Cüneyt Mertayak
All articles

Building software

On Moving Code Review Upstream

Three stacked sieves separate large stones, pebbles, and fine green grains.

"What should happen if someone clicks Reset in a sidebar that already has no filters?"
That's a small product decision. If I leave it open, a coding agent can choose a behavior, write a test for it, and hand me a change with every test passing. By the time I read the diff, the decision looks settled. I might never notice it was mine to make.

Ankit Jain argues that as agents produce more code, engineers should spend more of their review time deciding what a change must do and how they'll know it works. I adapted that idea for our work in Claude Code. I review the acceptance criteria before implementation, give four agents different jobs, and keep the final merge in human hands. Jain makes a broader case for giving up line-by-line review in How to Kill the Code Review.

[Human] Approve the specA person agrees on the behavior to test.
[Agent] Test WriterTurns acceptance criteria into a test outline.
[Agent] Implementer · Return pointBuilds the change and fills in the assertions.
[Script] Automated checkpointRuns lint, type checks, and tests.Failed check? Return to Implementer
[Agent] EnforcerChecks the change against the spec and the original test outline.Unmet requirement? Return to Implementer
[Agent] Breaker
(adversarial tester)Looks for inputs or sequences of actions that make the changed code fail.Failing test? Return to Implementer
[Human] Review and mergeInspect the change set and decide whether to merge.
Follow the arrows when checks pass. If I approve a return for fixes, the Implementer makes the change and the automated checkpoint runs again.

Follow the Reset example through the full review on GitHub to see what each agent receives and how a failed check returns to the Implementer.

Decide what deserves a test

The pipeline starts with a short spec that I review and approve. Take the sidebar reset from our walkthrough. Suppose we decide that clicking Reset twice should leave the sidebar in the same state as clicking it once. Someone can check that. "Reset works correctly" leaves the next person with the same question we started with.

Matt Pocock distinguishes work that needs a person in the loop from AFK work an agent can do while you're away from the keyboard. His grill-me skill fits the first part. For the sidebar, I'd want the agent to ask me what someone should see after that second click. That's where I see the connection to Jain's spec. The conversation brings out what I expect, and the spec gives the agent and me the same written answer to check the change against. With that settled, I'd be comfortable leaving the implementation and tests to the night shift. If a test uncovers another product decision, that question can wait for me in the morning.

The first agent, the Test Writer, gets the spec and the relevant type signatures. It outlines at least one test for each acceptance criterion and leaves the assertions blank. I want the list of cases written down while the only thing we know is what we asked for. We save a copy of that outline. This borrows from test-driven development (TDD). In a red-green-refactor cycle, I'd first watch the Reset test fail because the active filter was still there, then make it pass and clean up the code. Here the test cases come first, but the Implementer fills in the assertions as it builds the change.

The Implementer gets the outline, the spec, our project rules, and the codebase. It works in a separate Git worktree, implements the change, and fills in the assertions. That split leaves a question for review. A test called "handles two resets" could click twice and check only that the button still exists. Its name would survive, the suite could pass, and we'd still know very little about the filters.

Read what a passing test actually proves

Between implementation and review, a shell script runs lint, type checking, and the test suite. It records the change in test count and which test files changed. A missing test can show up in those numbers. A weak assertion takes a closer look.

That's the Enforcer's job. It gets the original outline, the completed tests, the changed files, the project rules, and the script's results. In the sidebar example, it can follow the requirement about the second click all the way to the assertion about the resulting state. Its tools are read-only. If the assertion falls short, the finding goes back to the Implementer. I can then see both what the reviewer objected to and what changed in response.

Give someone a chance to find what we forgot

The fourth agent, the Breaker, is our adversarial tester. It gets the changed files without the spec or the earlier agents' reasoning. The Enforcer has already asked whether we delivered what we promised. Here I want someone to look at the reset handler and wonder what else could happen. Our walkthrough illustrates that with an empty filter value and two resets arriving close together. Those are examples of cases to try. Whether either one is a bug depends on the behavior we expect.

There's a practical limit to this independence. The Enforcer has no editing tools, while the Breaker's narrower assignment relies on its instructions. Separate conversations can also miss the same assumption. That's one reason the workflow stops and asks for help after repeated failures. The checkpoint and Enforcer each allow three retries, and the Breaker allows two rounds of fixes. The resulting branch is ours to inspect and merge.

What I want from the final review is the ability to pick one user action and follow it through the change. For that second click on Reset, I can find the behavior we agreed on, the test that exercises it, and the assertion that would fail if we got it wrong. If I still can't say what the person at the keyboard will see, I know where our review needs another pass.

The full review pipeline on GitHub includes the six skills and example scripts for TypeScript projects.