← ClaudeAtlas

clean-code-reviewerlisted

Analyze code quality based on "Clean Code" principles. Identify naming, function size, duplication, over-engineering, and magic number issues with severity ratings and refactoring suggestions. Use when the user requests code review, quality check, refactoring advice, Clean Code analysis, code smell detection, or mentions terms like 代码体检, 代码质量, 重构检查.
aiskillstore/marketplace · ★ 329 · Code & Development · score 79
Install: claude install-skill aiskillstore/marketplace
# Clean Code Review 基于《代码整洁之道》原则,聚焦 7 个高收益检查维度。 ## Review Workflow ``` Review Progress: - [ ] 1. Scan codebase: identify files to review - [ ] 2. Check each dimension (naming, functions, DRY, YAGNI, magic numbers, clarity, conventions) - [ ] 3. Rate severity (高/中/低) for each issue - [ ] 4. Generate report sorted by severity ``` ## 核心原则:功能保留 所有建议仅针对**实现方式**优化——绝不建议改变代码的功能、输出或行为。 ## Check Dimensions ### 1. 命名问题【有意义的命名】 检查标志: - `data1`, `temp`, `result`, `info`, `obj` 等无意义命名 - 同一概念多种命名(`get`/`fetch`/`retrieve` 混用) ```typescript // ❌ const d = new Date(); const data1 = fetchUser(); // ✅ const currentDate = new Date(); const userProfile = fetchUser(); ``` ### 2. 函数问题【函数短小 + SRP】 检查标志: - 函数超过 **100 行** - 参数超过 **3 个** - 函数做多件事 ```typescript // ❌ 7 个参数 function processOrder(user, items, address, payment, discount, coupon, notes) // ✅ 使用参数对象 interface OrderParams { user: User; items: Item[]; shipping: Address; payment: Payment } function processOrder(params: OrderParams) ``` ### 3. 重复问题【DRY】 检查标志: - 相似的 if-else 结构 - 相似的数据转换/错误处理逻辑 - Copy-paste 痕迹 ### 4. 过度设计【YAGNI】 检查标志: - 从未为 true 的 `if (config.legacyMode)` 分支 - 只有一个实现的接口 - 无用的 try-catch 或 if-else ```typescript // ❌ YAGNI 违反:从未使用的兼容代码 if (config.legacyMode) { // 100 行兼容代码 } ``` ### 5. 魔法数字【避免硬编码】 检查标志: - 裸露数字无解释 - 硬编码字符串 ```typescript // ❌ if (retryCount > 3) // 3 是什么? setTimeout(fn, 86400000) // 这是多久? // ✅ const MAX_RETRY_COUNT = 3; const ONE_DAY_MS = 24 * 60 * 60 * 1000; ``` ### 6. 结构清晰度【可读性优先】 检查标志: