The Claude Code team at Anthropic says the vast majority of its code, about 90%, is written and reviewed by Claude. At that scale, the team says, the way it equips agents to prove their work is correct has become critical. In a detailed post, the team describes the tests, review rules and gates it uses to check AI-generated changes without reading every line.

How do developers check AI-written code without reading every line?

The core idea is the verification loop. Without one, a developer can realistically run only one or two Claude sessions at a time, because every result has to be checked by hand. With one, the team can run dozens or hundreds in parallel. The post cites internal testing on structured file generation, where a separate grader checking Claude’s work against a rubric improved task success by up to 10 points over a standard prompting loop. The largest gains came on the hardest problems.

Tests, benchmarks and specs that once took real effort to write are now cheap to request from an agent, the team says. Once generated, those tests run as software and can be executed often without using many additional tokens. The team also closes the loop by feeding failures back into the agent’s instructions. If an agent repeatedly fails a test that checks logs for user data, a developer can add a hook or a more explicit rule to the project’s CLAUDE.md file. That, the team says, mostly stops the problem from recurring.

Three test types worth the investment

The team warns that flaky tests are a trap. If tests are unreliable, the agent learns to rerun them instead of fixing the failing code. Slow tests cause a different problem: the agent runs fewer of them across batches, which makes issues harder to pin down. Heavier tests work best before changes are committed.

What kinds of tests does the Claude Code team use to verify agent work?

If a team can only focus on one test type, the post recommends end-to-end tests. These mimic real user flows, such as adding an item to a cart, checking out and landing on a confirmation page. The team says these tests are hard to fool. Either the feature works or it does not, and the failure report can show what broke. A unit test might report “Error: Timeout after 30 seconds,” while an end-to-end test can capture a screenshot and describe the problem. Unit tests are faster and less flaky, the post notes, but an agent can pass them and still break the feature because neither the agent nor the test fully understands the task.

Property tests take a different approach. Rather than checking for failures someone anticipated, they start with a statement that should never be false and use libraries to generate thousands of inputs trying to disprove it. The post names fast-check for JavaScript and TypeScript, Hypothesis for Python and proptest for Rust. Common properties include round-trip encoding, where encoding and then decoding returns the original value; invariants, such as an account balance that can never go negative; idempotency, where repeating an action has the same effect as doing it once; and equivalence, where optimized code matches a simpler, correct version. The team says property tests help keep agents honest because the edge cases are not generated with the same bias as the code that the agent wrote.

Differential tests are built for large migrations where behavior should not change. The old and new systems receive the same inputs, and any difference signals a bug or an unapproved breaking change. The post recommends random inputs or a sample of production traffic, normalization of irrelevant details such as whitespace, and a list of approved changes for cases where the new system should differ.

Gates, reviewers and checks that cannot be edited

The team puts running the app ahead of unit tests. “You wouldn’t ship an iOS change without trying it in a simulator,” the post says, and the same logic applies to Claude. Depending on the platform, Claude can use the Claude Chrome extension for web changes, an iOS or Android MCP for mobile, computer use for desktop, or run the service locally for backend work. Developers can codify these steps in a skill called verify, stored in a .claude/skills/ folder close to the relevant code. Claude is expected to use it before committing changes.

When does an AI agent hand a failing check to a human?

Human attention is reserved for failures. Claude runs the checks and tries to fix what fails. If a check still fails after three rounds, Claude stops and brings in a person. Code owners write their own checks and refine them until those checks flag what the owner would flag. When a check pulls in a reviewer, it should explain why, so the reviewer does not have to reconstruct the reasoning from the diff.

The team also maintains a reliability checklist of 39 items. Each item has a trigger that can be read from a diff, a check, and the incidents or pull requests behind it. One example is “--resume loads old transcripts.” Claude reads a diff and runs only the items whose triggers match, usually three to 10 of them. The team says it does not try to improve reviews by adding more reviewers. Instead, it tunes a single primary reviewer using a REVIEW.md file that states what to watch for in a given codebase. Review rounds build on earlier rounds and past failures rather than starting over.

A central rule is that a change cannot modify the check that judges it. Code Review reads REVIEW.md from the base or default branch, never from the pull request. Reviews are also tied to specific commits, since a passing review on an outdated commit means nothing if someone has pushed since. Cheap checks run first. On the team, Claude runs tests, the build and the linter before opening a pull request, which can be enforced with a hook or a goal for a passing test suite.

The team stamps each commit with how it was verified, including a value of “none” so unverified commits can be queried. It has also built a commit gate that can block a commit if the session did not include /code-review or /verify. The gate runs in off, observe and enforce modes. Observe mode logs what would have been blocked so the team can find false positives. Enforce mode blocks the commit, though a commit message can explain why verification was skipped. If a session has been blocked twice, the next commit is allowed through so Claude does not get stuck.

Testing the reviewers themselves

The team also reviews its reviewers. It tracks how many merged changes were later reverted, how many were rejected by a maintainer before merging, and a size-matched set of changes that stayed clean. Code Review uses a formal evaluation built from past incidents and reverts. Each example recreates the repository at the time of review, with a one-sentence answer key describing the bug. Only findings that correctly describe the bug earn credit, and merged, stable changes serve as controls against over-flagging. Recall is measured separately for raw findings, post-verification findings and the final review, so the team can see whether bugs are being lost along the way. The team tunes recall until the next gain would mean overfitting to the evaluation rather than catching more real bugs.

Findings are also sorted by importance. Code Review tags issues as Important, Nit or Pre-existing. The last tag means a reviewer should not hold the author responsible for a bug that was already there.

When a miss happens, the team turns it into a rule in one of two ways. The first extracts patterns from human review comments and reverts. A candidate pattern must appear in at least two pull requests and be identifiable from a diff. Three agents try to disprove it, and a human approves it in a pull request. The second replays three bug finders against a pull request tied to a known incident. If at least two find the bug, it counts as detectable, and a miss on a small diff becomes a candidate for REVIEW.md. Flaky tests get similar handling. Claude may not skip them, add sleeps or retry until they pass. If it cannot find the root cause, it deletes the test and records why. The team also prunes rules and test suites on a routine schedule, since they tend to grow unchecked.

The post’s conclusion is practical. Giving agents a strong feedback loop changes the job. Developers stop reading every diff and instead define what “done” means and review the evidence, which is what lets them run many Claudes at once.

Este artigo foi escrito com a assistência de IA.
News Factory APP - notícias agênticas para impulsionar seu SEO e AEO.