When agents write most of the code, the job is evidence

How to give a coding agent a verification loop, what each of the three test types can be fooled by, and one differential test measured at 42 milliseconds.

中文版是这篇文章的默认版本。 阅读中文版 →
This English page stays available at this URL; the Chinese version is the one we maintain first.

How many agents one person can run is set by whether that person can confirm the work without reading every diff. What follows is the version I ran, and what each kind of evidence can be fooled by.

1. The bottleneck moved from the keyboard to the confirmation#

Start with the number I cannot check. Around 90% of the code on the Claude Code team is written by Claude and reviewed by Claude, according to the team. It is vendor-published and I cannot reproduce it here, so read it as a direction rather than a size. Typing code stopped being the slow step.

Without some way to verify, one person can watch one or two Claudes, because every line still needs a human eye. With it, dozens or hundreds run at once. The model did not get faster. Each agent learned to hand over proof.

The same source has a second number. On structured file generation, having a separate grader score the work against a rubric improved task success by up to 10 points over a standard prompting loop, with the largest gains on the hardest problems.

Set both numbers aside and look at how the work breaks now that writing is cheap.

What goes wrong todayWhat it costs
A human reads every diffParallelism caps at one or two
Unit tests pass, the feature is brokenAgent and test share one misunderstanding
The gate lives inside the pull requestThat change widens the gate on its way through

Figure 1. The loop has one opening left for a person. The agent runs, reads the evidence, fixes, and only a third failed round goes out to a human
tap to enlarge

2. Three kinds of test, and what each one can be fooled by#

Two failure modes come before the choice of test. Flaky tests teach the agent to re-run rather than fix. Slow tests mean fewer runs per batch, which makes a failure harder to place. Heavy tests belong before the change lands.

End to end covers a real user path, add an item to a cart, check out, land on a confirmation page. It is hard to fool because the feature either works or it does not, and a failure comes with a screenshot and a sentence about what broke. A unit test can only say Error: Timeout after 30 seconds. The cost is run time and the occasional flake. Worth doing properly, with the agent holding a real pair of hands and a real pair of eyes, through the Chrome extension for web work, a simulator for mobile, an API harness for services.

Property tests cover the half you did not think about. Write a sentence you believe cannot fail, then let a library generate thousands of inputs that try to prove otherwise. fast-check for JS and TS, Hypothesis for Python, proptest for Rust. Almost every project already contains a few properties.

PropertyIn one sentence
Round tripEncode it, decode it, get the original back
InvariantThe balance never goes negative
IdempotencyA migration or a retry run twice equals run once
EquivalenceThe optimised version returns what the naive one returns

Differential tests use the old system as the answer key. Feed the same input to both implementations and look for disagreement, which means a bug or a breaking change. They pay off in large migrations, where the only trustworthy description of intended behaviour is the system about to be replaced. Generate the inputs randomly or sample production traffic, normalise the differences nobody cares about such as whitespace and field order, and keep a written list of the differences you approved.

TypeWhat it answersHow to fool it
End to endDoes the feature work, and where did it breakToo few paths, fixed sleeps, flakes
PropertyIs there a counterexample at the edgesThe property itself is wrong, and confident
DifferentialWhere do old and new behaviour differThe old system has the bug, and wins anyway

Figure 2. The three types fail in different corners. End to end misses paths it never walks, property tests miss a wrong assertion, differential tests miss a wrong answer key
tap to enlarge

3. Measured: eight hand-written cases pass, 129 random inputs quietly changed#

Here is a run I did in this container. A tag normaliser was rewritten. The old version kept ASCII letters and digits only. The new one swaps the character class from [a-z0-9] to \w, which reads like a small relaxation.

Whoever rewrote it wrote eight cases from their own understanding, covering spaces, hyphens, capitals, junk at either end. Then I used the old implementation as an oracle and ran 5000 random inputs through both.

The first version of the generator sprinkled odd characters too eagerly, and more than half the inputs disagreed. Real logs do not look like that. Only after I turned the rate down did the numbers below appear.

== hand-written suite
  8/8 agree

== differential over 5000 random inputs
  616/5000 disagree (12.3%)
  of those 487 are the approved `_` change, 129 are not
  42 ms total, 8 us per input

