diff --git a/skills/code-change-review/SKILL.md b/skills/code-change-review/SKILL.md index cb91403..16f8db8 100644 --- a/skills/code-change-review/SKILL.md +++ b/skills/code-change-review/SKILL.md @@ -5,7 +5,7 @@ description: Review a code change (local diff, staged changes, branch, commit ra # Code Change Review -Review a change the way a strong senior engineer would: find the defects that matter, prove each one, and report them so the author can act quickly. A short review with three real bugs beats a long one with thirty maybes, because every false positive teaches the reader to skim. +Review a change the way a strong senior engineer would: find the defects that matter, prove each one, and report them so the author can act quickly. A short review with three real bugs beats a long one with thirty maybes, because every false positive teaches the reader to skim. That is a bar on evidence, not on effort: find every defect the change introduces, depends on or makes worse in one review, then report only the ones the evidence supports: Confirmed findings, and Plausible ones that name the deciding fact you could not reach (step 5 has the grades, and `references/verification.md` the stricter rule for unattended posting). A second review of unchanged code should not turn up anything the first one could have found. ## Workflow @@ -124,9 +124,11 @@ Work from the top of this list down. A bug in tier 1 matters more than any numbe Apply the loaded language file's checks within these angles. They are the specific forms these problems take in that language. +**Exhaust the change before reporting.** Don't stop at the first serious findings. After working through the angles, sweep every hunk you fully reviewed again and ask what is still wrong that you have not raised; repeat until a sweep adds nothing. Where step 1's triage limited coverage, record the skimmed and unreviewed files in the coverage note rather than claiming a full sweep. In Quick mode, one sweep is enough. Ranking decides the order findings are reported in, not whether lower-ranked ones are looked for. An issue the author first hears about after fixing the earlier ones costs a whole extra review round. + ### 5. Verify every finding before reporting it -Choose review depth by user request: **Standard** by default (independently verify serious or uncertain findings when subagents exist); **Quick** for requested fast reviews (self-check only); **Deep** for thorough or unattended reviews (independently verify every reported finding when subagents exist). Never silently downgrade an unattended review. Limit simultaneous verification agents to four unless the user authorizes a higher budget. Log how many candidates were checked, refuted and dropped, and any limitations. See `references/verification.md` for the detailed rules and fallback. +Choose review depth by user request: **Standard** by default (independently verify serious or uncertain findings when subagents exist); **Quick** for requested fast reviews (self-check only); **Deep** for thorough or unattended reviews (independently verify every reported finding when subagents exist). Never silently downgrade an unattended review. Limit simultaneous verification agents to four unless the user authorizes a higher concurrency limit. Reviews that post findings without a human in the loop also have a per-review verifier-run budget for `[P3]`–`[P5]` candidates: past it, those get the self-check instead, while every `[P1]`/`[P2]` still gets a fresh verifier (`references/verification.md`, "Posting without a human in the loop"). Log how many candidates were checked, refuted and dropped, and any limitations. See `references/verification.md` for the detailed rules and fallback. Most false positives rest on one fact the reviewer assumed instead of checking. **Read `references/verification.md` before reporting**: it has the full procedure and a table of false-positive patterns with the check that catches each. For each candidate finding: @@ -134,7 +136,7 @@ Most false positives rest on one fact the reviewer assumed instead of checking. - **List its load-bearing facts** (what a type is, what a callee does, who calls it with what, that something is absent, what the language or spec says) and **settle each one by reading or running something you can cite**. A name, an idiom or "the likely design" settles nothing. Before claiming something is missing or unused, search the whole repository. - **Argue against it.** Look for the guard, counterpart, caller, test, spec section or decision record that would make it wrong. Evidence against the finding (tests pass, it works in production) counts against it; don't explain it away. - **Grade confidence:** *Confirmed* (every load-bearing fact settled) or *Plausible* (the deciding fact is out of reach, such as production config or another service). If you could check the deciding fact with the tools you have, check it: it is not Plausible. Drop anything else, or ask it as a question that names the unsettled fact. -- **Independently disprove findings at the selected depth.** In Standard mode, verify every `[P1]`/`[P2]` and any uncertain finding with a fresh agent when available; Deep mode verifies every reported finding; Quick mode uses a separate self-check. Never fork the reviewing agent's context into a verifier or reuse a verifier for multiple claims. Provide only the claim, location and change locator, not your supporting scenario. Use a concurrency limit and do not run untrusted code outside an authorized sandbox. `references/verification.md` has the brief and verdict handling. +- **Independently disprove findings at the selected depth.** In Standard mode, verify every `[P1]`/`[P2]` and any uncertain finding with a fresh agent when available; Deep mode verifies every reported finding, apart from that posting budget above; Quick mode uses a separate self-check. Never fork the reviewing agent's context into a verifier or reuse a verifier for multiple claims. Provide only the claim, location and change locator, not your supporting scenario. Use a concurrency limit and do not run untrusted code outside an authorized sandbox. `references/verification.md` has the brief and verdict handling. ### 6. Report @@ -142,9 +144,10 @@ Use `references/reporting.md` for the severity tags, the comment format and the - Lead with a one-line verdict: whether it is safe to merge, and the biggest issue if any. - **Every finding starts with its severity label: `[P1] CRITICAL`, `[P2] MAJOR`, `[P3] MINOR (Defect)`, `[P4] MINOR (Quality)` or `[P5] NIT`**, where the `[Pn]` rank comes first and `[P1]` is the most severe, then a one-line claim and its `file:line`. The body explains, in this order, what the issue is, why it is a problem (the concrete failure scenario), and a suggested fix or improvement wherever you can offer one. -- List findings with the most severe first. Default cap of about 10. Mention how many lower-severity items you left out, and list them if the user asks. -- Keep `[P5] NIT` findings out unless there are no real defects, or the user asked for a thorough pass. -- Say how the findings were verified: review mode, number sent to fresh verifiers, refutations, and any lack of independent verification. +- List findings with the most severe first. In a report a person reads, show every `[P1]`/`[P2]` in full, since they block the merge, then fill the report from `[P3]`/`[P4]` up to about 10 full findings in total, counting the `[P1]`/`[P2]`. Put the remaining `[P3]`/`[P4]` findings under **Also noted**, one line each; `[P5] NIT` follows the next bullet. +- In that report, count `[P5] NIT` findings instead of listing them unless there are no real defects or the user asked for a thorough pass; list them if the user asks. +- **When a host sets the output** (a review bot, CI job or structured findings tool with its own format, severity threshold or comment limit), those two display limits do not apply. Return every finding that meets the evidence bar (for a host that posts without a human in the loop, the stricter bar in `references/verification.md`), down to the host's severity threshold, most severe first, and let the host apply any comment limit. Where the host leaves something unset, don't ask (an unattended host has no one to answer): with no severity threshold, report down to `[P5] NIT` and let the host filter (when you post unattended yourself with no host in between, `references/verification.md` stops at `[P4]` instead); with no format, use `references/reporting.md`. A finding you hold back is lost, and surfaces as "new" in the next review after the author fixes the rest. +- Say how the findings were verified: review mode, number sent to fresh verifiers, refutations, how many were self-checked only past the verifier-run budget, and any lack of independent verification. - End with explicit coverage (files fully reviewed / skimmed / unavailable), checks run safely, and what you did *not* cover. An honest scope note is part of the review. Use the same label-first format for comments posted on a pull request, so a finding reads the same in the report and on the PR. Post to the PR only when the user asks, or when an explicitly authorized review bot is configured to post; `references/reporting.md` shows how to post them as one review with inline comments and recheck the pinned revision. When findings are posted with no human reviewing them first (a review bot or CI job), apply the stricter bar in `references/verification.md`. diff --git a/skills/code-change-review/references/reporting.md b/skills/code-change-review/references/reporting.md index 20a7f89..355e2e5 100644 --- a/skills/code-change-review/references/reporting.md +++ b/skills/code-change-review/references/reporting.md @@ -12,7 +12,7 @@ Severity is a priority rank from `[P1]` (most severe) to `[P5]` (least severe), | `[P2] MAJOR` | Wrong behaviour that users or operators will hit, or a serious risk under realistic conditions. Fix before merging. | Race causing duplicate charges, unhandled error on a common path, breaking API change, N+1 on a hot endpoint | | `[P3] MINOR (Defect)` | Wrong behaviour in edge cases or uncommon conditions, with limited impact. Fix in this change; need not block the merge. | Missing timeout, edge-case off-by-one, error swallowed on a rare path | | `[P4] MINOR (Quality)` | No wrong behaviour today, but a real maintainability or operability cost, or a clear improvement with small impact. Fix when convenient. | Missing test for new logic that works, wrong-altitude fix, misleading log message, small duplication, avoidable complexity | -| `[P5] NIT` | Style or taste; no behavioural effect. Omit unless there are no real defects, or the user asked for a thorough pass. | Formatting the linter missed, naming, wording | +| `[P5] NIT` | Style or taste; no behavioural effect. In a report a person reads, count rather than list them unless there are no real defects or the user asked for a thorough pass. When a host sets the output, report them if its severity threshold reaches `[P5]` or it sets none. When you post to a pull request yourself, unattended and with no threshold configured, leave them out (`references/verification.md`). | Formatting the linter missed, naming, wording | `[P1]` and `[P2]` block the merge; `[P3]` to `[P5]` do not. @@ -53,6 +53,7 @@ Use this for every finding, in reports and on PRs alike: - **Suggest a fix whenever you can.** Keep it minimal and in the codebase's style. If several fixes are reasonable, give the one you'd pick and name the trade-off in a sentence. If you can't propose one, replace the fix section with **Next step:** saying what to check or decide, or ask a question. - **One defect per comment.** If the same bug appears in five places, make one finding that lists the locations (on a PR, comment on the first and list the rest). - **Pre-existing problems** add `(pre-existing)` after the full label, for example `[P3] MINOR (Defect) (pre-existing) …`, and only appear if the change depends on them or makes them worse. +- **Self-checked findings** posted past the unattended verifier-run budget (`references/verification.md`) add `(self-checked)` after the full label the same way, for example `[P4] MINOR (Quality) (self-checked) …`. Where a host's format keeps the label in a separate field, follow that format and put `(self-checked)` wherever it allows: at the start of the title, or else at the start of the body. Never drop the marker. - **Questions are fine** when a finding hinges on something you can't see: `[P2] MAJOR Can user_id be null here?` followed by what breaks if it can. Example: @@ -97,7 +98,7 @@ The helper requires an unchanged head. If only the base tip advanced, it queries **Coverage:** . -**Verification:** ; <"N findings checked by fresh verifiers; M refuted and dropped." | "Not independently verified: ."> +**Verification:** ; <"N findings checked by fresh verifiers; M refuted and dropped." | "N findings checked by fresh verifiers; M refuted and dropped; K self-checked only, past the verifier-run budget." | "Not independently verified: ."> ### Findings @@ -105,7 +106,7 @@ The helper requires an unchanged head. If only the base tip advanced, it queries ### Also noted -[P3] MINOR (Defect) +[P3] MINOR (Defect) [P4] MINOR (Quality) diff --git a/skills/code-change-review/references/verification.md b/skills/code-change-review/references/verification.md index 5bd3f40..cafbb5b 100644 --- a/skills/code-change-review/references/verification.md +++ b/skills/code-change-review/references/verification.md @@ -89,11 +89,11 @@ Each pattern below is a real kind of rejected review comment, with the check tha ## Adversarial verification by a fresh agent -**Mode and budget.** Default **Standard**: independently verify each `[P1]`/`[P2]` candidate and any finding whose deciding facts are uncertain. **Quick**: self-check every finding; no subagent requirement. **Deep**: independently verify every finding that will appear in the report, including "Also noted". **Unattended publication** always uses Deep when subagents are available; without subagents use the separate self-check and explicitly report that limitation. Never imply an independent check occurred when it did not. Use at most four verifier agents concurrently by default, queue further findings, and record cost/coverage. Do not allow this budget to reduce the evidence standard for any finding. +**Mode and budget.** Default **Standard**: independently verify each `[P1]`/`[P2]` candidate and any finding whose deciding facts are uncertain. **Quick**: self-check every finding; no subagent requirement. **Deep**: independently verify every finding that will appear in the report, including "Also noted". **Unattended publication** always uses Deep when subagents are available; the verifier-run budget in "Posting without a human in the loop" limits verifier runs on `[P3]`–`[P5]` candidates only, and every `[P1]`/`[P2]` still gets a fresh verifier; without subagents use the separate self-check and explicitly report that limitation. Never imply an independent check occurred when it did not. Use at most four verifier agents concurrently by default, queue further findings, and record cost/coverage. Do not allow either limit to reduce the evidence standard for any finding: a past-budget `[P3]`–`[P5]` candidate takes the self-check instead of a fresh verifier, must still be Confirmed to be posted, and is reported as self-checked. Arguing against your own finding (step 3) only goes so far: you re-read the code through the reasoning that produced the finding, and the assumption that made it wrong looks just as reasonable the second time. So once you have drafted every finding and run the procedure above on each, hand each one to an agent whose only job is to disprove it, and who has never seen how you got there. -Independent verification applies to findings selected by the mode above when subagents are available; Deep covers **every finding that will appear in the report**, including held-back "Also noted" items. Nits only counted and not reported do not need independent verification. +Independent verification applies to findings selected by the mode above when subagents are available; Deep covers **every finding that will appear in the report**, including held-back "Also noted" items; the only exception is the verifier-run budget for findings posted without a human in the loop ("Posting without a human in the loop"). A report a person reads gets no budget, even from an unattended run. Nits only counted and not reported do not need independent verification. ### Who verifies @@ -166,7 +166,9 @@ If the host can't start subagents, do step 3 of the procedure as a separate pass When findings go straight onto a pull request (a review bot, a CI job), nobody filters them before the author sees them, so raise the bar: -- For unattended publication, run Deep mode. When the host can start subagents, post only findings whose last fresh-verifier verdict is `holds`, or `unsettled` on a fact that is genuinely out of reach (the Plausible case below). When it cannot, post only findings surviving a separate self-check and explicitly mark the absence of independent verification; an operator may instead configure the bot to refuse publication without an independent verifier. -- Of those, post only Confirmed findings, plus Plausible `[P1]`/`[P2]` findings whose deciding fact is genuinely out of reach and named in the comment. +- For unattended publication, run Deep mode. When the host can start subagents, post only findings whose last fresh-verifier verdict is `holds`, or `unsettled` on a fact that is genuinely out of reach (the Plausible case below); the one exception is a `[P3]`–`[P5]` finding past the verifier-run budget, which takes the self-check in place of a fresh verifier (see the budget bullet below). When it cannot, post only findings surviving a separate self-check and explicitly mark the absence of independent verification; an operator may instead configure the bot to refuse publication without an independent verifier. +- Of those, including any self-checked past the budget, post only Confirmed findings, plus Plausible `[P1]`/`[P2]` findings whose deciding fact is genuinely out of reach and named in the comment. - Leave out Plausible `[P3]`–`[P5]` findings. If you want, list them in the review body as questions. +- The stricter bar is on evidence, not on count. Return every finding that clears it, down to the host's severity threshold, most severe first; the human report's limit of about 10 and its NIT hold-back don't apply here. The host applies any comment limit after ranking. When you post directly instead, with no host filtering what you return: stop at the configured severity threshold, or at `[P4] MINOR (Quality)` when none is configured, because nobody else will hold back style NITs; and if you must apply a configured limit yourself, apply it after ranking and state the limit and how many findings it withheld. +- Bound fresh-verifier spend on lower ranks, not what is reported. The host's or operator's verifier-run budget counts fresh-verifier runs on `[P3]`–`[P5]` candidates, 15 per review if none is set. Take candidates in rank order. A candidate's runs, including the one extra verifier "Acting on the verdict" allows, all come from the budget, and a run that refutes its candidate still uses it up. Start a candidate's first run only while at least two runs remain after setting one aside for each candidate already in flight, so every disputed or unsettled verdict can get its extra verifier even when candidates run concurrently; a candidate's set-aside run is freed once its verdict is final; once fewer remain, that candidate and every later one are past the budget. Every `[P1]`/`[P2]` gets its fresh verifier, and its extra one when needed, on top of the budget, because when the host can start subagents a blocking finding is never posted on a self-check alone; without subagents, the first bullet of this list governs. Total spend is therefore at most two runs per `[P1]`/`[P2]` candidate plus the budget; a hard cap on the total belongs in the host's own configuration. A `[P3]`–`[P5]` finding past the budget gets the separate self-check used when no subagents exist. If it survives and is Confirmed, post it in this round with the `(self-checked)` marker from `references/reporting.md`; a Plausible one goes in the review body as a question, as above. Don't defer it to a later review. The verification note says how many findings were self-checked instead of agent-verified. - Cite the lines that settle the load-bearing facts in **Why it matters**, so the author can check your reasoning in seconds instead of re-deriving it.