reviewing-code-quality

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Code 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 suggestions
bash
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.sh
Returns: 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.sh
Returns: 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.sh
Returns: 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.sh
Returns: 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.sh
Returns: 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
undefined

Find 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:**

```bash
grep -n "function|const.=.=>.*{" <file> | while read line; do

统计至闭合花括号的行数

done

检查要点:行数超过50的函数、承担多个职责

**深层嵌套:**

```bash

Find 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:
PatternSeverityRationale
Type errors blocking compilationcriticalPrevents deployment
Missing error handling in critical pathshighProduction crashes
Unused exports in public APIhighBreaking changes needed
Large files (>500 LOC)mediumMaintainability impact
TODO commentsmediumIncomplete work
Debug statements (console.log)mediumProduction noise
Deep nesting (>3 levels)mediumComplexity issues
Long functions (>50 lines)mediumReadability issues
Linting warningsnitpickStyle consistency
Minor naming issuesnitpickClarity improvements
分类检测结果时请遵循以下标准:
模式严重程度理由
阻止编译的类型错误critical阻止部署
关键路径中缺失错误处理high导致生产环境崩溃
公共API中的未使用导出项high需要进行破坏性变更
大文件(>500行)medium影响可维护性
TODO注释medium未完成工作
调试语句(console.log)medium生产环境冗余输出
深层嵌套(>3层)medium复杂度问题
长函数(>50行)medium可读性问题
代码检查警告nitpick风格一致性
轻微命名问题nitpick提升清晰度

Analysis Priority

分析优先级

  1. Run automated scripts first (if tools available)
  2. Parse script outputs for file:line references
  3. Read flagged files using Read tool
  4. Apply manual detection patterns to flagged files
  5. Cross-reference findings (e.g., large file + many TODOs = higher priority)
  1. 优先运行自动化脚本(若工具可用)
  2. 解析脚本输出以获取文件:行号参考
  3. 使用Read工具查看标记的文件
  4. 对标记文件应用手动检测模式
  5. 交叉参考检测结果(例如:大文件+大量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
    review: true
    including reviewing-vitest-config from vitest-4 for detecting deprecated patterns and Vitest 4.x migration issues
跨插件参考:
  • 若评审Zod schema模式,使用reviewing-patterns技能检测验证问题与schema反模式
  • 使用标记有
    review: true
    的技能,包括来自vitest-4的reviewing-vitest-config,以检测弃用模式与Vitest 4.x迁移问题