cd /news/ai-agents/how-to-review-ai-written-code-lesson… · home › topics › ai-agents › article
[ARTICLE · art-155984] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=· neutral

How to Review AI-Written Code: Lessons From the Claude Code Team and Hacker News

A Hacker News thread that drew 614 points and 748 comments surfaced a consensus on reviewing AI-written code: engineers should own the design and treat agents as implementers, then verify behavior through heavy testing and automated review rather than line-by-line reading. The discussion cited the Claude Code team's seven-layer review pipeline, published by Addy Osmani, Morgan Westlee Lunt and Qing Wang, in which a second agent reviews diffs in a fresh context and no PR can merge while bug or security findings remain open. Commenters warned that AI-generated tests can share the same blind spots as the code they check, and that at least one person must be able to explain any code shipped to production.

by read7 min views6 publishedOct 23, 2026

Short answer: Reviewing AI-written code requires moving design decisions upstream and automating verification before a human opens the pull request. Treat the agent as an implementer working against an explicit design spec. Run tests, linters, and a fresh-context subagent review locally, gate pull requests by change risk rather than code author, and route sensitive paths to human reviewers.

On October 19, 2026, Hacker News user rzk posted "Ask HN: How to deal with shipping AI-written code you don't understand?" on Hacker News. By October 23, 2026, the thread had 614 points and 748 comments. The post quoted a LinkedIn update from a Meta engineer detailing the core problem: "I'm writing code these days and it all feels like a black box."

The same post explained why line-by-line review stops scaling when agents write most of a change: "if we're going to spend our time checking each line of code, it's going to take forever."

The practical answers in the thread fall into two groups: control the design before the agent writes code, and verify behavior after it does. The Claude Code team's published process does both, and adds rules for when a human must approve.

In the largest subthread of 183 replies, bitwizeshift argued that control must happen before the model writes any code. The commenter wrote: "I don't let the LLM design the code at all, I let it implement a design I have created." They added: "I may not know how each unit is implemented, but I know each unit's responsibilities and how they interact with one another."

Other engineers in the thread shared this focus on separating system architecture from code implementation. Commenter jedberg summarized the dynamic plainly: "Your job is to design, the AI builds like the junior engineers. Then you review their work." Clear interfaces give the human reviewer a strict boundary against which to evaluate generated logic.

Verification strategies focused heavily on rigorous execution rather than passive reading. Commenter ChrisMarshallNY stated: "Testing. Lots and lots of testing." The same engineer observed: "I don't find coding errors, but I do find implementation errors."

Relying purely on automated tests brings its own specific trap. As commenter edwin0 pointed out: "The part that makes me uneasy is when the AI writes both the code and the tests. They might agree with each other and still miss the same thing."

Accountability remains a requirement for production systems. Commenter plastic041 emphasized: "You must read the code before shipping it to production." The commenter continued: "At least one person in your company should be able to explain the code!"

Engineers also adjust their oversight depending on the system layer. Commenter bob1029 noted that UI code is "basically entirely vibe coded", while "For things like the SQL schema I am still doing things entirely by hand."

Claude writes about 90 percent of Claude Code's own code. On October 15, 2026, Addy Osmani, Morgan Westlee Lunt and Qing Wang published "How the Claude Code team does code review", outlining their seven-layer pipeline.

The first layer verifies the work before anyone else looks at it. Claude runs tests, the build, and the linter and shows the output. Then "a second agent reviews the diff in a fresh context".

The second layer runs an automated AI review on every pull request against the whole repository and the PR's stated intent. Findings are checked by other agents and tagged Important, Nit, or Pre-existing. This directly connects to the advice from bitwizeshift and jedberg, as the explicit intent serves as the review target.

The third layer is a dedicated security review that holds blocking power. The team established a strict merge condition: "A PR can't merge while any finding from the bug review or the security review is still open."

The fourth layer enforces blocking automated checks across the codebase. These are lint, type checks, tests on every platform, and a build.

The fifth layer applies human approval scaled strictly by risk. The sixth layer routes code into a merge queue with feature flags and gradual rollout, exposing new behavior to Anthropic employees first.

