code-review

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Code Review

代码评审

Guide proper code review practices emphasizing technical rigor, evidence-based claims, and verification over performative responses.
指导正确的代码评审实践,强调技术严谨性、基于证据的声明以及验证优先于表面回应。

Overview

概述

Code review requires three distinct practices:
  1. Receiving feedback - Technical evaluation over performative agreement
  2. Requesting reviews - Systematic review via code-reviewer subagent
  3. Verification gates - Evidence before any completion claims
Each practice has specific triggers and protocols detailed in reference files.
代码评审需要遵循三项明确的实践:
  1. 接收反馈 - 以技术评估替代表面认同
  2. 请求评审 - 通过code-reviewer subagent开展系统化评审
  3. 验证门机制 - 做出任何完成声明前必须提供证据
每项实践都有具体的触发条件和流程,详情见参考文件。

Core Principle

核心原则

Technical correctness over social comfort. Verify before implementing. Ask before assuming. Evidence before claims.
技术正确性优先于社交舒适度。 先验证再实施。先询问再假设。先拿证据再声明。

When to Use This Skill

何时使用该技能

Receiving Feedback

接收反馈

Trigger when:
  • Receiving code review comments from any source
  • Feedback seems unclear or technically questionable
  • Multiple review items need prioritization
  • External reviewer lacks full context
  • Suggestion conflicts with existing decisions
Reference:
references/code-review-reception.md
触发场景:
  • 收到来自任何渠道的代码评审意见
  • 反馈内容不清晰或存在技术疑问
  • 多项评审项需要优先级排序
  • 外部评审者缺乏完整上下文
  • 建议与现有决策存在冲突
参考文件:
references/code-review-reception.md

Requesting Review

请求评审

Trigger when:
  • Completing tasks in subagent-driven development (after EACH task)
  • Finishing major features or refactors
  • Before merging to main branch
  • Stuck and need fresh perspective
  • After fixing complex bugs
Reference:
references/requesting-code-review.md
触发场景:
  • 在子代理驱动的开发中完成单个任务后(每个任务完成后都需执行)
  • 完成主要功能开发或重构后
  • 合并到主分支之前
  • 遇到瓶颈需要新的思路时
  • 修复复杂漏洞后
参考文件:
references/requesting-code-review.md

Verification Gates

验证门机制

Trigger when:
  • About to claim tests pass, build succeeds, or work is complete
  • Before committing, pushing, or creating PRs
  • Moving to next task
  • Any statement suggesting success/completion
  • Expressing satisfaction with work
Reference:
references/verification-before-completion.md
触发场景:
  • 即将声明测试通过、构建成功或工作完成时
  • 提交、推送代码或创建PR之前
  • 进入下一个任务之前
  • 任何暗示工作成功/完成的表述
  • 表达对工作成果的满意时
参考文件:
references/verification-before-completion.md

Quick Decision Tree

快速决策树

SITUATION?
├─ Received feedback
│  ├─ Unclear items? → STOP, ask for clarification first
│  ├─ From human partner? → Understand, then implement
│  └─ From external reviewer? → Verify technically before implementing
├─ Completed work
│  ├─ Major feature/task? → Request code-reviewer subagent review
│  └─ Before merge? → Request code-reviewer subagent review
└─ About to claim status
   ├─ Have fresh verification? → State claim WITH evidence
   └─ No fresh verification? → RUN verification command first
当前场景?
├─ 收到反馈
│  ├─ 存在不清晰的内容? → 暂停,先请求澄清
│  ├─ 来自合作同事? → 理解后再实施
│  └─ 来自外部评审者? → 先从技术层面验证再实施
├─ 完成工作
│  ├─ 是主要功能/任务? → 请求code-reviewer subagent评审
│  └─ 即将合并分支? → 请求code-reviewer subagent评审
└─ 即将做出状态声明
   ├─ 有最新验证证据? → 附带证据做出声明
   └─ 无最新验证证据? → 先执行验证命令

Receiving Feedback Protocol

接收反馈流程

Response Pattern

响应模式

READ → UNDERSTAND → VERIFY → EVALUATE → RESPOND → IMPLEMENT
阅读 → 理解 → 验证 → 评估 → 回应 → 实施

Key Rules

