reviewing-code-quality
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCode Quality Review Skill
代码质量评审技能
Purpose
用途
This skill provides automated analysis commands and detection patterns for code quality issues. Use this as a reference for WHAT to check and HOW to detect issues—not for output formatting or workflow.
本技能提供用于检测代码质量问题的自动化分析命令与检测模式。将其作为检查内容与检测方法的参考——而非输出格式或工作流程的参考。
Automated Analysis Tools
自动化分析工具
Run these scripts to gather metrics (if tools available):
若工具可用,运行以下脚本以收集指标:
Linting Analysis
代码检查分析
bash
bash ~/.claude/plugins/marketplaces/claude-configs/review/scripts/review-lint.sh
**Returns:** Error count, violations with file:line, auto-fix suggestionsbash
bash ~/.claude/plugins/marketplaces/claude-configs/review/scripts/review-lint.sh返回结果: 错误数量、带文件:行号的违规项、自动修复建议
Type Safety Analysis
类型安全分析
bash
bash ~/.claude/plugins/marketplaces/claude-configs/review/scripts/review-types.shReturns: Type errors, missing annotations, error locations
bash
bash ~/.claude/plugins/marketplaces/claude-configs/review/scripts/review-types.sh返回结果: 类型错误、缺失的注解、错误位置
Unused Code Detection
未使用代码检测
bash
bash ~/.claude/plugins/marketplaces/claude-configs/review/scripts/review-unused-code.shReturns: Unused exports, unused dependencies, dead code
bash
bash ~/.claude/plugins/marketplaces/claude-configs/review/scripts/review-unused-code.sh返回结果: 未使用的导出项、未使用的依赖、死代码
TODO/FIXME Comments
TODO/FIXME 注释
bash
bash ~/.claude/plugins/marketplaces/claude-configs/review/scripts/review-todos.shReturns: Comment count by type, locations with context
bash
bash ~/.claude/plugins/marketplaces/claude-configs/review/scripts/review-todos.sh返回结果: 按类型统计的注释数量、带上下文的位置信息
Debug Statements
调试语句
bash
bash ~/.claude/plugins/marketplaces/claude-configs/review/scripts/review-debug-statements.shReturns: console.log/debugger statements with locations
bash
bash ~/.claude/plugins/marketplaces/claude-configs/review/scripts/review-debug-statements.sh返回结果: 带位置信息的console.log/debugger语句
Large Files
大文件检测
bash
bash ~/.claude/plugins/marketplaces/claude-configs/review/scripts/review-large-files.shReturns: Files >500 lines sorted by size
bash
bash ~/.claude/plugins/marketplaces/claude-configs/review/scripts/review-large-files.sh返回结果: 行数超过500的文件(按大小排序)
Manual Detection Patterns
手动检测模式
When automated tools unavailable or for deeper analysis, use Read/Grep/Glob to detect:
当自动化工具不可用或需要深度分析时,使用Read/Grep/Glob工具进行检测:
Code Smells to Detect
需检测的代码异味
Long Functions:
bash
undefined长函数:
bash
undefinedFind functions with >50 lines
查找行数超过50的函数
grep -n "function|const.=.=>.*{" <file> | while read line; do
Count lines until closing brace
done
Look for: Functions spanning >50 lines, multiple responsibilities
**Deep Nesting:**
```bashgrep -n "function|const.=.=>.*{" <file> | while read line; do
统计至闭合花括号的行数
done
检查要点:行数超过50的函数、承担多个职责
**深层嵌套:**
```bashFind lines with >3 levels of indentation
查找缩进级别超过3层的行
grep -E "^[[:space:]]{12,}" <file>
Look for: Nesting depth >3, complex conditionals
**Missing Error Handling:**
```bash
grep -n "async\|await\|Promise\|\.then\|\.catch" <file>Look for: Async operations without try-catch or .catch()
Poor Type Safety:
bash
grep -n "any\|as any\|@ts-ignore\|@ts-expect-error" <file>Look for: Type assertions, any usage, suppression comments
Repeated Patterns:
Use Read to identify duplicate logic blocks (>5 lines similar code)
Poor Naming:
Look for: Single-letter variables (except i, j in loops), unclear abbreviations, misleading names
grep -E "^[[:space:]]{12,}" <file>
检查要点:嵌套深度超过3层、复杂条件判断
**缺失错误处理:**
```bash
grep -n "async\|await\|Promise\|\.then\|\.catch" <file>检查要点:无try-catch或.catch()的异步操作
类型安全不足:
bash
grep -n "any\|as any\|@ts-ignore\|@ts-expect-error" <file>检查要点:类型断言、any类型使用、抑制注释
重复模式:
使用Read工具识别重复逻辑块(相似度超过5行的代码)
命名不佳:
检查要点:单字母变量(循环中的i、j除外)、含义模糊的缩写、误导性命名
Severity Mapping
严重程度映射
Use these criteria when classifying findings:
| Pattern | Severity | Rationale |
|---|---|---|
| Type errors blocking compilation | critical | Prevents deployment |
| Missing error handling in critical paths | high | Production crashes |
| Unused exports in public API | high | Breaking changes needed |
| Large files (>500 LOC) | medium | Maintainability impact |
| TODO comments | medium | Incomplete work |
| Debug statements (console.log) | medium | Production noise |
| Deep nesting (>3 levels) | medium | Complexity issues |
| Long functions (>50 lines) | medium | Readability issues |
| Linting warnings | nitpick | Style consistency |
| Minor naming issues | nitpick | Clarity improvements |
分类检测结果时请遵循以下标准:
| 模式 | 严重程度 | 理由 |
|---|---|---|
| 阻止编译的类型错误 | critical | 阻止部署 |
| 关键路径中缺失错误处理 | high | 导致生产环境崩溃 |
| 公共API中的未使用导出项 | high | 需要进行破坏性变更 |
| 大文件(>500行) | medium | 影响可维护性 |
| TODO注释 | medium | 未完成工作 |
| 调试语句(console.log) | medium | 生产环境冗余输出 |
| 深层嵌套(>3层) | medium | 复杂度问题 |
| 长函数(>50行) | medium | 可读性问题 |
| 代码检查警告 | nitpick | 风格一致性 |
| 轻微命名问题 | nitpick | 提升清晰度 |
Analysis Priority
分析优先级
- Run automated scripts first (if tools available)
- Parse script outputs for file:line references
- Read flagged files using Read tool
- Apply manual detection patterns to flagged files
- Cross-reference findings (e.g., large file + many TODOs = higher priority)
- 优先运行自动化脚本(若工具可用)
- 解析脚本输出以获取文件:行号参考
- 使用Read工具查看标记的文件
- 对标记文件应用手动检测模式
- 交叉参考检测结果(例如:大文件+大量TODO=更高优先级)
Integration Notes
集成说明
- This skill provides detection methods only
- Output formatting is handled by the calling agent
- Severity classification should align with agent's schema
- Do NOT include effort estimates or workflow instructions
- 本技能仅提供检测方法
- 输出格式由调用Agent处理
- 严重程度分类应与Agent的架构保持一致
- 请勿包含工作量估算或工作流程说明
Related Skills
相关技能
Cross-Plugin References:
- If reviewing Zod schema patterns, use the reviewing-patterns skill for detecting validation issues and schema anti-patterns
- Uses skills tagged with including reviewing-vitest-config from vitest-4 for detecting deprecated patterns and Vitest 4.x migration issues
review: true
跨插件参考:
- 若评审Zod schema模式,使用reviewing-patterns技能检测验证问题与schema反模式
- 使用标记有的技能,包括来自vitest-4的reviewing-vitest-config,以检测弃用模式与Vitest 4.x迁移问题
review: true