walkthrough-pr
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesewalkthrough-pr
walkthrough-pr
Produce one continuous, readable PR review the user can read top-to-bottom. Same shape as , plus a much heavier scrutiny pass. The user can have uncommitted changes in their main working tree — this skill never touches it.
walkthrough生成一份连贯易读的PR审查报告,方便用户从头到尾阅读。与的结构一致,但审查力度更强。用户的主工作树中可以存在未提交的更改——本技能绝不会触碰主工作树。
walkthroughResolve scope
确定范围
Arguments: . is required.
<pr-branch> [dest-branch]pr-branchResolve :
pr-branch- Try .
git rev-parse --verify <pr-branch> - If that fails, run once, then retry as
git fetchand<pr-branch>. Use whichever resolves.origin/<pr-branch> - If still unresolved, stop and ask the user.
Resolve :
dest-branch- If passed explicitly, use it (resolve same way as ).
pr-branch - Otherwise, run (yields
git symbolic-ref refs/remotes/origin/HEAD).refs/remotes/origin/<name> - If that fails (origin/HEAD not set), stop and ask the user. Do not guess /
main/master— better to ask than review against the wrong base.develop
Capture the PR head SHA via for use in output and verification.
git rev-parse <pr-branch>参数:。为必填项。
<pr-branch> [dest-branch]pr-branch解析:
pr-branch- 尝试执行。
git rev-parse --verify <pr-branch> - 如果执行失败,先运行,然后分别尝试解析
git fetch和<pr-branch>,使用解析成功的那个。origin/<pr-branch> - 如果仍无法解析,停止操作并询问用户。
解析:
dest-branch- 如果用户明确传入,使用该分支(解析方式与相同)。
pr-branch - 否则,执行(返回结果为
git symbolic-ref refs/remotes/origin/HEAD)。refs/remotes/origin/<name> - 如果执行失败(未设置origin/HEAD),停止操作并询问用户。请勿猜测/
main/master分支——与其审查错误的基准分支,不如询问用户。develop
通过获取PR头部的SHA值,用于输出和验证。
git rev-parse <pr-branch>Set up the worktree
设置工作树
The review reads files from a detached worktree at . The main working tree is never touched.
<repo-root>/.pr-review/<branch-slug>/<branch-slug>/\:*?"<>|-feature/login-fixfeature-login-fixbugfix/JIRA-123bugfix-JIRA-123origin/- First-run hygiene: ensure is in
.pr-review/. Read the file; if the line.git/info/excludeis missing, append it. (.pr-review/is per-repo and not committed, so this doesn't churn the team's.git/info/exclude.).gitignore - Clear the same-branch worktree if present: if already exists, run
<repo-root>/.pr-review/<branch-slug>/(check withgit worktree remove --force .pr-review/<branch-slug>first; ignore errors if absent). Other branches' worktrees are left untouched.git worktree list - Create the worktree: . Detached HEAD avoids "already checked out" errors when the PR branch happens to be checked out elsewhere.
git worktree add --detach .pr-review/<branch-slug> <pr-branch-ref>
The worktree stays alive after the skill finishes so clickable links in the review remain navigable. Re-running for the same branch overwrites it; different branches accumulate side-by-side under . The user can list them with and prune stale ones with .
/walkthrough-pr.pr-review/git worktree listgit worktree remove --force .pr-review/<branch-slug>审查将从位于的分离式工作树中读取文件。主工作树绝不会被触碰。
<repo-root>/.pr-review/<branch-slug>/<branch-slug>/\:*?"<>|-feature/login-fixfeature-login-fixbugfix/JIRA-123bugfix-JIRA-123origin/- 首次运行清理:确保已添加到
.pr-review/中。读取该文件;如果缺少.git/info/exclude这一行,则追加进去。(.pr-review/是仓库级别的配置,不会被提交,因此不会影响团队的.git/info/exclude文件。).gitignore - 清除已存在的同分支工作树:如果已存在,执行
<repo-root>/.pr-review/<branch-slug>/(先通过git worktree remove --force .pr-review/<branch-slug>检查;如果不存在则忽略错误)。其他分支的工作树将保持不变。git worktree list - 创建工作树:执行。分离头指针可以避免当PR分支已在其他地方被检出时出现的“已检出”错误。
git worktree add --detach .pr-review/<branch-slug> <pr-branch-ref>
本技能完成后,工作树会保持存在,以便审查报告中的可点击链接仍能正常访问。针对同一分支重新运行会覆盖原有工作树;不同分支的工作树会在下并存。用户可以通过查看所有工作树,通过清理过期的工作树。
/walkthrough-pr.pr-review/git worktree listgit worktree remove --force .pr-review/<branch-slug>Gather
收集信息
All git commands run from the main repo (refs work without entering the worktree):
- — file list and line counts.
git diff --stat <dest-branch>...<pr-branch> - — full diff. Three-dot range — compares PR head against the merge-base with dest, i.e. only what this PR introduces. Don't use two-dot.
git diff <dest-branch>...<pr-branch> - — PR commit messages (two-dot here for the linear commit list). Author intent is a strong signal even when the code is opaque.
git log <dest-branch>..<pr-branch> --format='%s%n%n%b'
When you need surrounding context that isn't in the diff (e.g. to see how a touched function is called elsewhere), files via absolute paths under . Don't from the main tree — that's the user's working state, not the PR's.
Read<repo-root>/.pr-review/<branch-slug>/...Read所有git命令都在主仓库中执行(无需进入工作树即可操作引用):
- —— 文件列表和行数统计。
git diff --stat <dest-branch>...<pr-branch> - —— 完整差异。使用三点范围——对比PR头部与目标分支的合并基准,即仅显示该PR引入的更改。请勿使用两点范围。
git diff <dest-branch>...<pr-branch> - —— PR的提交信息(此处使用两点范围获取线性提交列表)。即使代码难以理解,作者的意图也是重要的参考信号。
git log <dest-branch>..<pr-branch> --format='%s%n%n%b'
当需要差异中未包含的上下文信息时(例如查看被修改的函数在其他地方的调用方式),通过下的绝对路径文件。请勿从主工作树文件——主工作树是用户的当前工作状态,而非PR的状态。
<repo-root>/.pr-review/<branch-slug>/...ReadReadDecide reading order
确定阅读顺序
Same heuristic as walkthrough — bottom-up by dependency:
- Schema / migrations / types / data models
- Pure utilities and shared helpers
- Core business logic (services, domain modules)
- Glue / handlers / controllers / API routes
- UI / views / templates / styles
- Tests
- Config, fixtures, docs, snapshots, lockfiles
Deviate when one file is clearly the entry point of the change — lead with it and treat the rest as supporting context. State the chosen order and reason up front.
采用与walkthrough相同的启发式规则——按依赖关系自底向上:
- Schema / 迁移文件 / 类型定义 / 数据模型
- 纯工具函数和共享助手
- 核心业务逻辑(服务、领域模块)
- 粘合层 / 处理器 / 控制器 / API路由
- UI / 视图 / 模板 / 样式
- 测试代码
- 配置、测试数据、文档、快照、锁文件
当某个文件明显是更改的入口点时,可以调整顺序——先讲解该文件,其余文件作为支撑上下文。在报告开头说明选定的顺序及原因。
Linking to lines
代码行链接
Whenever you call out specific code, link to it with a line-anchored markdown link pointing into the worktree, not the main repo. Clicking opens the actual PR-state file.
Format:
- Single line: or
[validateInput](.pr-review/<branch-slug>/src/foo.ts#L42)[src/foo.ts:42](.pr-review/<branch-slug>/src/foo.ts#L42) - Range:
[the new error branch](.pr-review/<branch-slug>/src/foo.ts#L42-L58)
Pick line numbers from the post-change side of the diff — the in each hunk header, then count down. Those numbers match the file at the PR head, which is what the worktree contains.
+A@@ -X,Y +A,B @@For deletions, there's no "after" line to link — describe the removal in prose and link surrounding context. Don't fabricate anchors.
Use prose link text ("the new error branch", "") rather than raw whenever it reads better.
validateInputpath:42每当提及特定代码时,使用锚定到行号的markdown链接指向工作树中的文件,而非主仓库。点击链接将打开PR状态下的实际文件。
格式:
- 单行:或
[validateInput](.pr-review/<branch-slug>/src/foo.ts#L42)[src/foo.ts:42](.pr-review/<branch-slug>/src/foo.ts#L42) - 多行范围:
[新的错误分支](.pr-review/<branch-slug>/src/foo.ts#L42-L58)
行号从差异的变更后部分获取——即每个块头中的,然后向下计数。这些行号与PR头部的文件一致,也就是工作树中文件的行号。
@@ -X,Y +A,B @@+A对于删除的代码,没有“变更后”的行号可链接——用文字描述删除内容,并链接周围的上下文。请勿伪造锚点。
尽可能使用描述性的链接文本(如“新的错误分支”、“”),而非原始的格式,以提升可读性。
validateInputpath:42Write the review
撰写审查报告
Compose the review as one continuous markdown document, then save and display it:
- Save the full content to using the
<repo-root>/.pr-review/<branch-slug>/WALKTHROUGH.mdtool. This is the shareable artifact — the user can copy/paste the file into a Bitbucket comment, Slack, etc.Write - Display the exact same content inline in chat — no pagination, no "say next to continue". The chat output and the file content must be identical (single source of truth).
State up front in the document: "Links open files in , which holds the PR branch state. The worktree is overwritten on the next run for this same branch." Substitute the real branch slug in the actual output — readers should see a concrete path.
.pr-review/<branch-slug>//walkthrough-pr将审查报告撰写为一份连贯的markdown文档,然后保存并展示:
- 保存:使用工具将完整内容保存到
Write。这是可共享的成果——用户可以将该文件复制粘贴到Bitbucket评论、Slack等平台。<repo-root>/.pr-review/<branch-slug>/WALKTHROUGH.md - 展示:在聊天中直接显示完整内容——无需分页,无需提示“继续查看下一部分”。聊天输出与文件内容必须完全一致(单一数据源)。
在文档开头说明:“链接将打开中的文件,该目录保存着PR分支的状态。针对同一分支再次运行时,该工作树会被覆盖。” 在实际输出中替换为真实的分支slug——读者应看到具体的路径。
.pr-review/<branch-slug>//walkthrough-pr1. Overview (2–3 sentences)
1. 概述(2-3句话)
What this PR does and why, inferred from the code, commit messages, and any new tests. Mention the PR branch, the dest branch, the head SHA, and rough size (e.g. "9 files, ~240 lines added across X, Y, Z, against (PR head )").
mainabc1234说明该PR的功能和目的,从代码、提交信息和新增测试中推断而来。提及PR分支、目标分支、头部SHA值和大致规模(例如:“9个文件,在X、Y、Z模块中新增约240行代码,基准分支为(PR头部SHA为)”)。
mainabc12342. Reading order
2. 阅读顺序
Short numbered list naming the files in the order you'll cover them, with a brief reason for the grouping.
简短的编号列表,列出将要讲解的文件顺序,并简要说明分组原因。
3. File-by-file
3. 逐文件讲解
One section per file (or per group, for trivial files). Each section:
- Heading: clickable worktree path, e.g. , plus a one-line role ("new domain entity for X", "wires the new entity into the API layer", etc.). Keep the heading link file-level — line-anchored links go inline in the body.
[.pr-review/<branch-slug>/src/foo.ts](.pr-review/<branch-slug>/src/foo.ts) - What changed — a summary, not a re-paste of the diff.
- Why — inferred intent; flag uncertainty.
- Scrutinize — anything non-obvious, risky, or worth a second look. Omit when there's nothing to flag.
每个文件(或一组无关紧要的文件)对应一个章节:
- 标题:可点击的工作树路径,例如,加上一行描述(如“X的新领域实体”、“将新实体接入API层”等)。标题链接为文件级——行锚定链接放在正文内。
[.pr-review/<branch-slug>/src/foo.ts](.pr-review/<branch-slug>/src/foo.ts) - 变更内容——摘要,而非复制粘贴差异。
- 变更意图——推断的目的;如有不确定需标注。
- 审查意见——任何不明显、有风险或值得再次检查的内容。如果没有需要标注的内容则省略。
4. Things to scrutinize (heavy pass)
4. 重点审查项(严格检查)
A final section with cross-file concerns. Walk through each category below explicitly — even briefly stating "nothing here" — so nothing gets quietly skipped:
- Logic bugs & off-by-ones — boundary conditions, inverted comparisons, wrong loop variables.
- Tests — missing coverage for new branches; tests that assert nothing meaningful (e.g. only checking that something didn't throw); deleted tests; snapshot churn that hides logic changes.
- Error handling — swallowed exceptions, generic catches, missing fallbacks at boundaries (network, FS, deserialization), error states that silently succeed.
- Edge cases — empty inputs, nulls/undefined, zero-length collections, concurrency / race conditions, retry behavior, idempotency.
- Security — secrets in code or config, injection (SQL/shell/HTML), auth bypass, missing authz checks, unsafe deserialization, SSRF, prompt injection in LLM contexts.
- Scope creep — drive-by changes unrelated to the PR's stated intent; refactors mixed with feature work; formatting churn obscuring real changes.
- Accidental reverts — code that re-introduces something previously removed; stale code paths revived.
- Dependency changes — new packages, version bumps (especially major), unexpected lockfile churn, transitive risk.
- API / contract breaks — renamed/removed exports, changed function signatures, response shape changes — and whether call sites elsewhere in the repo were updated.
- Performance — N+1 queries, unbounded loops, sync I/O on hot paths, unneeded re-renders, large allocations in tight loops.
- Hallucinated APIs — calls to functions/methods that don't exist on the imported module (especially common in AI-generated PRs). Verify by ing the imported module from the worktree when in doubt.
Read - Leftovers — TODOs, debug logging, , commented-out code, dead branches.
console.log
If a category genuinely has nothing, say so in one phrase ("Tests: comprehensive, asserts the new branch."). If everything is clean, end with one sentence saying so.
最后一个章节涵盖跨文件的问题。需明确检查以下每个类别——即使简要说明“无问题”也可,避免遗漏任何项:
- 逻辑bug与边界错误——边界条件、反向比较、错误的循环变量。
- 测试代码——新增分支缺少测试覆盖;无实际意义的测试断言(如仅检查未抛出异常);被删除的测试;快照变更掩盖逻辑修改。
- 错误处理——被吞掉的异常、通用捕获语句、边界处缺少回退机制(网络、文件系统、反序列化)、静默成功的错误状态。
- 边缘情况——空输入、null/undefined、零长度集合、并发/竞态条件、重试行为、幂等性。
- 安全性——代码或配置中的密钥、注入攻击(SQL/Shell/HTML)、认证绕过、缺少授权检查、不安全的反序列化、SSRF、LLM场景中的提示注入。
- 范围蔓延——与PR既定意图无关的顺带修改;重构与功能开发混合;格式变更掩盖真实修改。
- 意外回滚——重新引入之前已移除的代码;激活陈旧的代码路径。
- 依赖变更——新增包、版本升级(尤其是大版本)、意外的锁文件变更、传递性风险。
- API/契约破坏——重命名/移除导出、函数签名变更、响应结构变更——以及仓库中其他调用位置是否已更新。
- 性能问题——N+1查询、无界循环、热点路径上的同步I/O、不必要的重渲染、循环中的大内存分配。
- 虚构API——调用导入模块中不存在的函数/方法(在AI生成的PR中尤为常见)。如有疑问,通过工作树导入模块进行验证。
Read - 遗留内容——TODO注释、调试日志、、被注释的代码、死分支。
console.log
如果某个类别确实无问题,用一句话说明(如“测试:覆盖全面,对新增分支进行了断言。”)。如果所有项都无问题,用一句话总结。
Length and tone
篇幅与语气
- One paragraph per file for typical changes. Expand to several for non-trivial logic. Collapse trivial files (lockfiles, snapshots, mass renames, generated code) into a single grouped paragraph.
- The user already has the diff — don't paste large hunks back. Quote specific lines only when calling something out, and prefer a line-anchored link over a quoted block when the link alone is enough.
- Plain prose with markdown structure.
- 对于典型变更,每个文件用一段文字说明。对于复杂逻辑,可扩展为多段。将无关紧要的文件(锁文件、快照、批量重命名、生成代码)合并为一段说明。
- 用户已拥有差异内容——请勿粘贴大段差异。仅在需要标注时引用特定代码行,且当链接足够清晰时,优先使用行锚定链接而非引用块。
- 使用简洁的 prose 配合markdown结构。
Footer
页脚
End the review with a one-line cleanup hint:
Worktree at(PR head.pr-review/<branch-slug>/). Saved review:<sha>— share this file as-is. To remove the worktree now:.pr-review/<branch-slug>/WALKTHROUGH.md. Other branches' worktrees undergit worktree remove --force .pr-review/<branch-slug>are untouched — list them with.pr-review/.git worktree list
Substitute the real branch slug and SHA in the actual output.
在审查报告末尾添加一行清理提示:
工作树位于(PR头部SHA为.pr-review/<branch-slug>/)。已保存的审查报告:<sha>——可直接共享该文件。如需立即移除工作树:执行.pr-review/<branch-slug>/WALKTHROUGH.md。git worktree remove --force .pr-review/<branch-slug>下其他分支的工作树不受影响——可通过.pr-review/查看。git worktree list
在实际输出中替换为真实的分支slug和SHA值。