The seventh layer provides fast detection and fast rollback. It relies on feature flags that "turn off without a deploy" and a weekly on-call rotation.

To keep the automated reviewer accurate, the team converts past incidents into an eval set. They collected historical pull requests that caused incidents or reverts and run the reviewer against that test suite daily. Every update to the reviewer's prompts, tools, or model is scored against this incident library.

Anthropic made Code Review for Claude Code generally available on October 15, 2026 for Claude Team and Enterprise organizations. Admins pick Quick, Standard (the default), or Deep per repository. Most reviews now take 6 to 10 minutes, down from about 20 minutes during the research preview.

The Claude Code team relies on three explicit rules to govern review responsibilities. First, "The change sets the tier, not the author." Second, "An agent's approval never counts as a person's." Third, "An approval covers one specific commit."

Low-risk changes require zero human approval once automated review and security checks are green. This tier covers documentation, copy updates, internal-only features, and additive changes isolated behind a feature flag. This matches the split bob1029 described, where interface code gets lighter review than the database schema.

Medium-risk changes require approval from one person. This category includes ordinary product changes and sensitive areas such as caching logic, the auto-updater, or system prompts.

High-risk changes require approval from two people. This tier is reserved for the highest-risk code alongside a small set of sensitive repository paths. This keeps human attention on the changes where a missed bug costs the most.

The Claude Code team measured the impact of this review system on their internal pull requests. The share of pull requests passing after just one review and fix round increased from 65% to 78%. Pull requests requiring five or more rounds dropped from 8.9% to 1.5%.

Review iteration cycles shortened across the engineering team. The mean number of review rounds required to pass dropped from 2.08 to 1.32.

Throughput expanded alongside code stability between June and September. During that period, total merged pull requests more than doubled while the share of pull requests that had to be reverted fell by more than 40 percent. These figures represent the team's own reported numbers.

List all checks an agent can execute inside a short CLAUDE.md file. Add hooks that run formatters and linters automatically.

Run /code-review and /security-review commands locally before opening a pull request, or trigger a fresh-context subagent review. The first human reviewer then starts from a diff that has already had one review.

Maintain a REVIEW.md document in your repository and migrate repeated review feedback directly into its rules. Update your pull request template to require sections for "Testing", "Risk", and "How to revert".

Cap the number of review rounds. After the first few rounds, restrict automated re-review so it checks only the newly modified diff rather than re-evaluating the full branch.

Configure CODEOWNERS and branch protection rules so that auth, billing, CI workflows, release workflows, and installers always require a human approver.

Track human engineering time spent on reviews while monitoring revert and production incident rates as your primary guardrail. If revert rates rise, tighten the risk tiers or expand the automated eval suite.

Claude Code can run directly with a Tokely API key through Tokely's Anthropic-compatible /v1/messages endpoint. Set ANTHROPIC_BASE_URL to https://api.tokely.me and ANTHROPIC_AUTH_TOKEN to your key, as in this single-line command from the Tokely guide:

ANTHROPIC_BASE_URL=https://api.tokely.me ANTHROPIC_AUTH_TOKEN='<YOUR_TOKELY_API_KEY>' ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-5 ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-5-5 ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-5-5 claude

Local /code-review and /security-review runs are billed per token from your existing Tokely balance.

The same Tokely API key also accesses OpenAI and Google models, such as GPT-6.1 Sol and Gemini 4 Argon, through the OpenAI-compatible Chat Completions endpoint. That makes it possible to send an agent's diff to a model from a different developer for a second review.

The switch is a change of the model ID. It is one option for edwin0's concern about code and tests sharing the same blind spot, not a proven fix. Tokely is an API gateway and does not run Anthropic's hosted Code Review GitHub App. For implementation details, consult the guide on Claude Code with Tokely and the Tokely Claude Code guide.

The community perspectives in this guide come from the Ask HN thread posted on October 19, 2026. The review framework and reported metrics come from How the Claude Code team does code review and the product announcement Code Review is now generally available, both published on October 15, 2026.

Originally published at tokely.me.

── more in #ai-agents 4 stories · sorted by recency
── more on @hacker news 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/how-to-review-ai-wri…] indexed:0 read:7min 2026-10-23 · —