--- name: review description: > Review a teammate's pull request the way a team reviewer should: against the requirement, the design, and the team conventions, with findings ranked by severity, each one citing a line and stating the failure it causes, and blocking issues separated from preferences. Use before approving a PR, when reviewing a colleague's branch, or when a review needs a second opinion. Triggers on: "review PR", "code review", "review this branch", "check PR", "approve this", "is this ready to merge", "/atk:review". argument-hint: "[pr-number|branch|commit|range|paths] [--against ] [--comment] [--strict] [--parallel ] [--out ]" --- # Team Code Review (`atk:review`) Reviews a change the way a responsible colleague does: it starts from what the change was supposed to do, not from the diff. Findings that block a merge are separated from findings that are taste, because mixing them is what makes reviews feel arbitrary. ## Scope Handles: reading the diff in the context of the requirement, design, and conventions, deciding which review rounds the change is worth and whether they run in agents of their own, finding correctness and regression risks, checking test coverage of the changed behavior, and writing review comments that a person can act on. Does NOT handle: approving or merging, a human act; rewriting the code, which the author does with `atk:implement` or `atk:fix`; judging the requirement itself (`atk:intake`); or reviewing a plan or a cases file, which `atk:plan --review` and `atk:qa --review` do against what each one rests on. ## Roles The reviewer is never the author. Tech Lead holds the final call on a disputed blocking finding. QA reviews test adequacy. See `shared/team-roles.md`. In band 1 without `--parallel`, the session that wrote a change hands the review to a fresh agent, per step 3; any other run where the author's session is the calling agent says so in the report. ## Invocation ```bash /atk:review # Review a pull request from the detected tracker /atk:review # A branch diff, one commit, or ... with its base /atk:review # Review given paths in the working tree /atk:review --against # Review against a specific design document /atk:review --comment # Post findings as inline PR comments /atk:review --strict # Include low-severity and stylistic findings /atk:review --parallel 3 # Deeper pass: a round that searches runs 3 copies /atk:review --out # Write the report somewhere other than the default ``` ## Workflow ``` [1. Establish intent] -> [2. Read diff in context] -> [3. Choose the rounds] -> [4. Find] -> [5. Verify] -> [6. Rank and write] ``` Before step 1, read `.atk/overrides/review.md` when it exists, per rule 7 of `shared/team-roles.md`. Then, before anything else, create this run's trace, `/derived/traces/review/.md`: read the kit's `shared/run-trace.md` and do what it says before the file, at each step, and at the close. Where the target has an earlier report, ask its scope first, or take the files a fix loop names, per Called again after a fix in `references/review-rounds.md`. Then count the changed lines in that scope per step 3 without printing them. In band 1 without `--parallel`, spawn a general agent at once as the reviewer, never `atk:read-only-reviewer`, with the target, the scope and the paths and no diff, which it reads through Masking a diff in `shared/secret-scan.md`: it runs steps 1 to 6 and spawns no reviewer, and this session writes the trace for it, per `shared/run-trace.md`. ### 1. Establish intent Find the requirement and design behind the change, per `references/review-rounds.md`. Without them, say so and review against the PR description alone; a review with no stated intent is a style check. A finding whose fix reverses a decision they record keeps its severity, per `references/report-format.md`. ### 2. Read the diff in context Open the surrounding files, not only the changed lines. Most real defects live in what the change implies elsewhere: a caller not updated, an enum case not handled, a migration without a backfill, a cache not invalidated. ### 3. Choose the rounds The review runs as nine rounds, one job each, using the host's ability to run agents in parallel per `shared/host-capabilities.md`. `references/review-rounds.md` holds the round list, how many copies each round runs, which rounds may share an agent, the memory cap, what each agent is given, how the calling agent drives them, and how the findings become one list. Three questions settle the shape of a run: **Which rounds run.** All nine, minus the ones whose subject the diff does not contain: no deleted lines, no signature change, no behavior change. That is different from a round that ran and found nothing, and the report keeps the two apart. The list comes from step 4 below. **Where they run, and how many copies.** Every round runs once. The size of the change decides only where, measured in changed lines and never in files: 500 lines or fewer run all nine rounds and the sweep in one reviewer agent, handed the target and the paths to the intent and nothing of the conversation; above that the rounds get agents of their own, the comparing ones sharing one, seven at most. A file the repository regenerates counts toward neither number, on the evidence `references/review-rounds.md` requires, and is still read by the rounds that have a reason to open it. Say which band the run is in and what put it there. Copies come only from `--parallel `, at any size: the rounds that have to go looking run N, and a round that only compares the diff against a list runs once, because copies of a comparison return the same answer. **Which rounds share an agent.** Comparing rounds may be combined; searching rounds never are, because combining them rebuilds the agent that forgets its earlier concerns. All three are settled before anything is spawned, so the run says what it will cost first: the round runs, the agents, and the concurrency the machine's memory allows. The cap is measured, not assumed, and it outranks the dispatch rule of step 4 rather than the copy count, per `references/review-rounds.md`. Stating the cost is what leaves the choice to pay it with the person. Every agent in a round reads the same diff: independence is the point, so splitting the files between them would produce agreement that means nothing. Rounds divide the question, never the files. Steps 1, 5, and 6 keep their judgement in the calling agent, which in band 1 is the reviewer agent, and it returns only the summary of `## Output` and the report path. Intent is what the rounds are measured against, ranking one list out of many needs all of them in one context, and the calling agent also drives the rounds. The one search inside them that is delegated is the closing sweep of step 5, which above band 1 gets its own agent and hands its candidates back for the verdicts; `references/review-rounds.md` says why. Where the harness cannot spawn agents, the nine rounds run one after another in this session and the report says so, including that the reviewer shared the author's context. ### 4. Find Eight things to look for, ranked here in the order step 6 reports them: behavior that contradicts an acceptance criterion, correctness bugs and regressions, missing error and edge-case handling, security and data exposure, untested new behavior, a public contract changed without its reference document, convention violations, then readability. This list is what the nine rounds are made of, not a separate list running beside them. Six of the eight become one round each; item 2 becomes three, `lines`, `removed`, and `callers`, because that is where defects hide and the three open different things; readability becomes no round at all, for the reason `references/review-rounds.md` gives. The order above is how step 6 ranks what comes back, not the order the rounds run in: the calling agent dispatches one round ahead of the one it is synthesizing, and never all nine at once, per the same file. Convention checking is the `rules` round, and it runs off `shared/review-checklist.md`: resolve the project's conventions document per Where the rules live in that file, read its review checklist section, check each `REVIEWED` rule, and cite the rule ID with its text quoted verbatim so the author can dispute the rule rather than the reviewer. With no recorded conventions, say so in the review and check this round's own baseline items anyway: the round never falls silent there. The other baseline items stay with the rounds that hold them, per `references/review-rounds.md`. Do not invent project-specific rules mid-review; report the gap so `atk:convention` can record it. The reference-document check is the `contract` round, and the sync obligation in `shared/spec-docs.md`, which lists the six kinds of change that trigger it and so decides whether the round runs at all. Raise a `BLOCKING` finding when a contract moved and neither the document nor a stated skip came with it, or when the change left the document untrue, per The sync obligation there; `Contract: first`, and any `screen` document, add a rule in `references/review-rounds.md`. Where the pull request, or the intent given with a change not yet in one, says what is stale and who will fix it, the obligation was met and there is no finding. Do not fix the document as the reviewer. That moves the work to the wrong person and teaches the next author that the rule is optional. Something the document never settled is an open question, not drift, per the same file. ### 5. Verify before reporting Every candidate gets one verdict, decided against the code rather than against how confident it sounds, and so does a round's checkable "checked and fine", per `references/review-rounds.md`. | Verdict | The candidate | What happens to it | |---------|---------------|--------------------| | `CONFIRMED` | Names the input or state that triggers it, and the wrong result | Reported. Eligible for any severity | | `PLAUSIBLE` | Names the mechanism, but the trigger depends on timing, environment, or configuration | Reported at `SHOULD FIX` or below, carrying the one check that would settle it | | `REFUTED` | Rests on something the code does not do | Dropped, silently | `PLAUSIBLE` is what a candidate gets when nothing refutes it. Do not refute one for being speculative, or for depending on state at run time, when that state is one the system reaches: two callers racing, `nil` on a rare but reachable path such as an error handler or a cold cache, an absent optional field, a falsy zero read as missing, an off-by-one on a boundary the code does not exclude, a retry storm, a partial failure, an anchor lost from a pattern. Refute only on something the code shows: the real line says otherwise, a type or a constant or an invariant makes it impossible, the same diff already guards it, or it is style with no observable effect. A verdict resting on "unlikely" is none of these, and dropping a finding that way is how a race condition ships. This does not license the question dressed up as a finding. `PLAUSIBLE` still needs a named mechanism and a named trigger; what is uncertain is only whether that trigger occurs. A candidate naming neither is not plausible, it is unexamined, and it is dropped. A candidate on a state no rule of an `atk` run covers is dropped and counted, from any round, when rule 5's default in `shared/team-roles.md` handles it, per `boundary` in `references/review-rounds.md`. Then take one more pass, once, with the verified list in hand: in an agent of its own above band 1 where one can be spawned, and in band 1 inside the reviewer agent. Read the diff and the code around it looking only for what is not on that list: the job is the gaps, not a second opinion on what has already been found. Surface at most eight new candidates, or nothing at all when there is nothing new: a padded sweep costs the author the attention that makes the rest of the list worth reading. New candidates go through the verdicts above like any other, and are labelled apart from every round's findings, per `references/review-rounds.md`. A sweep that died before it reported is re-run once, per the same file, and a review that ships without one says so: the run that quietly lost it reads exactly like the run that found nothing. ### 6. Rank and write | Severity | Meaning | |----------|---------| | `BLOCKING` | Wrong behavior, data risk, security risk, or a broken contract | | `SHOULD FIX` | Real problem, safe to fix in a follow-up if the author agrees | | `NIT` | Preference. Never blocks. Say so in the comment | **Reach.** A finding on a rule written for an agent carries `Reach: ordinary` or `Reach: edge`, as the `boundary` round in `references/review-rounds.md` defines them; code carries none. An `edge` finding is a `NIT`, unless its consequence is one of five, the kit's floor, which keep the severity they earn: (1) a role's decision taken, or an approval state entered, without its owner, per rules 2 and 3 of `shared/team-roles.md`; (2) a secret or a person's data written, sent or shown, per rule 9 and The data a record must not carry in `skills/qa/references/test-run.md`; (3) an action past the consent line of `shared/finalize-steps.md`; (4) history or a person's uncommitted work lost or overwritten; (5) a public contract broken, per `shared/spec-docs.md`. Where it cannot be judged whether a consequence is one of the five, it keeps its severity, as an unjudged reach is `ordinary`; reach is how often a trigger is met, not step 4's edge cases. A convention violation takes the severity recorded against its rule, which reach never lowers, and is how a project adds a consequence of its own; a baseline item another round holds is not such a rule, per `references/review-rounds.md`. Raise it only when the concrete failure is worse than the rule anticipated, and say why. The report carries every finding step 5 kept, `BLOCKING` first. The summary, inline comments and visible part of a posted summary carry at most ten, or twenty under `--strict`, per Cap in `references/report-format.md`, which says what is cut first and what never is, and gives a long `NIT` list its one-row form. Each comment: the file and line, what goes wrong, and a concrete suggestion, addressed to the code and never the author. State what the change does well in one line: only negatives teach nothing. Every finding carries an identifier prefixed by its severity, `B1`, `S1`, `N1`, numbered within that severity rather than across the three. It is the only part of a review that survives being spoken in a stand-up. `references/report-format.md` holds it, and the shape of everything around it. ## Output Every run writes a report to `docs/derived/reviews/-.md` per `shared/artifact-paths.md`, asked for or not. A review costs more to produce than to keep, and the run only spoken into a session is gone when the terminal scrolls. It is derived: safe to delete, rebuilt by running the review again. A target that is not a pull request is named by what was reviewed, a branch, a commit, a range or paths, as How a target becomes a name in `references/report-format.md` says. The session gets the summary, not the report: how many findings at each severity, the `BLOCKING` ones in one line each, how many the cap left to the report alone, the path to the file, and `/atk:catchup `, which explains each finding in plain words. Whoever watched the run needs to know whether they are blocked and where to read the rest; the argument is the file's. `references/report-format.md` holds what that file looks like, its identifiers, labels, round table and sections; this section decides only where it goes and what reaches the session. Read the newest earlier report on the same target first, and on a pull request its newest `atk:review` summary: a second review reuses its identifiers, so `B1` stays `B1`. `references/report-format.md` holds what a severity change and a missing earlier report do. `atk:plan --review` and `atk:qa --review` read their own the same way, and step 1 of `atk:convention` takes its `Convention gaps`; `shared/artifact-paths.md` lists every derived kind the kit reads. `--out ` moves the file. It no longer decides whether one is written. ## Ticket Follow `shared/ticket-adapters.md`, whose script posts the review. Under `--comment`, post inline the findings the cap in step 6 allows, except one the author answered, and one review comment that answers those and lists every finding, collapsed, per `references/report-format.md`, which says what the reviewer decides on each answer first. Post nothing before the list is shown and the person says yes; band 1's reviewer agent posts nothing. Only a posted `BLOCKING` finding requests changes. ## Definition of done - [ ] The requirement or design the change was reviewed against is named, or its absence is stated. - [ ] Every `BLOCKING` finding names a concrete failing input or broken contract. - [ ] Every reported finding and every checkable "checked and fine" was verified, and a `PLAUSIBLE` finding names the check that would settle it. - [ ] Nothing was refuted for being unlikely: every drop rests on a line, a type, a guard, the absence of any observable effect, or the default of rule 5 handling the state, listed and counted. - [ ] Preferences, and `edge` findings outside the five consequences, are `NIT` and do not block; every finding on a rule written for an agent carries its reach. - [ ] The report carries every verified finding; the summary, inline comments and the visible part of a posted summary are within the cap, and a cut names how many it left out, at what severity. - [ ] A sweep for gaps ran once against the verified list, in its own agent above band 1 where one could be spawned or inside the band-1 reviewer agent, and returned nothing rather than padding. - [ ] New behavior without a test is reported as a finding. - [ ] Every convention finding cites a rule ID and quotes the rule, or is marked as a baseline item. - [ ] A rule the review wanted but the project has not recorded is reported as a convention gap, not applied as if agreed. - [ ] A band-1 review without `--parallel` ran in a reviewer agent given no conversation; any other run whose calling agent was the author's session says so in the report. - [ ] The cost was stated before the first agent was spawned, or the run said it spawned nothing, and a run the cap held to one round at a time instead of one round ahead says so. - [ ] The band and the line count that put the change in it are stated, net of any generated file the count excluded and naming it, along with the agent count the band and any `--parallel` ask for, the rounds that ran, any skipped and why, any that came back empty, any that died, and a copy count the machine forced down. - [ ] A round or a sweep that died was re-run once or reported as not run, and neither was left to read as a round that looked and found nothing. - [ ] Every finding carries a severity-prefixed identifier, carried over from the earlier report or pull request summary where there is one, and the report follows `references/report-format.md`. - [ ] Every agent within a round received the same scope, and a finding only one copy of a round raised was checked against the code before it was reported. - [ ] No spawned round was shown what an earlier round found, the closing sweep excepted. Where every round ran in the calling agent, only the deduplicated list was carried between them. - [ ] A change touching a public contract carried its reference document and left it true, or stated the skip, and neither was silently fixed by the reviewer. - [ ] The report was written, to the default path or to `--out`, and the session carried the summary and that path rather than the whole list. - [ ] No comment addresses the author rather than the code.