== smallest unapproved counterexample
  'üe' old='ue' new='u-e'

Eight out of eight passed. Of the 5000 random inputs, 616 disagreed, 487 of them because of a change we approved on purpose (the new version treats an underscore as a separator), and 129, or 2.6%, that nobody approved. The whole run took 42 milliseconds, about 8 microseconds per input.

I expected the smallest counterexample to be some accented library name. It is two characters, 'üe'. The old version normalises with NFKD and drops anything non-ASCII, giving ue. The new \w does not accept a combining mark, treats it as one more separator, and gives u-e. One tag, two URLs.

Both implementations are a dozen lines, short enough to copy.

# experiment/difftest.py: the old one keeps ASCII letters and digits
def old_normalise(raw: str) -> str:
    s = unicodedata.normalize("NFKD", raw.lower())
    s = s.encode("ascii", "ignore").decode("ascii")
    return re.sub(r"[^a-z0-9]+", "-", s).strip("-")

# the new one swaps [a-z0-9] for \w, which reads like a relaxation
def new_normalise(raw: str) -> str:
    s = unicodedata.normalize("NFKD", raw.lower())
    return re.sub(r"[^\w]+", "-", s).strip("-")

The snippet earns its place outside the example, because the same code takes production traffic. Sample 5000 inputs out of the logs, spend 42 milliseconds, and the conclusion no longer depends on someone reading the diff. The eight hand-written cases missed the combining mark because the person who wrote them and the code under test share a mental model. A random generator has no such model.

Figure 3. 5000 random inputs land in three piles. The white area the hand-written cases covered is all green, and the trouble sits in the 129 nobody approved
tap to enlarge

4. Write “run it” down as a skill#

Running the app matters more than running the tests. Nobody ships an iOS change without trying it in a simulator, and an agent gets the same treatment.

The concrete move is a skill called verify, in .claude/skills/ in the repo, as close to the relevant code as you can put it, as many copies as you need. Claude knows to use it before committing. The Chrome extension for web changes, an iOS or Android MCP for mobile, computer use for desktop, the service started locally for backend work.

Keep that skill fast and reliable. A slow one gets skipped, and a skill that gets skipped a few times stops being maintained. Ask Claude to iterate on it and stress it, because it is now your smoke test bench.

<!-- .claude/skills/verify/SKILL.md: the shape of one skill -->
---
name: verify
description: Boot the app and walk one user path before committing any change
---
1. make dev, wait until 127.0.0.1:8080/healthz returns 200
2. npx playwright test e2e/smoke --reporter=line, keep the screenshot on failure
3. pass only if the screenshot shows the user finishing the step

When a check is still failing after three rounds, Claude stops and brings in a person. That rule spends the human’s attention instead of the agent’s time.

5. A check needs a trigger you can read off the diff#

The team keeps a reliability checklist of 39 items. Each carries three things, a trigger readable from a diff, a check, and the incidents or pull requests behind it.

One item says --resume loads old transcripts. The trigger is a diff that touches session storage or message types. When it fires, the question is whether a newly added field loads safely when the older transcript does not have it.

Claude reads the diff and runs only the items whose trigger matches, usually 3 to 10 of them. Nobody has to memorise last year’s outage.

Most gates die the same way, by asking to be remembered. Run all 39 every time and the check becomes slow and noisy, and people stop reading the result.

Figure 4. Thirty-nine items narrow to three or ten by diff trigger before anything runs. An untriggered item is never executed
tap to enlarge

6. A gate has to sit out of reach of the change it judges#

If a change can edit the check that judges it, the check is broken. Code Review reads REVIEW.md from the base or default branch, never from the pull request. The team made it structural, with the rules that gate changes living on a branch the change cannot reach.

A review also only means something for a commit. If someone pushes while the review runs, the result is stale and useless.

Every commit is stamped with how it was verified, and the stamp includes none, so unverified commits are queryable. The team also built a commit gate that can block a commit from a session that ran neither /code-review nor /verify, in three modes. Off does nothing. Observe logs what would have been blocked, so false positives can be reviewed without anyone being hit. Enforce blocks, and a commit can explain in its message why it went unverified. After two blocked commits in one session the next one goes through, because Claude Code is not perfect and getting stuck is worse.

