by hylarucoder
代码审查有助于在可维护性问题变成技术债务之前识别出来。此技能为AI助手提供系统化的评估指南,涵盖命名、函数、重复和项目约定等七个关键维度。
1. 打开 Claude 聊天界面
2. 点击下方 "📋 复制" 按钮
3. 粘贴到 Claude 聊天框中并发送
4. 输入 "使用 clean-code-reviewer 技能" 开始使用
=== clean-code-reviewer 技能 === 作者: hylarucoder 描述: 代码审查有助于在可维护性问题变成技术债务之前识别出来。此技能为AI助手提供系统化的评估指南,涵盖命名、函数、重复和项目约定等七个关键维度。 使用方法: 1. 调用技能: "使用 clean-code-reviewer 技能" 2. 提供相关信息: 根据技能要求提供必要参数 3. 查看结果: 技能会返回处理结果 示例: "使用 clean-code-reviewer 技能,帮我分析一下这段代码"
这种方法适用于所有 Claude 用户,不需要安装额外工具。
coding
safe
基于《代码整洁之道》原则,聚焦 7 个高收益检查维度。
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
所有建议仅针对实现方式优化——绝不建议改变代码的功能、输出或行为。
检查标志:
data1, temp, result, info, obj 等无意义命名get/fetch/retrieve 混用)// ❌
const d = new Date();
const data1 = fetchUser();
// ✅
const currentDate = new Date();
const userProfile = fetchUser();
检查标志:
// ❌ 7 个参数
function processOrder(user, items, address, payment, discount, coupon, notes)
// ✅ 使用参数对象
interface OrderParams { user: User; items: Item[]; shipping: Address; payment: Payment }
function processOrder(params: OrderParams)
检查标志:
检查标志:
if (config.legacyMode) 分支// ❌ YAGNI 违反:从未使用的兼容代码
if (config.legacyMode) {
// 100 行兼容代码
}
检查标志:
// ❌
if (retryCount > 3) // 3 是什么?
setTimeout(fn, 86400000) // 这是多久?
// ✅
const MAX_RETRY_COUNT = 3;
const ONE_DAY_MS = 24 * 60 * 60 * 1000;
检查标志:
// ❌ 嵌套三元
const status = a ? (b ? 'x' : 'y') : (c ? 'z' : 'w');
// ✅ 使用 switch 或 if/else
function getStatus(a, b, c) {
if (a) return b ? 'x' : 'y';
return c ? 'z' : 'w';
}
检查标志:
// ❌ 风格不一致
import { api } from './api'
import axios from 'axios' // 外部库应在前
const handle_click = () => { ... } // 命名风格混用
// ✅ 统一风格
import axios from 'axios'
import { api } from './api'
function handleClick(): void { ... }
[!TIP] 项目规范应参照
CLAUDE.mdAGENTS.md或项目约定的编码标准。
| 级别 | 标准 |
|---|---|
| 高 | 影响可维护性/可读性,应立即修复 |
| 中 | 有改进空间,建议修复 |
| 低 | 代码气味,可选优化 |
### [问题类型]: [简述]
- **原则**: [Clean Code 原则]
- **位置**: `文件:行号`
- **级别**: 高/中/低
- **问题**: [具体描述]
- **建议**: [修复方向]
Detailed examples: See references/detailed-examples.md
Language patterns: See references/language-patterns.md
按以下维度拆分给多 agent 并行:
示例:/clean-code-reviewer --scope=components 或 --dimension=naming
汇总时需去重和统一严重程度评定。
View Count
0
Download Count
0
Favorite Count
0
Quality Score
70