pr-review
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePR Review
PR代码审查
Diff-based code review across five dimensions. Reads the changed files, selects
applicable review methodologies, and produces an aggregated report with severity-ranked
findings.
基于diff的五大维度代码审查。读取变更文件,选择适用的审查方法,生成汇总报告,包含按严重程度排序的审查结果。
Reference Files
参考文件
| File | Contents | Load When |
|---|---|---|
| Guideline compliance, bug detection, confidence scoring | Always |
| Behavioral test coverage, criticality rating | Test files changed |
| Silent failure patterns, catch block analysis | Error handling changed |
| Invariant analysis, 4-dimension rating rubric | Type definitions added/modified |
| Comment accuracy, long-term value, rot detection | Comments/docstrings added |
| 文件 | 内容 | 加载条件 |
|---|---|---|
| 规范合规性、漏洞检测、置信度评分 | 始终加载 |
| 行为测试覆盖率、严重程度评级 | 测试文件变更时 |
| 静默故障模式、catch块分析 | 错误处理逻辑变更时 |
| 不变量分析、4维评级标准 | 新增/修改类型定义时 |
| 注释准确性、长期价值、过时检测 | 新增注释/文档字符串时 |
Workflow
工作流
Phase 1: Scope
阶段1:范围确认
- Determine the review target:
- Default: (unstaged changes)
git diff - If user specifies a PR: or
git diff main...HEADgh pr diff <number> - If user specifies files: review those files directly
- Default:
- List all changed files with
git diff --name-only - Read the project's CLAUDE.md (if present) for project-specific rules
- 确定审查目标:
- 默认:(未暂存变更)
git diff - 若用户指定PR:或
git diff main...HEADgh pr diff <number> - 若用户指定文件:直接审查这些文件
- 默认:
- 用列出所有变更文件
git diff --name-only - 读取项目的CLAUDE.md(如果存在)获取项目专属规则
Phase 2: Route
阶段2:维度匹配
Classify changed files and select applicable dimensions:
| Condition | Dimension | Reference to Load |
|---|---|---|
| Always | Code review | |
Files matching | Test analysis | |
| Files containing try/catch, except, .catch, Result, error callbacks | Error handling | |
| Files containing class, interface, type, struct, enum, dataclass definitions | Type design | |
| Files with new/modified docstrings, JSDoc, or block comments | Comment quality | |
Load only the reference files that apply. Skip dimensions with no matching files.
对变更文件分类,选择适用的审查维度:
| 条件 | 维度 | 加载的参考文件 |
|---|---|---|
| 始终满足 | 代码审查 | |
文件匹配 | 测试分析 | |
| 文件包含try/catch、except、.catch、Result、错误回调 | 错误处理 | |
| 文件包含class、interface、type、struct、enum、dataclass定义 | 类型设计 | |
| 文件有新增/修改的文档字符串、JSDoc或块注释 | 注释质量 | |
仅加载适用的参考文件,跳过无匹配文件的维度。
Phase 3: Review
阶段3:执行审查
For each applicable dimension, analyze the diff using the loaded methodology:
- Code review — scan every changed file for guideline violations and bugs. Apply confidence scoring (0-100). Only report issues >= 80.
- Test analysis — map test coverage to changed code paths. Rate gaps 1-10. Only report gaps >= 5.
- Error handling — examine every error handler in the diff for silent failures. Classify CRITICAL/HIGH/MEDIUM.
- Type design — evaluate new or modified types on 4 dimensions (encapsulation, invariant expression, usefulness, enforcement). Rate each 1-10.
- Comment quality — verify accuracy, assess long-term value, flag comment rot.
针对每个适用维度,使用加载的方法论分析diff:
- 代码审查 — 扫描所有变更文件是否存在规范违反和漏洞。应用置信度评分(0-100),仅报告得分>=80的问题。
- 测试分析 — 将测试覆盖率映射到变更的代码路径,对覆盖率缺口按1-10评级,仅报告得分>=5的缺口。
- 错误处理 — 检查diff中所有错误处理逻辑是否存在静默故障,按CRITICAL/HIGH/MEDIUM分类。
- 类型设计 — 从4个维度评估新增或修改的类型(封装性、不变量表达、实用性、强制约束),每个维度按1-10评级。
- 注释质量 — 验证准确性、评估长期价值、标记过时注释。
Phase 4: Aggregate
阶段4:结果汇总
Merge all findings into a single report, deduplicated and severity-ranked.
Deduplication rules:
- If two dimensions flag the same file:line, keep the higher-severity finding
- If code-review and error-handling both flag an empty catch block, merge into one finding with the error-handling severity (it's the specialist)
Severity mapping across dimensions:
| Dimension | Maps to Critical | Maps to Important | Maps to Suggestion |
|---|---|---|---|
| Code review | Confidence 90-100 | Confidence 80-89 | — |
| Test analysis | Rating 9-10 | Rating 7-8 | Rating 5-6 |
| Error handling | CRITICAL | HIGH | MEDIUM |
| Type design | Any rating <= 3/10 | Any rating 4-6/10 | Rating 7-8/10 |
| Comment quality | Factually incorrect | Misleading or incomplete | Restates obvious code |
将所有审查结果合并为单个报告,去重后按严重程度排序。
去重规则:
- 若两个维度标记了同一个文件的同一行,保留严重程度更高的结果
- 若代码审查和错误处理都标记了空catch块,合并为一条结果,采用错误处理维度的严重程度(该维度更专业)
跨维度严重程度映射:
| 维度 | 对应严重级别Critical | 对应严重级别Important | 对应严重级别Suggestion |
|---|---|---|---|
| 代码审查 | 置信度90-100 | 置信度80-89 | — |
| 测试分析 | 评级9-10 | 评级7-8 | 评级5-6 |
| 错误处理 | CRITICAL | HIGH | MEDIUM |
| 类型设计 | 任意评级<=3/10 | 任意评级4-6/10 | 评级7-8/10 |
| 注释质量 | 事实错误 | 误导性或不完整 | 重复说明显而易见的代码 |
Output Format
输出格式
undefinedundefinedPR Review Summary
PR Review Summary
Scope: [X files changed, Y dimensions applied]
Dimensions: [list of active dimensions]
Scope: [X files changed, Y dimensions applied]
Dimensions: [list of active dimensions]
Critical Issues (must fix before merge)
Critical Issues (must fix before merge)
- [dimension] — Description. Fix suggestion.
file:line
- [dimension] — Description. Fix suggestion.
file:line
Important Issues (should fix)
Important Issues (should fix)
- [dimension] — Description. Fix suggestion.
file:line
- [dimension] — Description. Fix suggestion.
file:line
Suggestions (consider)
Suggestions (consider)
- [dimension] — Description.
file:line
- [dimension] — Description.
file:line
Strengths
Strengths
- What's well-done in this changeset.
- What's well-done in this changeset.
Recommended Action
Recommended Action
- Fix critical issues
- Address important issues
- Consider suggestions
- Re-run review after fixes
If no issues are found at any severity level, confirm the code meets standards with
a brief summary of what was reviewed and which dimensions were applied.
---- Fix critical issues
- Address important issues
- Consider suggestions
- Re-run review after fixes
如果所有严重级别都未发现问题,确认代码符合标准,简要说明审查内容和应用的维度即可。
---Aspect Selection
维度选择
Users can request specific dimensions instead of running all:
| User Says | Dimensions Applied |
|---|---|
| "review my PR" / "check my changes" | All applicable (default) |
| "review the code" / "check code quality" | Code review only |
| "check the tests" / "is test coverage good" | Test analysis only |
| "check error handling" / "find silent failures" | Error handling only |
| "review the types" / "check type design" | Type design only |
| "check the comments" / "review documentation" | Comment quality only |
When a specific aspect is requested, load only that reference file and skip routing.
用户可以指定特定审查维度,无需运行所有维度:
| 用户指令 | 应用的维度 |
|---|---|
| "review my PR" / "check my changes" | 所有适用维度(默认) |
| "review the code" / "check code quality" | 仅代码审查 |
| "check the tests" / "is test coverage good" | 仅测试分析 |
| "check error handling" / "find silent failures" | 仅错误处理 |
| "review the types" / "check type design" | 仅类型设计 |
| "check the comments" / "review documentation" | 仅注释质量 |
当用户指定特定维度时,仅加载对应的参考文件,跳过维度匹配步骤。
Error Handling
错误处理
| Problem | Resolution |
|---|---|
| No git diff available | Ask user to specify files or scope |
| CLAUDE.md not found | Review against general best practices; note the absence |
| No test files in diff | Skip test analysis dimension; note in output |
| Diff is empty | Report "no changes to review" and stop |
| Diff exceeds context limits | Focus on files the user is most likely to care about; summarize skipped files |
| 问题 | 解决方案 |
|---|---|
| 无可用git diff | 要求用户指定文件或审查范围 |
| 未找到CLAUDE.md | 按照通用最佳实践审查,并注明未找到项目专属规则 |
| diff中无测试文件 | 跳过测试分析维度,并在输出中注明 |
| diff为空 | 报告"no changes to review"并终止流程 |
| diff超出上下文限制 | 重点审查用户最关心的文件,汇总说明跳过的文件 |
Calibration Rules
校准规则
- Precision over recall. A false positive erodes trust in the review. Only report issues at >= 80 confidence (code review) or >= 5 criticality (tests). Silence is better than noise.
- File:line references are mandatory. Every finding must include a specific location. Vague findings ("consider improving error handling") are not actionable.
- Project rules override general rules. If CLAUDE.md says "use arrow functions",
do not flag arrow functions even if conventional style prefers declarations.
function - Deduplication is mandatory. If two dimensions flag the same issue, merge them. Never report the same problem twice.
- Acknowledge strengths. A review that only lists problems is demoralizing. Note what's done well, even briefly.
- Code-refiner handles simplification. This skill reviews and reports. It does not
refactor or simplify — that's the skill's job. Keep the roles separate.
code-refiner
- 精准优先于全面。误报会侵蚀对审查结果的信任。仅报告置信度>=80(代码审查)或严重程度>=5(测试)的问题,无结果好过噪声结果。
- 必须包含文件:行号引用。每条结果都必须包含具体位置,模糊的结果(如"考虑优化错误处理")不具备可执行性。
- 项目规则优先于通用规则。如果CLAUDE.md中规定"使用箭头函数",即使通用规范更偏好声明,也不要标记箭头函数为问题。
function - 必须去重。如果两个维度标记了同一个问题,合并处理,禁止重复报告同一个问题。
- 肯定优点。仅列出问题的审查会打击积极性,即使很简短也要注明做得好的地方。
- 代码优化由code-refiner负责。本skill仅负责审查和报告,不负责重构或简化代码——那是skill的职责,保持角色分离。
code-refiner