Cheap checks run first, and the order is part of the design. An agent that pushes without testing locally spends shared review and CI time on something it could have caught itself, so tests, build and linter run before a pull request opens, enforced by a hook or by a /goal of a passing suite.

One counterintuitive result. You do not improve review by stacking reviewers. Adding a second, more expensive reviewer on top of the first usually costs more than tuning the first one. The team writes a REVIEW.md that says what the reviewer should watch for in this code, and each round is pointed at the context of earlier rounds, rather than re-checking everything from scratch. It is cheaper and it finds more.

Figure 5. Rules live above the line, the change lives below it. The gate only reads downward, so a change cannot edit the book it is judged by
tap to enlarge

7. Turn every miss into a rule, then delete rules on a schedule#

The first mines human review comments and reverts for patterns. A pattern has to appear in at least two pull requests and be identifiable from a diff. Before it enters the list, three agents try to disprove it, and a human approves it in a pull request. The second replays three bug-finding agents against a pull request tied to a known incident. If at least two find the bug, the bug is detectable. If a small diff hides it, the list is missing an item.

Flaky tests get the same treatment. Claude cannot skip them, add sleeps, or retry until green. If it cannot find the root cause, it deletes the test and writes down why.

Rules grow on their own. Test suites, verification steps and .md files only get bigger unless someone prunes them, and an unpruned list is just noise.

The reviewers get reviewed too. The team tracks the share of merged changes later reverted, the share a maintainer rejected before merge, and a size-matched control set of changes that stayed clean. For a formal evaluation they rebuild the repo at the state it was in at review time and give each example a one-sentence answer key, so only a finding that names the actual bug scores. Merged and stable changes serve as the control against over-flagging.

Recall is read in three stages, raw findings, post-verification, final review, because a single end-to-end score hides a system losing bugs it had already found. Tuning stops at the point where the next improvement would be fitting the eval set rather than catching bugs.

Figure 6. A miss is replayed, becomes a rule, and the rules are pruned on a schedule so the list stays worth running
tap to enlarge

8. Costs, one check you can run, two questions I cannot answer#

DecisionAlternativeWhyCost
Run end to end before mergingUnit tests onlyA green suite can hide a broken featureSlow, occasionally flaky, needs care
Let the old system be the oracleRewrite the spec firstThe spec has drifted from productionBugs in the old system become correct answers
Read REVIEW.md from the trunkShip the gate with the PROtherwise the change edits its own judgeChanging a rule is its own PR
Start a new gate in observe modeEnforce on day oneFalse positives block people for no reasonSomeone reads the logs during the trial
One reviewer, several roundsStack a second reviewerStacking buys cost, not judgementThe primary reviewer has to be tuned

The numbers, with sources kept apart.

MetricValueSource
Code written and reviewed by Claudeabout 90%vendor-published
Gain from a separate rubric graderup to 10 points of task successvendor-published, internal test, structured file generation
Items on the reliability checklist39vendor-published
Items triggered by a typical diff3 to 10vendor-published
Failing rounds before a human is pulled in3vendor-published
Hand-written cases agreeing8/8measured
Random inputs disagreeing616 of 5000 (12.3%)measured
Of those, an approved behaviour change487measured
Of those, approved by nobody129 (2.6%)measured
Time for 5000 differential cases42 ms median, about 8 us eachmeasured, 5 samples

Your version of this costs an afternoon. Take a pair of functions you rewrote recently, where the old one still runs in production. Put both implementations in one process, feed them five thousand inputs from real logs, and sort the disagreements into two piles, the approved behaviour change and the rest. The size of the second pile is the debt that rewrite took on, and paying it down costs CPU time.

Two questions I cannot answer. Differential testing assumes old and new should agree, and for a system where a random number, a clock or a concurrency schedule is in the answer, I have not found a workable way to write that assumption down as a rule. And when an observe period ends, which false positive should change the rule and which should change the code is still a human judgement I cannot yet record as data.

References#

Search 50 essays

Browse all writing