review-diff
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSkill: Review Diff
Skill: Git Diff审查
Purpose
目的
Review only the current change (git diff, staged and unstaged) along a single dimension: scope = diff. Cover intent and impact, regression and correctness, breaking changes and compatibility, side effects and idempotency, and observability. Emit a findings list in the standard format so a meta skill (e.g. review-code) can aggregate with language, framework, and cognitive skills. Do not perform architecture, security, or language-specific analysis; those are separate atomic skills.
仅审查当前变更(git diff,已暂存和未暂存的内容),聚焦单一维度:范围 = 差异内容。涵盖意图与影响、回归与正确性、破坏性变更与兼容性、副作用与幂等性,以及可观测性。输出符合标准格式的问题列表,以便元技能(如review-code)能与语言、框架和认知类技能的结果进行聚合。请勿执行架构、安全或特定语言的分析;这些属于独立的原子技能范畴。
Use Cases
适用场景
- Pre-commit: Quick diff-only check before commit.
- Orchestrated review: Used as the scope step when review-code runs scope → language → framework → library → cognitive.
- Focused change review: When the user explicitly wants only "what changed" analyzed.
When to use: When the input is a git diff and the task is to review the change set itself, not the full codebase or language/framework/cognitive dimensions.
- 提交前检查:提交前快速完成仅针对diff的检查。
- 编排式审查:在review-code执行「范围→语言→框架→库→认知」的流程中,作为范围审查步骤使用。
- 聚焦式变更审查:当用户明确希望仅分析「变更内容」时使用。
适用时机:当输入为git diff,且任务仅需审查变更集本身,而非整个代码库或语言/框架/认知维度时。
Behavior
行为规范
Scope
审查范围
- Analyze: Only files in the change set — diff (staged + unstaged) and untracked files that are part of the same change (included by default). Do not analyze unchanged or out-of-scope files.
- Untracked files: Included by default. When the invoker passes paths and full content of untracked files (e.g. new files to be committed), treat each as a full-file addition and apply the same review checklist; reference file path and line ranges as for added lines.
- Do not: Review whole repo, or cover architecture/security/language-specific rules; defer to review-codebase, review-security, review-dotnet, etc.
- 分析对象:仅针对变更集中的文件——diff(已暂存+未暂存)以及属于同一变更的未追踪文件(默认包含)。请勿分析未变更或超出范围的文件。
- 未追踪文件:默认包含在内。当调用者传入未追踪文件的路径和完整内容(例如即将提交的新文件)时,将其视为完整文件添加,并应用相同的审查清单;引用文件路径和行号范围,与处理新增行的方式一致。
- 禁止操作:请勿审查整个仓库,或进行架构/安全/特定语言规则的分析;此类工作交由review-codebase、review-security、review-dotnet等技能处理。
Review checklist (diff dimension only)
审查清单(仅针对diff维度)
For each changed file, evaluate and emit findings for:
- Intent and impact: What changed and why (if inferable); impact on callers, data, config, deployment.
- Regression and correctness: Does this change introduce bugs or miss edge cases? If it is a fix, is the fix complete?
- Breaking changes and compatibility: Does it break API/data/config contracts? Backward compatibility or versioning/deprecation?
- Side effects and idempotency: Unintended side effects, data corruption, duplication, or idempotency issues?
- Observability and debugging: Does the change add or fix logs, metrics, or error messages for production debugging?
- Concrete suggestions: Actionable fix or improvement with file:line or @@ block references.
对于每个变更文件,评估并输出以下方面的问题:
- 意图与影响:变更内容是什么,以及变更原因(如果可推断);对调用方、数据、配置、部署的影响。
- 回归与正确性:此变更是否引入bug或遗漏边缘情况?如果是修复,该修复是否完整?
- 破坏性变更与兼容性:是否破坏API/数据/配置契约?是否考虑向后兼容性或版本控制/废弃策略?
- 副作用与幂等性:是否存在意外副作用、数据损坏、重复或幂等性问题?
- 可观测性与调试:变更是否添加或修复了用于生产环境调试的日志、指标或错误信息?
- 具体建议:带有文件:行号或@@块引用的可操作修复或改进建议。
Tone and references
语气与引用
- Professional and engineering-focused: Review as if this will run in production.
- Precise: Reference specific locations (file:line or @@ block in the diff).
- 专业且聚焦工程实践:以生产环境运行的标准进行审查。
- 精准:引用具体位置(文件:行号或diff中的@@块)。
Special cases
特殊情况
- Bug fix: Verify the fix is correct and note any remaining or partial issues.
- Format/comments only: State briefly "format/comments only, no behavior change"; if comments contradict or mislead, still emit a finding with suggestion.
- Bug修复:验证修复是否正确,并记录任何剩余或部分未解决的问题。
- 仅格式/注释变更:简要说明“仅格式/注释变更,无行为变化”;如果注释与代码矛盾或产生误导,仍需输出问题并给出建议。
Input & Output
输入与输出
Input
输入
- git diff: Changes on the current branch vs HEAD (staged + unstaged), provided when invoking this skill.
- Untracked files (in scope by default): Paths and full content of untracked files that belong to the same change set. The invoker should include them so they are reviewed as full-file additions.
- git diff:当前分支与HEAD之间的变更(已暂存+未暂存),调用技能时提供。
- 未追踪文件(默认包含在范围内):属于同一变更集的未追踪文件的路径和完整内容。调用方应传入这些内容,以便将其作为完整文件添加进行审查。
Output
输出
- Emit zero or more findings in the format defined in Appendix: Output contract.
- Each finding MUST include Location, Category, Severity, Title, Description, and optionally Suggestion.
- Category for this skill is always scope.
- 输出零个或多个符合附录:输出契约格式定义的问题。
- 每个问题必须包含Location、Category、Severity、Title、Description,可选包含Suggestion。
- 本技能的Category始终为scope。
Restrictions
限制条件
- Do not review files outside the diff or the whole repo.
- Do not give conclusions without specific locations or actionable suggestions.
- Do not use vague language (e.g. "might be wrong" without type and fix direction).
- Do not perform security, architecture, or language/framework-specific checks; stay within the diff scope dimension.
- 禁止审查diff以外的文件或整个仓库。
- 禁止在没有具体位置或可操作建议的情况下给出结论。
- 禁止使用模糊语言(例如“可能存在错误”但未说明类型和修复方向)。
- 禁止执行安全、架构或特定语言/框架的检查;仅聚焦于diff范围维度。
Self-Check
自我检查
- Was only the diff (and untracked files in the change set, when included) reviewed?
- Were intent, impact, regression, correctness, compatibility, side effects, and observability covered?
- Is each finding emitted with Location, Category=scope, Severity, Title, Description, and optional Suggestion?
- Are issues referenced with file:line or @@?
- For bug fixes, was fix logic verified and any remaining issues noted?
- 是否仅审查了diff(以及变更集中包含的未追踪文件)?
- 是否涵盖了意图、影响、回归、正确性、兼容性、副作用和可观测性?
- 每个输出的问题是否包含Location、Category=scope、Severity、Title、Description,以及可选的Suggestion?
- 问题是否引用了文件:行号或@@块?
- 对于Bug修复,是否验证了修复逻辑并记录了任何剩余问题?
Examples
示例
Example 1: API change
示例1:API变更
- Input: Diff adds a query param and changes response shape.
- Expected: Emit findings for intent/impact on callers, backward compatibility risk, breaking-change risk with suggestion (e.g. versioning or deprecation); reference specific lines or @@ blocks. Do not emit security or architecture findings in this skill.
- 输入:Diff添加了一个查询参数并修改了响应结构。
- 预期输出:输出关于调用方影响、向后兼容性风险、破坏性变更风险的问题,并给出建议(例如版本控制或废弃策略);引用具体行号或@@块。本技能请勿输出安全或架构相关问题。
Example 2: Bug fix
示例2:Bug修复
- Input: Diff fixes a null pointer and one error code.
- Expected: Emit finding(s) confirming the fix and any regression (e.g. similar null-pointer or error-code issues); note observability (logs/errors); reference changed lines. Category = scope for all.
- 输入:Diff修复了一个空指针问题和一个错误码。
- 预期输出:输出确认修复的问题以及任何回归风险(例如类似的空指针或错误码问题);记录可观测性相关内容(日志/错误信息);引用变更行。所有问题的Category均为scope。
Edge case: Format/comments only
边缘情况:仅格式/注释变更
- Input: Diff only has indentation, spaces, or comment changes.
- Expected: Either no findings or a single minor/suggestion finding: "format/comments only, no behavior change"; if comments contradict code, emit a finding with Title and Suggestion.
- 输入:Diff仅包含缩进、空格或注释变更。
- 预期输出:要么无问题输出,要么输出一个轻微/建议类问题:“仅格式/注释变更,无行为变化”;如果注释与代码矛盾,需输出问题并给出Title和Suggestion。
Edge case: New (untracked) file in change set
边缘情况:变更集中包含新的(未追踪)文件
- Input: Diff plus one untracked file (path + full content) as part of the change set (included by default).
- Expected: Review the new file as a full-file addition; apply the same checklist (intent, impact, regression, compatibility, side effects, observability); emit findings with Location = path and line references. Category = scope for all.
- 输入:Diff加上一个属于同一变更集的未追踪文件(路径+完整内容)(默认包含)。
- 预期输出:将新文件视为完整文件添加进行审查;应用相同的审查清单(意图、影响、回归、兼容性、副作用、可观测性);输出问题时引用路径和行号。所有问题的Category均为scope。
Appendix: Output contract
附录:输出契约
When this skill produces a review, it emits a findings list compatible with aggregation by review-code. Each finding MUST follow:
| Element | Requirement |
|---|---|
| Location | |
| Category | |
| Severity | |
| Title | Short one-line summary. |
| Description | 1–3 sentences. |
| Suggestion | Concrete fix or improvement (optional). |
Example finding:
markdown
- **Location**: `pkg/handler.go:31`
- **Category**: scope
- **Severity**: major
- **Title**: New query param may break existing clients
- **Description**: Response shape changed without versioning. Old clients may fail.
- **Suggestion**: Add API version or deprecation header; document in CHANGELOG.当本技能生成审查结果时,输出的问题列表需兼容review-code的聚合要求。每个问题必须遵循以下规范:
| 元素 | 要求 |
|---|---|
| Location | |
| Category | |
| Severity | |
| Title | 简短的单行摘要。 |
| Description | 1–3句话。 |
| Suggestion | 具体的修复或改进建议(可选)。 |
示例问题:
markdown
- **Location**: `pkg/handler.go:31`
- **Category**: scope
- **Severity**: major
- **Title**: New query param may break existing clients
- **Description**: Response shape changed without versioning. Old clients may fail.
- **Suggestion**: Add API version or deprecation header; document in CHANGELOG.