pi-review — Code Review Workflow
A code-review skill for coding agents, ported from earendil-works/pi-review (the Pi /review + /end-review extension). It works in any agent that loads Agent Skills (SKILL.md): DSH, Claude Code, pi, and others. The review rubric, git recipes, and output contracts are unchanged from the original; the parts tied to Pi's TUI (interactive selector, session-tree branching, review widget) are replaced by conversation-driven behavior.
Invoke it with the host's skill gesture — /pi-review in DSH and Claude Code, /skill:pi-review in pi (e.g. /pi-review uncommitted, /pi-review branch main, /skill:pi-review pr 123) — or just describe the request in natural language ("review uncommitted", "评审一下未提交的改动"). The gesture resolves against the host's skill registry, so the command is built from this skill's own name. /review and /end-review were the commands of the original Pi extension: in this port they are accepted only as request phrasing — /review resolves to no skill (in Claude Code it is the built-in code-review alias), so it never injects this skill and must never be presented as its command.
1. Parse the request into a review target
Give the target as an argument to the skill gesture (/pi-review branch main, or /skill:pi-review branch main in pi) or as plain phrasing (review branch main); the two are equivalent.
| Request |
Target |
| "review uncommitted" |
uncommitted |
| "review branch <name>" |
base branch diff |
| "review commit <sha> [title...]" |
single commit (title is optional context) |
| "review pr <number | GitHub URL>" |
pull request |
| "review folder <paths...>" |
snapshot review (not a diff); paths are whitespace-separated |
--extra "..." or --extra=... (works with any mode) |
additional user-provided review instruction |
Target selection rules:
- An explicit target is used as-is, without confirmation.
- With no target given: default to uncommitted when the working tree has uncommitted changes (staged, unstaged, or untracked); otherwise ask the user which target to review, suggesting the diff against the default branch. (The original extension auto-selected "base branch" when on a feature branch and "commit" otherwise; asking first is the chat-appropriate equivalent — see the README's differences table.)
- If the current directory is not a git repository, say so and stop (the original guarded this with
git rev-parse --git-dir).
--extra with no value is an error — ask for the missing value.
2. Gather the changes (via shell commands)
- uncommitted:
git status --porcelain; inspect git diff HEAD for tracked changes and read untracked files directly.
- baseBranch: resolve the merge base first —
git rev-parse --abbrev-ref '<branch>@{upstream}', then git merge-base HEAD <upstream>; if that fails, fall back to git merge-base HEAD <branch>. Then inspect git diff <mergeBaseSha>.
- commit:
git show <sha> and review the full diff it introduces.
- pullRequest: requires
gh. Verify it is installed and authenticated (gh auth status); if not, give the setup hint (install from https://cli.github.com/ — macOS brew install gh — then gh auth login). Get base branch and title via gh pr view <n> --json baseRefName,title,headRefName, compute the merge base as in baseBranch mode, and inspect git diff <mergeBaseSha>. PR checkout requires a clean working tree (no changes to tracked files); if dirty, tell the user to commit or stash first. Note: the original always ran gh pr checkout <n>; this port checks out only when the PR head is not available locally, so it never moves the user's working tree unnecessarily (see the README's differences table).
- folder: no diff. Read the files under the given paths directly (snapshot review).
Focus text for each mode (verbatim from the original)
Use these exact strings as the mode-specific focus (see §4 for where they go), substituting the placeholders:
uncommitted
Review the current code changes (staged, unstaged, and untracked files) and provide prioritized findings.
baseBranch, merge base resolved
Review the code changes against the base branch '{baseBranch}'. The merge base commit for this comparison is {mergeBaseSha}. Run `git diff {mergeBaseSha}` to inspect the changes relative to {baseBranch}. Provide prioritized, actionable findings.
baseBranch, no merge base
Review the code changes against the base branch '{branch}'. Start by finding the merge diff between the current branch and {branch}'s upstream e.g. (`git merge-base HEAD "$(git rev-parse --abbrev-ref "{branch}@{upstream}")"`), then run `git diff` against that SHA to see what changes we would merge into the {branch} branch. Provide prioritized, actionable findings.
commit, with title
Review the code changes introduced by commit {sha} ("{title}"). Provide prioritized, actionable findings.
commit, no title
Review the code changes introduced by commit {sha}. Provide prioritized, actionable findings.
pullRequest, merge base resolved
Review pull request #{prNumber} ("{title}") against the base branch '{baseBranch}'. The merge base commit for this comparison is {mergeBaseSha}. Run `git diff {mergeBaseSha}` to inspect the changes that would be merged. Provide prioritized, actionable findings.
pullRequest, no merge base
Review pull request #{prNumber} ("{title}") against the base branch '{baseBranch}'. Start by finding the merge base between the current branch and {baseBranch} (e.g., `git merge-base HEAD {baseBranch}`), then run `git diff` against that SHA to see the changes that would be merged. Provide prioritized, actionable findings.
folder
Review the code in the following paths: {paths}. This is a snapshot review (not a diff). Read the files directly in these paths and provide prioritized, actionable findings.
3. Project review guidelines
Walk up from the current directory to find the project anchor: the first directory containing a .dsh directory, falling back to the first containing .git. Look for REVIEW_GUIDELINES.md in that anchor directory only, and stop the upward search there — if the anchor has no such file, there are no project instructions. (This mirrors the original, which anchored on the directory containing .pi and stopped there instead of continuing up into parent repositories.)
When found, append its contents as the project-instructions block described in §4; it overrides the default rubric where more specific.
4. Perform the review
Assemble the review input in exactly this order — the rubric's own precedence rule ("if you encounter more specific guidelines elsewhere … those override these general instructions") depends on the order and wording of these blocks:
- The review rubric below, verbatim.
- The line
Please perform a code review with the following focus: followed by the mode-specific focus text from §2.
- If recurring shared review instructions apply to all reviews, the line
Shared custom review instructions (applies to all reviews): followed by them. (The original stored these in session state via its selector; here the durable equivalent is REVIEW_GUIDELINES.md, while one-off additions arrive through --extra.)
- If the user passed
--extra, the line Additional user-provided review instruction: followed by that text.
- If a
REVIEW_GUIDELINES.md was found (§3), the line This project has additional instructions for code reviews: followed by its contents.
Act as the code reviewer defined by the rubric and emit the output format it requires (findings with [P0]–[P3], verdict "correct" or "needs attention", and the mandatory Human Reviewer Callouts section).
Review Guidelines
You are acting as a code reviewer for a proposed code change made by another engineer.
Below are default guidelines for determining what to flag. These are not the final word — if you encounter more specific guidelines elsewhere (in a developer message, user message, file, or project review guidelines appended below), those override these general instructions.
Determining what to flag
Flag issues that:
- Meaningfully impact the accuracy, performance, security, or maintainability of the code.
- Are discrete and actionable (not general issues or multiple combined issues).
- Don't demand rigor inconsistent with the rest of the codebase.
- Were introduced in the changes being reviewed (not pre-existing bugs).
- The author would likely fix if aware of them.
- Don't rely on unstated assumptions about the codebase or author's intent.
- Have provable impact on other parts of the code — it is not enough to speculate that a change may disrupt another part, you must identify the parts that are provably affected.
- Are clearly not intentional changes by the author.
- Be particularly careful with untrusted user input and follow the specific guidelines to review.
- Treat silent local error recovery (especially parsing/IO/network fallbacks) as high-signal review candidates unless there is explicit boundary-level justification.
- Violate the clean-code guidelines below.
- Introduce error handling that conflicts with the fail-fast guidelines below.
Clean-code guidelines
- Check whether each newly added function duplicates existing functionality elsewhere in the codebase. Flag actual duplication and identify the existing implementation.
- Flag one-off helper functions that add indirection without improving clarity or reuse (for example,
isRecord or asString).
- Flag abstractions introduced without a concrete need in the reviewed change, including wrappers created only for hypothetical future use.
- Flag defensive checks or fallback behavior that mask programming errors, especially when callers already guarantee the relevant invariants.
Untrusted User Input
- Be careful with open redirects, they must always be checked to only go to trusted domains (?next_page=...)
- Always flag SQL that is not parametrized
- In systems with user supplied URL input, http fetches always need to be protected against access to local resources (intercept DNS resolver!)
- Escape, don't sanitize if you have the option (eg: HTML escaping)
Comment guidelines
- Be clear about why the issue is a problem.
- Communicate severity appropriately - don't exaggerate.
- Be brief - at most 1 paragraph.
- Keep code snippets under 3 lines, wrapped in inline code or code blocks.
- Use ```suggestion blocks ONLY for concrete replacement code (minimal lines; no commentary inside the block). Preserve the exact leading whitespace of the replaced lines.
- Explicitly state scenarios/environments where the issue arises.
- Use a matter-of-fact tone - helpful AI assistant, not accusatory.
- Write for quick comprehension without close reading.
- Avoid excessive flattery or unhelpful phrases like "Great job...".
Review priorities
- Surface critical non-blocking human callouts (migrations, dependency churn, auth/permissions, compatibility, destructive operations) at the end.
- Prefer simple, direct solutions over wrappers or abstractions without clear value.
- Treat back pressure handling as critical to system stability.
- Apply system-level thinking; flag changes that increase operational risk or on-call wakeups.
- Ensure that errors are always checked against codes or stable identifiers, never error messages.
Fail-fast error handling (strict)
When reviewing added or modified error handling, default to fail-fast behavior.
- Evaluate every new or changed
try/catch: identify what can fail and why local handling is correct at that exact layer.
- Prefer propagation over local recovery. If the current scope cannot fully recover while preserving correctness, rethrow (optionally with context) instead of returning fallbacks.
- Flag catch blocks that hide failure signals (e.g. returning
null/[]/false, swallowing JSON parse failures, logging-and-continue, or “best effort” silent recovery).
- JSON parsing/decoding should fail loudly by default. Quiet fallback parsing is only acceptable with an explicit compatibility requirement and clear tested behavior.
- Boundary handlers (HTTP routes, CLI entrypoints, supervisors) may translate errors, but must not pretend success or silently degrade.
- If a catch exists only to satisfy lint/style without real handling, treat it as a bug.
- When uncertain, prefer crashing fast over silent degradation.
Required human callouts (non-blocking, at the very end)
After findings/verdict, you MUST append this final section:
Human Reviewer Callouts (Non-Blocking)
Include only applicable callouts (no yes/no lines):
- This change adds a database migration: <files/details>
- This change introduces a new dependency: <package(s)/details>
- This change changes a dependency (or the lockfile): <files/package(s)/details>
- This change modifies auth/permission behavior:
- This change introduces backwards-incompatible public schema/API/contract changes:
- This change includes irreversible or destructive operations:
- This change adds or removes feature flags: (call out re-use of dormant feature flags!)
- This change changes configuration defaults:
Rules for this section:
- These are informational callouts for the human reviewer, not fix items.
- Do not include them in Findings unless there is an independent defect.
- These callouts alone must not change the verdict.
- Only include callouts that apply to the reviewed change.
- Keep each emitted callout bold exactly as written.
- If none apply, write "- (none)".
Priority levels
Tag each finding with a priority level in the title:
- [P0] - Drop everything to fix. Blocking release/operations. Only for universal issues that do not depend on assumptions about inputs.
- [P1] - Urgent. Should be addressed in the next cycle.
- [P2] - Normal. To be fixed eventually.
- [P3] - Low. Nice to have.
Output format
Provide your findings in a clear, structured format:
- List each finding with its priority tag, file location, and explanation.
- Findings must reference locations that overlap with the actual diff — don't flag pre-existing code.
- Keep line references as short as possible (avoid ranges over 5-10 lines; pick the most suitable subrange).
- Provide an overall verdict: "correct" (no blocking issues) or "needs attention" (has blocking issues).
- Ignore trivial style issues unless they obscure meaning or violate documented standards.
- Do not generate a full PR fix — only flag issues and optionally provide short suggestion blocks.
- End with the required "Human Reviewer Callouts (Non-Blocking)" section and all applicable bold callouts (no yes/no).
Output all findings the author would fix if they knew about them. If there are no qualifying findings, explicitly state the code looks good. Don't stop at the first finding - list every qualifying issue. Then append the required non-blocking callouts section.
5. End-of-review handoff ("end-review" / 结束评审)
When the user finishes a review and asks for the handoff — the phrase "end-review" / "结束评审", or /pi-review end-review; this port has no separate command — produce the structured summary below so the findings can be acted on immediately. Do not omit findings — include every actionable issue identified during the review.
The interactive review is ending; produce the structured handoff below so it can be used immediately to implement fixes.
You MUST summarize the review that just happened so findings can be acted on.
Do not omit findings: include every actionable issue that was identified.
Required sections (in order):
Review Scope
- What was reviewed (files/paths, changes, and scope)
Verdict
- "correct" or "needs attention"
Findings
For EACH finding, include:
- Priority tag ([P0]..[P3]) and short title
- File location (
path/to/file.ext:line)
- Why it matters (brief)
- What should change (brief, actionable)
Fix Queue
- Ordered implementation checklist (highest priority first)
Constraints & Preferences
- Any constraints or preferences mentioned during review
- Or "(none)"
Human Reviewer Callouts (Non-Blocking)
Include only applicable callouts (no yes/no lines):
- This change adds a database migration: <files/details>
- This change introduces a new dependency: <package(s)/details>
- This change changes a dependency (or the lockfile): <files/package(s)/details>
- This change modifies auth/permission behavior:
- This change introduces backwards-incompatible public schema/API/contract changes:
- This change includes irreversible or destructive operations:
If none apply, write "- (none)".
These are informational callouts for humans and are not fix items by themselves.
Preserve exact file paths, function names, and error messages where available.
6. Fix the findings ("fix review findings" / 修复评审问题)
Use the latest review summary in this session and implement the review findings now.
Instructions:
- Treat the summary's Findings/Fix Queue as a checklist.
- Fix in priority order: P0, P1, then P2 (include P3 if quick and safe).
- If a finding is invalid/already fixed/not possible right now, briefly explain why and continue.
- Treat "Human Reviewer Callouts (Non-Blocking)" as informational only; do not convert them into fix tasks unless there is a separate explicit finding.
- Follow fail-fast error handling: do not add local catch/fallback recovery unless this scope is an explicit boundary that can safely translate the failure.
- If you add or keep a
try/catch, explain the expected failure mode and either rethrow with context or return a boundary-safe error response.
- JSON parsing/decoding should fail loudly by default; avoid silent fallback parsing.
- Run relevant tests/checks for touched code where practical.
- End with: fixed items, deferred/skipped items (with reasons), and verification results.
1---2name: pi-review3description: Structured code-review workflow ported from earendil-works/pi-review (Codex-style rubric). Use when the user wants a code review — review uncommitted changes, review against a base branch, review a specific commit, review a GitHub pull request, or snapshot-review folders/files. Also handles the post-review handoff ("end-review" summary) and "fix review findings". Triggers: /pi-review, /skill:pi-review, /review, review uncommitted, review branch main, review commit abc123, review pr 123, review folder src docs, 代码评审, 评审一下, 帮我 review, end-review, 修复评审问题.4---56# pi-review — Code Review Workflow78A code-review skill for coding agents, ported from [`earendil-works/pi-review`](https://github.com/earendil-works/pi-review) (the Pi `/review` + `/end-review` extension). It works in any agent that loads Agent Skills (`SKILL.md`): DSH, Claude Code, pi, and others. The review rubric, git recipes, and output contracts are unchanged from the original; the parts tied to Pi's TUI (interactive selector, session-tree branching, review widget) are replaced by conversation-driven behavior.910Invoke it with the host's skill gesture — `/pi-review` in DSH and Claude Code, `/skill:pi-review` in pi (e.g. `/pi-review uncommitted`, `/pi-review branch main`, `/skill:pi-review pr 123`) — or just describe the request in natural language ("review uncommitted", "评审一下未提交的改动"). The gesture resolves against the host's skill registry, so the command is built from this skill's own name. `/review` and `/end-review` were the commands of the *original Pi extension*: in this port they are accepted only as request phrasing — `/review` resolves to no skill (in Claude Code it is the built-in `code-review` alias), so it never injects this skill and must never be presented as its command.1112## 1. Parse the request into a review target1314Give the target as an argument to the skill gesture (`/pi-review branch main`, or `/skill:pi-review branch main` in pi) or as plain phrasing (`review branch main`); the two are equivalent.1516| Request | Target |17|---|---|18| "review uncommitted" | uncommitted |19| "review branch \<name\>" | base branch diff |20| "review commit \<sha\> [title...]" | single commit (title is optional context) |21| "review pr \<number \| GitHub URL\>" | pull request |22| "review folder \<paths...\>" | snapshot review (not a diff); paths are whitespace-separated |23| `--extra "..."` or `--extra=...` (works with any mode) | additional user-provided review instruction |2425Target selection rules:2627- An explicit target is used as-is, without confirmation.28- With no target given: default to **uncommitted** when the working tree has uncommitted changes (staged, unstaged, or untracked); otherwise ask the user which target to review, suggesting the diff against the default branch. (The original extension auto-selected "base branch" when on a feature branch and "commit" otherwise; asking first is the chat-appropriate equivalent — see the README's differences table.)29- If the current directory is not a git repository, say so and stop (the original guarded this with `git rev-parse --git-dir`).30- `--extra` with no value is an error — ask for the missing value.3132## 2. Gather the changes (via shell commands)3334- **uncommitted**: `git status --porcelain`; inspect `git diff HEAD` for tracked changes and read untracked files directly.35- **baseBranch**: resolve the merge base first — `git rev-parse --abbrev-ref '<branch>@{upstream}'`, then `git merge-base HEAD <upstream>`; if that fails, fall back to `git merge-base HEAD <branch>`. Then inspect `git diff <mergeBaseSha>`.36- **commit**: `git show <sha>` and review the full diff it introduces.37- **pullRequest**: requires `gh`. Verify it is installed and authenticated (`gh auth status`); if not, give the setup hint (install from https://cli.github.com/ — macOS `brew install gh` — then `gh auth login`). Get base branch and title via `gh pr view <n> --json baseRefName,title,headRefName`, compute the merge base as in baseBranch mode, and inspect `git diff <mergeBaseSha>`. PR checkout requires a clean working tree (no changes to tracked files); if dirty, tell the user to commit or stash first. Note: the original always ran `gh pr checkout <n>`; this port checks out only when the PR head is not available locally, so it never moves the user's working tree unnecessarily (see the README's differences table).38- **folder**: no diff. Read the files under the given paths directly (snapshot review).3940### Focus text for each mode (verbatim from the original)4142Use these exact strings as the mode-specific focus (see §4 for where they go), substituting the placeholders:4344- **uncommitted**4546 ```text47 Review the current code changes (staged, unstaged, and untracked files) and provide prioritized findings.48 ```4950- **baseBranch**, merge base resolved5152 ```text53 Review the code changes against the base branch '{baseBranch}'. The merge base commit for this comparison is {mergeBaseSha}. Run `git diff {mergeBaseSha}` to inspect the changes relative to {baseBranch}. Provide prioritized, actionable findings.54 ```5556- **baseBranch**, no merge base5758 ```text59 Review the code changes against the base branch '{branch}'. Start by finding the merge diff between the current branch and {branch}'s upstream e.g. (`git merge-base HEAD "$(git rev-parse --abbrev-ref "{branch}@{upstream}")"`), then run `git diff` against that SHA to see what changes we would merge into the {branch} branch. Provide prioritized, actionable findings.60 ```6162- **commit**, with title6364 ```text65 Review the code changes introduced by commit {sha} ("{title}"). Provide prioritized, actionable findings.66 ```6768- **commit**, no title6970 ```text71 Review the code changes introduced by commit {sha}. Provide prioritized, actionable findings.72 ```7374- **pullRequest**, merge base resolved7576 ```text77 Review pull request #{prNumber} ("{title}") against the base branch '{baseBranch}'. The merge base commit for this comparison is {mergeBaseSha}. Run `git diff {mergeBaseSha}` to inspect the changes that would be merged. Provide prioritized, actionable findings.78 ```7980- **pullRequest**, no merge base8182 ```text83 Review pull request #{prNumber} ("{title}") against the base branch '{baseBranch}'. Start by finding the merge base between the current branch and {baseBranch} (e.g., `git merge-base HEAD {baseBranch}`), then run `git diff` against that SHA to see the changes that would be merged. Provide prioritized, actionable findings.84 ```8586- **folder**8788 ```text89 Review the code in the following paths: {paths}. This is a snapshot review (not a diff). Read the files directly in these paths and provide prioritized, actionable findings.90 ```9192## 3. Project review guidelines9394Walk up from the current directory to find the project anchor: the first directory containing a `.dsh` directory, falling back to the first containing `.git`. Look for `REVIEW_GUIDELINES.md` in **that anchor directory only**, and stop the upward search there — if the anchor has no such file, there are no project instructions. (This mirrors the original, which anchored on the directory containing `.pi` and stopped there instead of continuing up into parent repositories.)9596When found, append its contents as the project-instructions block described in §4; it overrides the default rubric where more specific.9798## 4. Perform the review99100Assemble the review input in exactly this order — the rubric's own precedence rule ("if you encounter more specific guidelines elsewhere … those override these general instructions") depends on the order and wording of these blocks:1011021. The review rubric below, verbatim.1032. The line `Please perform a code review with the following focus:` followed by the mode-specific focus text from §2.1043. If recurring shared review instructions apply to all reviews, the line `Shared custom review instructions (applies to all reviews):` followed by them. (The original stored these in session state via its selector; here the durable equivalent is `REVIEW_GUIDELINES.md`, while one-off additions arrive through `--extra`.)1054. If the user passed `--extra`, the line `Additional user-provided review instruction:` followed by that text.1065. If a `REVIEW_GUIDELINES.md` was found (§3), the line `This project has additional instructions for code reviews:` followed by its contents.107108Act as the code reviewer defined by the rubric and emit the output format it requires (findings with [P0]–[P3], verdict "correct" or "needs attention", and the mandatory Human Reviewer Callouts section).109110# Review Guidelines111112You are acting as a code reviewer for a proposed code change made by another engineer.113114Below are default guidelines for determining what to flag. These are not the final word — if you encounter more specific guidelines elsewhere (in a developer message, user message, file, or project review guidelines appended below), those override these general instructions.115116## Determining what to flag117118Flag issues that:1191. Meaningfully impact the accuracy, performance, security, or maintainability of the code.1202. Are discrete and actionable (not general issues or multiple combined issues).1213. Don't demand rigor inconsistent with the rest of the codebase.1224. Were introduced in the changes being reviewed (not pre-existing bugs).1235. The author would likely fix if aware of them.1246. Don't rely on unstated assumptions about the codebase or author's intent.1257. Have provable impact on other parts of the code — it is not enough to speculate that a change may disrupt another part, you must identify the parts that are provably affected.1268. Are clearly not intentional changes by the author.1279. Be particularly careful with untrusted user input and follow the specific guidelines to review.12810. Treat silent local error recovery (especially parsing/IO/network fallbacks) as high-signal review candidates unless there is explicit boundary-level justification.12911. Violate the clean-code guidelines below.13012. Introduce error handling that conflicts with the fail-fast guidelines below.131132## Clean-code guidelines1331341. Check whether each newly added function duplicates existing functionality elsewhere in the codebase. Flag actual duplication and identify the existing implementation.1352. Flag one-off helper functions that add indirection without improving clarity or reuse (for example, `isRecord` or `asString`).1363. Flag abstractions introduced without a concrete need in the reviewed change, including wrappers created only for hypothetical future use.1374. Flag defensive checks or fallback behavior that mask programming errors, especially when callers already guarantee the relevant invariants.138139## Untrusted User Input1401411. Be careful with open redirects, they must always be checked to only go to trusted domains (?next_page=...)1422. Always flag SQL that is not parametrized1433. In systems with user supplied URL input, http fetches always need to be protected against access to local resources (intercept DNS resolver!)1444. Escape, don't sanitize if you have the option (eg: HTML escaping)145146## Comment guidelines1471481. Be clear about why the issue is a problem.1492. Communicate severity appropriately - don't exaggerate.1503. Be brief - at most 1 paragraph.1514. Keep code snippets under 3 lines, wrapped in inline code or code blocks.1525. Use ```suggestion blocks ONLY for concrete replacement code (minimal lines; no commentary inside the block). Preserve the exact leading whitespace of the replaced lines.1536. Explicitly state scenarios/environments where the issue arises.1547. Use a matter-of-fact tone - helpful AI assistant, not accusatory.1558. Write for quick comprehension without close reading.1569. Avoid excessive flattery or unhelpful phrases like "Great job...".157158## Review priorities1591601. Surface critical non-blocking human callouts (migrations, dependency churn, auth/permissions, compatibility, destructive operations) at the end.1612. Prefer simple, direct solutions over wrappers or abstractions without clear value.1623. Treat back pressure handling as critical to system stability.1634. Apply system-level thinking; flag changes that increase operational risk or on-call wakeups.1645. Ensure that errors are always checked against codes or stable identifiers, never error messages.165166## Fail-fast error handling (strict)167168When reviewing added or modified error handling, default to fail-fast behavior.1691701. Evaluate every new or changed `try/catch`: identify what can fail and why local handling is correct at that exact layer.1712. Prefer propagation over local recovery. If the current scope cannot fully recover while preserving correctness, rethrow (optionally with context) instead of returning fallbacks.1723. Flag catch blocks that hide failure signals (e.g. returning `null`/`[]`/`false`, swallowing JSON parse failures, logging-and-continue, or “best effort” silent recovery).1734. JSON parsing/decoding should fail loudly by default. Quiet fallback parsing is only acceptable with an explicit compatibility requirement and clear tested behavior.1745. Boundary handlers (HTTP routes, CLI entrypoints, supervisors) may translate errors, but must not pretend success or silently degrade.1756. If a catch exists only to satisfy lint/style without real handling, treat it as a bug.1767. When uncertain, prefer crashing fast over silent degradation.177178## Required human callouts (non-blocking, at the very end)179180After findings/verdict, you MUST append this final section:181182## Human Reviewer Callouts (Non-Blocking)183184Include only applicable callouts (no yes/no lines):185186- **This change adds a database migration:** <files/details>187- **This change introduces a new dependency:** <package(s)/details>188- **This change changes a dependency (or the lockfile):** <files/package(s)/details>189- **This change modifies auth/permission behavior:** <what changed and where>190- **This change introduces backwards-incompatible public schema/API/contract changes:** <what changed and where>191- **This change includes irreversible or destructive operations:** <operation and scope>192- **This change adds or removes feature flags:** <feature flags changed> (call out re-use of dormant feature flags!)193- **This change changes configuration defaults:** <config var changed>194195Rules for this section:1961. These are informational callouts for the human reviewer, not fix items.1972. Do not include them in Findings unless there is an independent defect.1983. These callouts alone must not change the verdict.1994. Only include callouts that apply to the reviewed change.2005. Keep each emitted callout bold exactly as written.2016. If none apply, write "- (none)".202203## Priority levels204205Tag each finding with a priority level in the title:206- [P0] - Drop everything to fix. Blocking release/operations. Only for universal issues that do not depend on assumptions about inputs.207- [P1] - Urgent. Should be addressed in the next cycle.208- [P2] - Normal. To be fixed eventually.209- [P3] - Low. Nice to have.210211## Output format212213Provide your findings in a clear, structured format:2141. List each finding with its priority tag, file location, and explanation.2152. Findings must reference locations that overlap with the actual diff — don't flag pre-existing code.2163. Keep line references as short as possible (avoid ranges over 5-10 lines; pick the most suitable subrange).2174. Provide an overall verdict: "correct" (no blocking issues) or "needs attention" (has blocking issues).2185. Ignore trivial style issues unless they obscure meaning or violate documented standards.2196. Do not generate a full PR fix — only flag issues and optionally provide short suggestion blocks.2207. End with the required "Human Reviewer Callouts (Non-Blocking)" section and all applicable bold callouts (no yes/no).221222Output all findings the author would fix if they knew about them. If there are no qualifying findings, explicitly state the code looks good. Don't stop at the first finding - list every qualifying issue. Then append the required non-blocking callouts section.223224## 5. End-of-review handoff ("end-review" / 结束评审)225226When the user finishes a review and asks for the handoff — the phrase "end-review" / "结束评审", or `/pi-review end-review`; this port has no separate command — produce the structured summary below so the findings can be acted on immediately. Do not omit findings — include every actionable issue identified during the review.227228The interactive review is ending; produce the structured handoff below so it can be used immediately to implement fixes.229230You MUST summarize the review that just happened so findings can be acted on.231Do not omit findings: include every actionable issue that was identified.232233Required sections (in order):234235## Review Scope236- What was reviewed (files/paths, changes, and scope)237238## Verdict239- "correct" or "needs attention"240241## Findings242For EACH finding, include:243- Priority tag ([P0]..[P3]) and short title244- File location (`path/to/file.ext:line`)245- Why it matters (brief)246- What should change (brief, actionable)247248## Fix Queue2491. Ordered implementation checklist (highest priority first)250251## Constraints & Preferences252- Any constraints or preferences mentioned during review253- Or "(none)"254255## Human Reviewer Callouts (Non-Blocking)256Include only applicable callouts (no yes/no lines):257- **This change adds a database migration:** <files/details>258- **This change introduces a new dependency:** <package(s)/details>259- **This change changes a dependency (or the lockfile):** <files/package(s)/details>260- **This change modifies auth/permission behavior:** <what changed and where>261- **This change introduces backwards-incompatible public schema/API/contract changes:** <what changed and where>262- **This change includes irreversible or destructive operations:** <operation and scope>263264If none apply, write "- (none)".265266These are informational callouts for humans and are not fix items by themselves.267268Preserve exact file paths, function names, and error messages where available.269270## 6. Fix the findings ("fix review findings" / 修复评审问题)271272Use the latest review summary in this session and implement the review findings now.273274Instructions:2751. Treat the summary's Findings/Fix Queue as a checklist.2762. Fix in priority order: P0, P1, then P2 (include P3 if quick and safe).2773. If a finding is invalid/already fixed/not possible right now, briefly explain why and continue.2784. Treat "Human Reviewer Callouts (Non-Blocking)" as informational only; do not convert them into fix tasks unless there is a separate explicit finding.2795. Follow fail-fast error handling: do not add local catch/fallback recovery unless this scope is an explicit boundary that can safely translate the failure.2806. If you add or keep a `try/catch`, explain the expected failure mode and either rethrow with context or return a boundary-safe error response.2817. JSON parsing/decoding should fail loudly by default; avoid silent fallback parsing.2828. Run relevant tests/checks for touched code where practical.2839. End with: fixed items, deferred/skipped items (with reasons), and verification results.