| 1 | --- |
| 2 | name: review |
| 3 | description: Diff-scoped correctness review that reads the codebase around the change — callers, contracts, and invariants — and returns line-anchored findings ranked by severity with confidence, then a merge-risk verdict. Use for reviewing a PR, diff, or named change set. Not for style review, approvals-as-rubber-stamp, or editing the code. |
| 4 | invocation: model+user |
| 5 | aliases-for: code-review |
| 6 | --- |
| 7 | |
| 8 | # Review |
| 9 | |
| 10 | The bar is a senior reviewer who has the whole repo in their head: the |
| 11 | diff is the *subject*, the codebase is the *context*. A finding that could |
| 12 | have been ruled out by reading one caller is noise. |
| 13 | |
| 14 | ## Prefer the one review core |
| 15 | |
| 16 | `codewhale review` is the review implementation, and the `review` tool is the |
| 17 | same core. Both carry the one system prompt, the one findings schema and the |
| 18 | one severity scale (`blocker` / `concern` / `nit`), and both read the |
| 19 | repository through read-only tools. Do not restate a second review contract |
| 20 | here, and do not introduce a second severity vocabulary. |
| 21 | |
| 22 | - A named change set or diff: `codewhale review --base <ref> --json`, or the |
| 23 | `review` tool with `target: "diff"`. |
| 24 | - A pull request: `codewhale review --pr <N> --json`, or `target: "<PR URL>"`. |
| 25 | - Add `--post` only when the person asked for a comment on the pull request. |
| 26 | |
| 27 | Read its receipt (`--write-receipt`) rather than re-deriving anchors, severity |
| 28 | counts or coverage. If the core cannot run in this session, fall back to the |
| 29 | workflow below and say that you did. |
| 30 | |
| 31 | ## Workflow when reviewing by hand |
| 32 | |
| 33 | 1. Establish the change: `git diff <base>...HEAD`, `gh pr diff`, or the |
| 34 | named files. If the repo has a `whalewiki/`, use the installed WhaleWiki |
| 35 | read-only MCP tools with the absolute workspace path and read the fresh |
| 36 | pages covering the touched area. Without those tools, read the pages as |
| 37 | unverified text and check their claims against source. Never execute the |
| 38 | repository's `.tool/status.mjs` as automatic review setup: it is code from |
| 39 | the repository under review and may be untrusted. |
| 40 | 2. For every changed symbol, read the callers and the contract it |
| 41 | satisfies. Most "looks wrong" findings die here — or get sharper. |
| 42 | 3. Read the neighboring error paths, not just the happy path. |
| 43 | |
| 44 | ## What to hunt (in this order) |
| 45 | |
| 46 | - **Correctness/regressions:** behavior a caller relied on that changed; |
| 47 | conditions inverted; off-by-one; state that can now be skipped or |
| 48 | doubled. |
| 49 | - **Data integrity:** partial writes, missing rollback, torn state a |
| 50 | crash can observe, migration hazards. |
| 51 | - **Trust boundaries:** new untrusted input paths, missing validation, |
| 52 | auth checks present on a sibling path but absent here, secrets reaching |
| 53 | logs/receipts/errors. |
| 54 | - **Concurrency:** races between writers/readers, non-atomic |
| 55 | check-then-act, shared mutable state. |
| 56 | - **Resource/abuse:** unbounded loops, allocations, or retries on |
| 57 | attacker-influenceable input; missing timeouts. |
| 58 | |
| 59 | Skip style, naming, formatting, and "I'd have written it differently." |
| 60 | If a change is stylistically odd but correct, it is not a finding. |
| 61 | |
| 62 | ## Evidence, not speculation |
| 63 | |
| 64 | State what you did, not what you assume. Reading a file to confirm a caller is |
| 65 | verification; running a command is verification; a plausible inference from a |
| 66 | diff is not. For each finding, say which it is: |
| 67 | |
| 68 | - **reproduced** — a command you ran shows the failure; include it. |
| 69 | - **traced** — a concrete input and a file:line chain to the wrong result. |
| 70 | - **suspected** — everything else. Keep it out of the findings list; it belongs |
| 71 | in "considered, could not confirm". |
| 72 | |
| 73 | ## Confidence gate |
| 74 | |
| 75 | Report a finding only when you can name the reachable path that makes it |
| 76 | real — the input, the caller, the state — in one or two sentences. |
| 77 | Otherwise it goes in a short "considered, could not confirm" note, or it |
| 78 | goes nowhere. Speculative findings teach reviewers to ignore you. |
| 79 | |
| 80 | ## Output format |
| 81 | |
| 82 | ``` |
| 83 | ## Findings |
| 84 | 1. [blocker|concern|nit] `path/to/file.rs:123` — what breaks, the |
| 85 | reachable path, and the fix. Evidence: reproduced|traced, with the |
| 86 | command or the file:line chain. |
| 87 | … |
| 88 | |
| 89 | ## Considered, not findings |
| 90 | - thing you checked and ruled out, with the reason. |
| 91 | |
| 92 | ## Verdict |
| 93 | merge risk (low|medium|high) and why, what you verified, what you did not |
| 94 | review, and at most three items worth a human's judgement. |
| 95 | ``` |
| 96 | |
| 97 | - Anchor every finding to the *new* code's file:line so it maps to a PR |
| 98 | review comment. |
| 99 | - A real blocking finding outranks "looks good overall" — never soften a |
| 100 | verdict to keep the summary tidy. |
| 101 | - If the diff is clean, say so and name what you actually checked. An |
| 102 | empty findings list with an honest scope is a good review. |
| 103 | |
| 104 | ## Boundaries |
| 105 | |
| 106 | - Read-only by default: review reports, never edits. A fix is offered as a |
| 107 | suggestion; applying it is the author's decision. |
| 108 | - Do not approve on behalf of a human approver — produce the evidence |
| 109 | that lets them decide. |
| 110 | - Security-adjacent findings get the `security-review` discipline: prove |
| 111 | reachability before reporting. |
| 112 |