review-diff
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese<!-- markdownlint-disable-file MD041 -->
STARTER_CHARACTER = ⚡
<!-- markdownlint-disable-file MD041 -->
STARTER_CHARACTER = ⚡
Diff Review
差异审查
Review everything that differs from across 9 perspectives, each by one subagent. The nine areas' findings then run through the same scripted collate, merge, rank, and isolated-judge verification chain review-deep uses. No arguments.
mainAvailable on Claude Code (through this plugin) and Codex. Fails preflight by name on OpenCode and Hermes Agent, neither of which can dispatch a subagent to a named reviewer type.
This skill runs , dispatched as a subagent with no user present to answer a prompt. Never pause before dispatch to confirm scope, cost, or model spend; the diff is whatever it is.
context: fork从 9 个维度审查相对于 的所有差异,每个维度由一个 subagent 负责。随后,9 个领域的结果将经过与 review-deep 相同的脚本化汇总、合并、排序和隔离 judge 验证链处理。无需参数。
main可通过 Claude Code(经由此插件)和 Codex 使用。在 OpenCode 和 Hermes Agent 上会按名称在 preflight 阶段失败,因为二者都无法将 subagent 派发给指定类型的 reviewer。
此 skill 以 运行,作为 subagent 被派发,期间没有用户可回答提示词。派发前绝不暂停以确认范围、成本或模型消耗;审查对象就是当前 diff。
context: forkStep 1: Preflight
第 1 步:Preflight
Determine your harness. In Claude Code, and is this plugin's root, two directories up from this SKILL.md. In Codex, ; does not apply there, since the nine Codex reviewer agents live at a fixed path, not inside a plugin.
HARNESS=claudePLUGIN_ROOTHARNESS=codexPLUGIN_ROOTbash
S="${CLAUDE_SKILL_DIR}/../review-deep/scripts" # replace ${CLAUDE_SKILL_DIR} with this SKILL.md's own directory on a non-Claude harness
[ -f "$S/init_run.py" ] || { echo "scripts not found at $S"; exit 1; }
HARNESS=claude
PLUGIN_ROOT="$(cd "${CLAUDE_SKILL_DIR}/../.." && pwd)"
OUT=$(python3 "$S/preflight.py" --tier diff --harness "$HARNESS" --plugin-root "$PLUGIN_ROOT")
STATUS=$?
echo "$OUT"
[ "$STATUS" -eq 0 ] || exit 1
LABEL=$(echo "$OUT" | sed -n 's/^LABEL=//p')
AGENT_PREFIX=$(echo "$OUT" | sed -n 's/^AGENT_PREFIX=//p')preflight.pyorigin/mainmainPASSFAILFAILLABEL$LABEL-<area>.mdAGENT_PREFIXclanker-code-review:$S确定 harness。在 Claude Code 中,, 是此插件的根目录,即从该 向上两级。在 Codex 中,; 不适用,因为九个 Codex reviewer agent 位于固定路径,而不是插件内部。
HARNESS=claudePLUGIN_ROOTSKILL.mdHARNESS=codexPLUGIN_ROOTbash
S="${CLAUDE_SKILL_DIR}/../review-deep/scripts" # replace ${CLAUDE_SKILL_DIR} with this SKILL.md's own directory on a non-Claude harness
[ -f "$S/init_run.py" ] || { echo "scripts not found at $S"; exit 1; }
HARNESS=claude
PLUGIN_ROOT="$(cd "${CLAUDE_SKILL_DIR}/../.." && pwd)"
OUT=$(python3 "$S/preflight.py" --tier diff --harness "$HARNESS" --plugin-root "$PLUGIN_ROOT")
STATUS=$?
echo "$OUT"
[ "$STATUS" -eq 0 ] || exit 1
LABEL=$(echo "$OUT" | sed -n 's/^LABEL=//p')
AGENT_PREFIX=$(echo "$OUT" | sed -n 's/^AGENT_PREFIX=//p')preflight.pyorigin/mainmainPASSFAILFAILLABEL$LABEL-<area>.mdAGENT_PREFIXclanker-code-review:$SStep 2: Resolve the Base
第 2 步:解析基准
bash
PROJECT_ROOT=$(git rev-parse --show-toplevel)
BASE_REF=$(git rev-parse --verify --quiet origin/main || git rev-parse --verify --quiet main)
if [ -z "$BASE_REF" ]; then
echo "No main branch found (tried origin/main and main)"
exit 1
fi
BASE=$(git merge-base HEAD "$BASE_REF")bash
PROJECT_ROOT=$(git rev-parse --show-toplevel)
BASE_REF=$(git rev-parse --verify --quiet origin/main || git rev-parse --verify --quiet main)
if [ -z "$BASE_REF" ]; then
echo "No main branch found (tried origin/main and main)"
exit 1
fi
BASE=$(git merge-base HEAD "$BASE_REF")On main itself the merge base is HEAD, which would hide committed work.
On main itself the merge base is HEAD, which would hide committed work.
Fall back to the previous commit so the branch tip is still under review.
Fall back to the previous commit so the branch tip is still under review.
if [ "$BASE" = "$(git rev-parse HEAD)" ]; then
BASE=$(git rev-parse --verify --quiet HEAD~1 || echo "$BASE")
fi
echo "BASE=$BASE"
undefinedif [ "$BASE" = "$(git rev-parse HEAD)" ]; then
BASE=$(git rev-parse --verify --quiet HEAD~1 || echo "$BASE")
fi
echo "BASE=$BASE"
undefinedStep 3: Collect the Delta
第 3 步:收集差异
bash
git log --oneline "${BASE}"..HEAD
git diff "${BASE}" --find-renames --stat
git diff "${BASE}" --find-renames
git status --porcelain
git ls-files --others --exclude-standardgit diff "$BASE"..HEAD--find-renamesR<score>git status --porcelainls-files --others.gitignoreStop when all five signals are empty (the commit log, the diffstat, the diff, the status, and the untracked list). Report and stop.
No changes against mainbash
git log --oneline "${BASE}"..HEAD
git diff "${BASE}" --find-renames --stat
git diff "${BASE}" --find-renames
git status --porcelain
git ls-files --others --exclude-standardgit diff "$BASE"..HEAD--find-renamesR<score>git status --porcelainls-files --others.gitignore当五个信号全部为空时停止,即 commit log、diffstat、diff、status 和未跟踪文件列表均为空。报告 并停止。
No changes against mainStep 4: Start the Run
第 4 步:启动运行
bash
python3 "$S/init_run.py" --kind diff --base "$BASE" "$PROJECT_ROOT" "$PROJECT_ROOT" "$PROJECT_ROOT/.llmtmp/review-diff"Prints and . is , outside the repository. On a clean working tree is HEAD. On a dirty one, snapshots the working tree into an unreferenced commit over HEAD, so the reviewers, the below, and the scripted chain's judges all see the exact same uncommitted edits. carries , , and .
RUN_DIRCOMMITRUN_DIR${XDG_CACHE_HOME:-~/.cache}/review-diff/<repo>-<commit12>COMMITinit_run.pygit diffrun.jsonkind: diffbase: $BASEticket_label: review-diffbash
python3 "$S/init_run.py" --kind diff --base "$BASE" "$PROJECT_ROOT" "$PROJECT_ROOT" "$PROJECT_ROOT/.llmtmp/review-diff"init_run.pyRUN_DIRCOMMITRUN_DIR${XDG_CACHE_HOME:-~/.cache}/review-diff/<repo>-<commit12>COMMITinit_run.pygit diffrun.jsonkind: diffbase: $BASEticket_label: review-diffStep 5: Materialize the Input
第 5 步:物化输入
Write the whole change set to one file. Reviewers hold but no , so they cannot run git themselves. Passing the diff through nine prompts costs nine copies of it in orchestrator output; writing it once and having each reviewer read it costs one.
ReadBashbash
STATE_DIR="$PROJECT_ROOT/.llmtmp/review-diff"
mkdir -p "$STATE_DIR"
find "$STATE_DIR" -mindepth 1 -delete
INPUT="$STATE_DIR/input.md"
{
echo "# Change set vs merge-base ${BASE}, reviewed at commit ${COMMIT}"
echo; echo "## Commits"; git log --oneline "${BASE}"..HEAD
echo; echo "## Status"; git status --porcelain
echo; echo "## Diffstat"; git diff "${BASE}" "${COMMIT}" --find-renames --stat
echo; echo "## Diff"; git diff "${BASE}" "${COMMIT}" --find-renames
} > "$INPUT"
for f in $(git ls-files --others --exclude-standard); do
{ echo; echo "## Untracked file: $f"; cat -n "$f"; } >> "$INPUT"
done
wc -c "$INPUT"git diff "$BASE" "$COMMIT"git diff "$BASE"$COMMITmkdir -pfind -deleterm -rfsafe-rmPATH-f将整个变更集写入一个文件。Reviewer 拥有 但没有 ,因此无法自行运行 git。将 diff 通过九个提示词传递会在 orchestrator 输出中产生九份副本;只写一次并让每个 reviewer 读取则只需一份。
ReadBashbash
STATE_DIR="$PROJECT_ROOT/.llmtmp/review-diff"
mkdir -p "$STATE_DIR"
find "$STATE_DIR" -mindepth 1 -delete
INPUT="$STATE_DIR/input.md"
{
echo "# Change set vs merge-base ${BASE}, reviewed at commit ${COMMIT}"
echo; echo "## Commits"; git log --oneline "${BASE}"..HEAD
echo; echo "## Status"; git status --porcelain
echo; echo "## Diffstat"; git diff "${BASE}" "$COMMIT" --find-renames --stat
echo; echo "## Diff"; git diff "${BASE}" "$COMMIT" --find-renames
} > "$INPUT"
for f in $(git ls-files --others --exclude-standard); do
{ echo; echo "## Untracked file: $f"; cat -n "$f"; } >> "$INPUT"
done
wc -c "$INPUT"git diff "$BASE" "$COMMIT"git diff "$BASE"$COMMIT使用 后接 ,而不是 。某些 dotfiles 配置中 上的 shim 会将路径移至 Trash,并在路径不存在时即使使用 也会返回非零状态,从而导致首次运行时清理失败。
mkdir -pfind -deleterm -rfPATHsafe-rm-fStep 6: Build the Ledger
第 6 步:构建台账
bash
python3 "$S/ledger.py" "$STATE_DIR" --diff "$PROJECT_ROOT" "$BASE" "$COMMIT"
python3 "$S/partition.py" "$STATE_DIR"ledger.py --diffgit diff --name-only --no-renames --diff-filter=d$BASE$COMMIT$INPUTpartition.pyreport.pybash
python3 "$S/ledger.py" "$STATE_DIR" --diff "$PROJECT_ROOT" "$BASE" "$COMMIT"
python3 "$S/partition.py" "$STATE_DIR"ledger.py --diff$BASE$COMMITgit diff --name-only --no-renames --diff-filter=d$INPUTpartition.pyreport.pyStep 7: Dispatch 9 Reviewers in Parallel
第 7 步:并行派发 9 个 Reviewer
Issue all 9 Agent calls in a single tool block with .
run_in_background: falseSubagents default to running in the background. A backgrounded fan-out delivers its results in later turns, so Step 8 would find nothing to consolidate. Synchronous dispatch in one block is what makes the fleet parallel and the report possible in this turn.
| Agent type | Area |
|---|---|
| architecture |
| correctness |
| data |
| ops |
| performance |
| quality |
| security |
| solid |
| testing |
Dispatch all 9 every run. Do not skip a perspective based on which files changed.
Every prompt is identical apart from nothing. Send this, with and substituted:
<INPUT><PROJECT_ROOT>text
Read <INPUT>. It holds the commit log, porcelain status, diffstat, full diff
against the merge-base with main, and the full contents of every untracked
file. That is the complete change set under review.
The project root is <PROJECT_ROOT>. Every path in the diff is relative to it.
Open any file you need in that tree to confirm a finding and to confirm the
line number you cite.
Audit this change set. Apply the Ownership table in your instructions: report
only defect classes you own, and stay silent on the rest.
Write your findings to <STATE_DIR>/<LABEL>-<area>.md. Use an H2 header
followed by findings or exactly "No findings."The brief stays short on purpose. Severity, citation format, output shape, and lane discipline all live in the agent definitions, so one edit there changes every caller.
Do not pack repomix. The input file holds everything.
在单个 tool block 中发出全部 9 次 Agent 调用,并设置 。
run_in_background: falseSubagent 默认在后台运行。后台 fan-out 会在后续轮次才返回结果,因此第 8 步将找不到可汇总的内容。在一个 block 中同步派发,才能让这组任务并行执行,并在本轮生成报告。
| Agent type | 领域 |
|---|---|
| 架构 |
| 正确性 |
| 数据 |
| 运维 |
| 性能 |
| 质量 |
| 安全 |
| SOLID |
| 测试 |
每次运行都要派发全部 9 个。不要因为某些文件未发生变化而跳过任何维度。
所有提示词都完全相同,没有任何差异。发送以下提示词,其中 和 已替换:
<INPUT><PROJECT_ROOT>text
Read <INPUT>. It holds the commit log, porcelain status, diffstat, full diff
against the merge-base with main, and the full contents of every untracked
file. That is the complete change set under review.
The project root is <PROJECT_ROOT>. Every path in the diff is relative to it.
Open any file you need in that tree to confirm a finding and to confirm the
line number you cite.
Audit this change set. Apply the Ownership table in your instructions: report
only defect classes you own, and stay silent on the rest.
Write your findings to <STATE_DIR>/<LABEL>-<area>.md. Use an H2 header
followed by findings or exactly "No findings."提示词有意保持简短。严重程度、引用格式、输出结构和 lane 约束均定义在 agent definitions 中,因此只需修改一处即可影响所有调用方。
不要打包 repomix。输入文件包含全部内容。
Step 8: Check and Re-dispatch
第 8 步:检查并重新派发
bash
python3 "$S/check_reviews.py" "$RUN_DIR" "$LABEL"Prints one or line per area and exits 1 when any fails: the file is missing, has no H2, has no finding and is not exactly , or holds a bullet that parses as neither nor . Two causes are common here: the agent died on a transient API error and wrote nothing, or a hook blocked its read of and it wrote a refusal instead. Re-dispatch each failing area's agent once, using the same prompt as Step 7, then run again. A second failure is reported as not reviewed in Step 9, not retried further.
PASSFAILNo findings.normalize.FULLnormalize.BARE$INPUTcheck_reviews.pyEditing an agent definition does not affect a session already running. Claude Code detects agent files being added or removed, but a session keeps the body it loaded at startup, and a definition reached through a symlink (as dotbot installs them) is not re-read on edit. Restart the session after changing a reviewer.
bash
python3 "$S/check_reviews.py" "$RUN_DIR" "$LABEL"每个领域打印一行 或 ,任一失败即以 1 退出:文件缺失、没有 H2、没有 finding 且并非恰好为 ,或者包含无法解析为 或 的 bullet。常见原因有两个:agent 因临时 API 错误退出且没有写入任何内容;或者某个 hook 阻止其读取 ,导致它写入拒绝信息。使用与第 7 步相同的提示词,为每个失败领域重新派发一次 agent,然后再次运行 。第二次失败会在第 9 步中报告为未审查,不再继续重试。
PASSFAILNo findings.normalize.FULLnormalize.BARE$INPUTcheck_reviews.py编辑 agent definition 不会影响已在运行的 session。Claude Code 可以检测到 agent 文件的新增或删除,但 session 会保留启动时加载的正文,而通过 symlink 访问的 definition(例如 dotbot 的安装方式)在编辑后不会重新读取。修改 reviewer 后需重启 session。
Step 9: Run the Scripted Chain and Report
第 9 步:运行脚本链并生成报告
Run each model stage as a background Bash call; its pool returns when every call has finished, and the completion notification is the signal to continue. Never poll a running stage with . Run the stage command itself as the background call. Never detach it with or a trailing , and never wait on a log line with . exits only when it next writes, so the call hangs until its timeout once the log gets its last line.
sleepnohup&tail -f | grep -m1tailbash
python3 "$S/checkout.py" "$RUN_DIR"
python3 "$S/normalize.py" "$RUN_DIR"
python3 "$S/collate.py" "$RUN_DIR" # one model call per component, background
uv run --with scikit-learn --with scipy --with numpy python "$S/windows.py" "$RUN_DIR"
python3 "$S/merge.py" "$RUN_DIR" # one model call per similarity window, background
python3 "$S/rank.py" "$RUN_DIR"
python3 "$S/verify.py" "$RUN_DIR" # one model call per Critical or High issue, background
python3 "$S/report.py" "$RUN_DIR"A diff's scope is usually small enough to afford verifying Medium-severity issues too: pass to () to widen it past the Critical/High default.
--floor Mediumverify.pypython3 "$S/verify.py" "$RUN_DIR" --floor MediumReport the counts from , the confirmed issues, and to the operator. The run directory is valid input to the review-tickets skill, with ticket label .
report.mdRUN_DIRreview-diff将每个 model stage 作为后台 Bash 调用运行;其 pool 会在所有调用完成后返回,而完成通知才是继续执行的信号。绝不要用 轮询正在运行的 stage。应将 stage 命令本身作为后台调用运行。绝不要用 或末尾的 将其分离,也绝不要通过 等待某一行日志。 只有在下一次写入时才会退出,因此日志写完最后一行后,调用会一直挂起直到超时。
sleepnohup&tail -f | grep -m1tailbash
python3 "$S/checkout.py" "$RUN_DIR"
python3 "$S/normalize.py" "$RUN_DIR"
python3 "$S/collate.py" "$RUN_DIR" # one model call per component, background
uv run --with scikit-learn --with scipy --with numpy python "$S/windows.py" "$RUN_DIR"
python3 "$S/merge.py" "$RUN_DIR" # one model call per similarity window, background
python3 "$S/rank.py" "$RUN_DIR"
python3 "$S/verify.py" "$RUN_DIR" # one model call per Critical or High issue, background
python3 "$S/report.py" "$RUN_DIR"Diff 的范围通常足够小,因此也可以验证 Medium 严重程度的问题:向 传入 (),将验证范围扩展到 Critical/High 默认级别之外。
verify.py--floor Mediumpython3 "$S/verify.py" "$RUN_DIR" --floor Medium向操作者报告 中的计数、已确认的问题以及 。该 run directory 是 review-tickets skill 的有效输入,ticket label 为 。
report.mdRUN_DIRreview-diffTests
测试
See review-deep's Tests section. The same at the root of this plugin's repository covers every skill here, including for this skill's preflight tier.
evals/unit/preflight见 review-deep 的 Tests 部分。此插件仓库根目录下的同一套 覆盖这里的所有 skill,包括此 skill 的 preflight tier 对应的 。
evals/unit/preflight