关键规则

  • ❌ No performative agreement: "You're absolutely right!", "Great point!", "Thanks for [anything]"
  • ❌ No implementation before verification
  • ✅ Restate requirement, ask questions, push back with technical reasoning, or just start working
  • ✅ If unclear: STOP and ask for clarification on ALL unclear items first
  • ✅ YAGNI check: grep for usage before implementing suggested "proper" features
  • ❌ 禁止表面认同:如“你完全正确!”、“好观点!”、“感谢[任何表述]”
  • ❌ 禁止未验证就实施
  • ✅ 重述需求、提出问题、用技术依据反驳,或直接开展工作
  • ✅ 若内容不清晰:暂停,先对所有不清晰内容请求澄清
  • ✅ YAGNI检查:在实施建议的“合理”功能前,先通过grep检查现有使用场景

Source Handling

按反馈来源处理

  • Human partner: Trusted - implement after understanding, no performative agreement
  • External reviewers: Verify technically correct, check for breakage, push back if wrong
Full protocol:
references/code-review-reception.md
  • 合作同事: 可信任,理解后实施,禁止表面认同
  • 外部评审者: 先验证技术正确性,检查是否会导致问题,若错误则提出反驳
完整流程:
references/code-review-reception.md

Requesting Review Protocol

请求评审流程

When to Request

请求时机

  • After each task in subagent-driven development
  • After major feature completion
  • Before merge to main
  • 子代理驱动开发中每个任务完成后
  • 主要功能开发完成后
  • 合并到主分支之前

Process

流程步骤

  1. Get git SHAs:
    BASE_SHA=$(git rev-parse HEAD~1)
    and
    HEAD_SHA=$(git rev-parse HEAD)
  2. Dispatch code-reviewer subagent via Task tool with: WHAT_WAS_IMPLEMENTED, PLAN_OR_REQUIREMENTS, BASE_SHA, HEAD_SHA, DESCRIPTION
  3. Act on feedback: Fix Critical immediately, Important before proceeding, note Minor for later
Full protocol:
references/requesting-code-review.md
  1. 获取git哈希值:
    BASE_SHA=$(git rev-parse HEAD~1)
    HEAD_SHA=$(git rev-parse HEAD)
  2. 通过任务工具调度code-reviewer subagent,需提供:WHAT_WAS_IMPLEMENTED、PLAN_OR_REQUIREMENTS、BASE_SHA、HEAD_SHA、DESCRIPTION
  3. 根据反馈行动:立即修复严重问题,推进前修复重要问题,次要问题记录后续处理
完整流程:
references/requesting-code-review.md

Verification Gates Protocol

验证门机制流程

The Iron Law

铁律

NO COMPLETION CLAIMS WITHOUT FRESH VERIFICATION EVIDENCE
无最新验证证据,不得做出任何完成声明

Gate Function

门控流程

IDENTIFY command → RUN full command → READ output → VERIFY confirms claim → THEN claim
Skip any step = lying, not verifying
识别命令 → 执行完整命令 → 读取输出 → 验证结果与声明一致 → 再做出声明
跳过任何步骤=未验证,属于不实表述

Requirements

验证要求

  • Tests pass: Test output shows 0 failures
  • Build succeeds: Build command exit 0
  • Bug fixed: Test original symptom passes
  • Requirements met: Line-by-line checklist verified
  • 测试通过:测试输出显示0个失败项
  • 构建成功:构建命令返回退出码0
  • 漏洞修复:针对原始症状的测试通过
  • 需求满足:逐行核对检查清单确认完成

Red Flags - STOP

危险信号 - 立即暂停

Using "should"/"probably"/"seems to", expressing satisfaction before verification, committing without verification, trusting agent reports, ANY wording implying success without running verification
Full protocol:
references/verification-before-completion.md
使用“应该”/“可能”/“似乎”等表述、验证前表达对成果的满意、未验证就提交代码、信任代理报告、任何未执行验证就暗示成功的表述
完整流程:
references/verification-before-completion.md

Integration with Workflows

与工作流的集成

  • Subagent-Driven: Review after EACH task, verify before moving to next
  • Pull Requests: Verify tests pass, request code-reviewer review before merge
  • General: Apply verification gates before any status claims, push back on invalid feedback
  • 子代理驱动开发: 每个任务完成后评审,进入下一个任务前验证
  • 拉取请求(Pull Requests): 验证测试通过后,请求code-reviewer subagent评审再合并
  • 通用场景: 做出任何状态声明前应用验证门机制,对无效反馈提出反驳

Bottom Line

核心总结

  1. Technical rigor over social performance - No performative agreement
  2. Systematic review processes - Use code-reviewer subagent
  3. Evidence before claims - Verification gates always
Verify. Question. Then implement. Evidence. Then claim.
  1. 技术严谨优先于表面社交表现 - 禁止表面认同
  2. 系统化评审流程 - 使用code-reviewer subagent
  3. 先有证据再声明 - 始终启用验证门机制
先验证,再质疑,然后实施。先拿证据,再做声明。