AI workflows
A code-review book for agents: how I built it, and why it needs upkeep
I mined six months of my team's PR reviews into a rulebook for coding agents, with a PR count behind every rule. It helps me write and review code, I can't prove it cut review comments, and it only stays useful if someone maintains it.

Every team already has a code-review guide. It just isn't written down. It sits in closed pull-request threads: a reviewer asks for a test, the author adds it, the thread closes, and three weeks later someone else makes the same mistake and gets the same comment. An agent that writes code for that team starts every session without any of it.
We need to learn from the past, but keep that knowledge active and always measure what we do. A rulebook mined from past code reviews does no harm and does help, but only as long as someone maintains it.
This post is how I built such a book for my team at work, how I use it while writing and reviewing code, what I could and could not measure, and what I would change. If you have a repository with a review history, you can do the same.
I did not want a generic best-practice list. There are good ones, and the library I use for my agents (Trove) already had one: a book called Code Review for AI Agents. I took its layout from it: a decision matrix, severity mapped to an action, and a when not to flag note on every rule. I did not take its numbers. Its numeric thresholds contradicted each other, and a threshold that is not from your own code is a guess.
Two posts shaped the method.
Anthropic's write-up of how the Claude Code team reviews code gave me two ideas. The first is to sort every review comment by how it was received: fixed, said to be wrong, intentional, or didn't matter. A comment nobody acted on is not a rule. The second is the risk tier: “The change sets the tier, not the author.” (Osmani, Lunt and Wang, How the Claude Code team does code review, claude.dev, 2026-10-15) A docs change and a migration need different review, whoever wrote them.
Sahar Carmel's post on Trove's blog, I merge PRs I never read, gave me the ownership model. “A review document is not a style guide. The linter already handles style.” (Sahar Carmel, I merge PRs I never read, Trove blog, 2026-10-18) And the line I kept coming back to: “The owner decides what goes in and keeps it true.” (Sahar Carmel, I merge PRs I never read, Trove blog, 2026-10-18)
I was not the only one reaching for this. Macroscope's guide to team standards puts it in one line: “Your repeated review comments are your real standards.” (Macroscope, How to Enforce Team Coding Standards with AI Checks)
So the structure came from outside. The rules had to come from my team.
I built it in one run, on 2026-10-19, from six months of review history in our main web repository. Six months is how far back the comments go, not how long it took.
Inventory, in code. A Python script pulled every pull request through the gh CLI: metadata, the diff, every review, every inline comment with its thread, and the commits after each comment. No model was involved. It found 599 PRs inventoried; 194 had review discussion, and 982 threads in all.
One reader per pull request. Each PR with review discussion went to its own agent, which read the whole packet and returned strict JSON for every thread: who raised it (a person, Copilot or Claude), what it was about, how it was received, and a generalised lesson.
I started with Haiku as that reader. A Sonnet audit disagreed with it on 70 of 384 threads, mostly because Haiku called comments "fixed" with no clear evidence. "Fixed" is what turns a comment into a rule, so Sonnet did the extraction.
Coverage is checked, not trusted. Code checks that every review thread appears exactly once in the extraction, and that a cited fix commit really belongs to that PR. An agent that skims cannot silently drop a comment.
Clustering and synthesis. Sonnet grouped the findings into candidate rules by code area. Opus ranked them and wrote the approval guidance, the AI-reviewer guidance and the review-loop rules.
My approval, rule by rule. I walked through every entry before anything was published. The whole run cost under 40 dollars, most of it the Sonnet extraction.
The model proposes; code decides what becomes a rule. These are the thresholds:
A rule needs a fix in at least 2 distinct PRs. One fixed comment is an anecdote. The same fix in two unrelated PRs is a pattern.
A do not flag entry needs at least 60% of its evidence rejected, intentional or didn't-matter, and at least 2 threads. These are the comments reviewers keep raising and authors keep declining. An agent should stop raising them.
Known debt means every evidence thread is on pre-existing lines. A comment about code the PR did not touch is real, but it is not a review rule.
After that I approved every entry by hand: 107 entries approved, 0 entries rejected, 0 entries edited.
Every rule in the book says what it rests on: how many PRs, how many authors, and what share of its threads were fixed. That turns a list of opinions into something an agent can weigh. A rule that came up in many PRs and was almost always fixed is one to lean on. A rule that came up once is a default, not a law.
The book is honest about how small the numbers are: “Nearly every rule rests on fewer than 10 PRs. Treat a rule as the team's default, not as a measured law: apply it, and accept a stated reason from the author for not following it.” (the guidebook, How to use this book)
And the count alone can mislead. The rule on branch and stack hygiene rests on 12 PRs, but only 25% of its threads were fixed: reviewers raised it often and authors mostly didn't act. The rule to use a native button for click actions rests on 7 PRs, and 91% of its threads were fixed. The second one deserves more weight, even with fewer PRs. So the weight I want is the count and the fixed share together, not the count by itself.
The book is not a document I read. It sits inside my review loop, in three places.
When I open a pull request. The description states the change's risk tier and the number of approvals the book's decision matrix calls for. A change to the data model is high tier and needs two people; a docs change is low.
When an agent writes a fix. My plans cite rule IDs. One fix plan, for a CI change, named four backend-test rules and the CI rule that two people approve deploy changes. The agent loads the chapter for each code area the diff touches, and chapter one tells it which.
When the diff is ready. Every non-trivial diff gets a cross-harness review with my /code-review-x skill: work Claude wrote is reviewed by Codex, and work Codex wrote is reviewed by Claude. A reviewer from the writer's own model family is refused. I wrote about why in Claude writes, Codex reviews. The briefing carries the repository's REVIEW.md and the books, so the reviewer checks the diff against the team's rules, not only its own taste.
One caution I took from the research. Jacob Stephens ran a preregistered replay of cross-family review and reports: “At three of four checkpoints the cross-family reviewer fails.” (Jacob Stephens, Fresh Eyes Beat a Second Family, 2026-10-12) His explanation: “A reviewer from another family is also a reviewer that did not watch the code being written.” (Jacob Stephens, Fresh Eyes Beat a Second Family, 2026-10-12) So some of what I credit to a second model family may simply be a fresh look. My ledger can't tell those two apart yet.
<skill-dir>/run.sh --base main --json
When a review finds something worth keeping, it becomes a dated proposal for the book, never a direct edit. One proposal came from a Codex review of the first commit of a PR, fixed in the second: a row count on a table that may not exist must use two queries, because the database resolves every table name before it evaluates the CASE.
After acting on a review, I log every finding: its severity, how it was received, and how many rounds it took to settle.
python3 <skill-dir>/ledger.py add --repo <name> --severity <S> --disposition <fixed|wrong|intentional|did-not-matter> --rounds <n> --finding "<file:line summary>"
python3 <skill-dir>/ledger.py stats
Across all my repositories, from 2026-10-28 to 2026-11-10: 207 findings, 165 fixes, a noise rate of 13%, and a median of 2 rounds. On the work repository alone: 64 findings, 50 fixes, a noise rate of 14%. That measures the whole review loop, the book together with the cross-harness reviewer. It is not a measurement of the book alone.
Did review comments go down? This is the question I most wanted to answer, so I counted. Before the book: 126 PRs, human root review comments 0.27 per PR. After the book: 89 PRs, human root review comments 0.09 per PR. On paper, that is a drop to a third.
I don't trust it, for five reasons.
The PRs that use the book mostly haven't been reviewed. 36 PRs cite the guidebook in their description, and only 1 PR of them is merged. An unreviewed PR has no comments by definition.
Copilot stopped commenting. There were 2 comments from Copilot on August PRs, and 0 comments from Copilot on September PRs. That is a tool change, not the book.
The baseline is tiny. Before the book, 10 PRs had any human comment, out of 126 PRs.
The PRs changed shape. The median change went from 44 lines to 155 lines.
There is no control group I trust, and the "after" window is three weeks.
The honest metric is slower. Anthropic names it: “Revert and incident rates are the guardrail: if they rise, we haven't saved human time, we've only moved it.” (Osmani, Lunt and Wang, How the Claude Code team does code review, claude.dev, 2026-10-15) The book already has the seed for that. When I built it, 24 of 242 PRs merged had a revert or a follow-up fix, and the first heuristic for finding them flagged 54% of PRs, which was noise. Getting that signal right took work, and it takes months of new merges before it can show a change.
I can't prove it, but it is good context, both for reviewing code and for writing it. I don't think it does harm: a rule that doesn't fit is skipped with a reason, and the book says so. In the PRs I open with it, the risk tier and the approval count are explicit, and my agents cite the rule they are applying.
What didn't work was everything around the content. In one session the library was unreachable (an authentication error), and the agent had to work from older notes. The book has since moved out of Trove into the team wiki. And the maintenance has not happened yet.
Since the first run, proposals have come in: three on 2026-10-27, three more on 2026-11-08. None has been promoted. No rule has been edited or retired. A book that nobody updates doesn't fail loudly. It just slowly stops describing the team.
Karol Piatek names why this happens: “Almost nobody does it, and for the same reason migrations never happen: the work is unowned and reactive, and it always loses to the next feature.” (Karol Piatek, Every review comment you repeat is a bug in your guardrails, Swifty Friday, 2026-07-01) Florian Bruniaux's answer is the one I am applying: “name who may promote the rule and who maintains it” (Florian Bruniaux, Turn recurring review comments into tested controls, 2026-10-14). For this book that is me, and the proposals are still waiting.
Here is what maintenance means for this book today.
A rule that is no longer relevant. The AI-reviewer chapter is tuned on Copilot's comments: which categories the team acts on, and the rule to answer every bot thread before approval. Copilot threads were fixed 243 of 386 times. But Copilot has left no comments on my PRs since September. That chapter should be marked superseded, with a dated note, and re-mined from the reviewers we use now.
Rules that should carry more weight. Extract repeated definitions rests on 12 PRs, with 75% of its threads fixed. Tests accompany new behavior paths rests on 8 PRs, with 67% fixed, and my fix plans already cite it. Both have a high count and a high fixed share. And one rule should leave the book: lint-catchable JSX and code hygiene was 93% fixed, which says a linter should catch it, not a reviewer. Addy Osmani makes the same point about agent files in general: “instruction value can expire, so archive first, and if a rule must always hold, encode it in a test, hook, or permission rather than leaving it as prose the model might lose.” (Addy Osmani, Audit your Agent files, 2026-08-27)
So here is what I'll do better. I'll weigh each rule by its PR count and its fixed share together, and show that weight to the agent. I'll re-run the miss statistics every month. I'll turn the reverts and follow-up fixes into an eval set, and score each revision of the book against it.
I'll also give each rule a review-by date, so a stale rule is a visible event. And I'll promote or reject proposals every week instead of letting them pile up.
Export your review threads. For each PR, pull the inline comments with the gh CLI:
gh api --paginate 'repos/<owner>/<repo>/pulls/<number>/comments?per_page=100'
Sort every comment by how it was received: fixed, said wrong, intentional, didn't matter, no response.
Keep a rule only when it was fixed in at least two different PRs. Put the declined ones on a do not flag list.
Write the evidence under every rule: PR count, fixed share, links.
Name an owner. Agents propose; the owner approves.
Review every diff with a model from a different family, with the book in the briefing, and log what you do with each finding.
A prompt to start with (written for this post, not one I ran):
Read every review thread in <export folder>. For each thread, return JSON with: who raised it (person, Copilot, Claude), the file, a one-line lesson, and how it was received: fixed (with the fixing commit), said_wrong, intentional, didnt_matter, no_response or unclear. Call it fixed only if a later commit in the same PR changed the commented lines. Do not skip a thread.
The structure is easy to copy. The hard part is the last word of the thesis: maintains.
- How the Claude Code team does code review (Anthropic): the response taxonomy, risk tiers set by the change, and reverts as the guardrail metric.
- I merge PRs I never read (Sahar Carmel): why a review document needs an owner, and what belongs in it.
- Code Review for AI Agents (Trove marketplace): the generic book I took the layout from.
- How to Enforce Team Coding Standards with AI Checks (Macroscope): mining past review comments into checks, advisory first.
- Fresh Eyes Beat a Second Family (Jacob Stephens): a replay study that separates a different model family from a fresh session.
- Audit your Agent files (Addy Osmani): why agent instructions go stale, and what to move into tests and hooks.
- Every review comment you repeat is a bug in your guardrails (Karol Piatek): a weekly loop for turning repeated comments into enforcement.
- Turn recurring review comments into tested controls (Florian Bruniaux): keeping observations, candidate rules and promoted rules apart.
