Article
AI engineering · Engineering practice · Guides
Make AI-Written Pull Requests Cheap to Review: A Step-by-Step Guide
Agents made code cheap to write, and the waiting moved to the review queue. Six steps, with the setup for Claude Code, Codex and GitHub, that cut what each review costs.
Start readingAs of October 2026. Every setting below links to the official page it comes from.
An agent can write a pull request in minutes. Someone still has to read it.
That second part has not got faster. Faros AI’s telemetry from more than 10,000 developers, a correlation from mid-2025 data, found that teams with high AI adoption merged 98% more pull requests while review time rose 91%. LinearB’s 2026 benchmarks show where the time goes. At the 75th percentile, pull requests opened by agents waited 17.6 hours before anyone picked them up, against 3.4 hours for pull requests written without AI. The review itself took longer too, 6.4 hours against 4.2, but the wait was the bigger part.
My reading of these vendor numbers: most of the extra time is not spent reading. It is spent waiting in a queue. If you have read Scalable Is Not Fast, you know the shape: as a resource gets close to fully busy, the time spent waiting climbs steeply. Here the resource is a few people’s review time, and agents have raised the arrival rate. Anthropic said it plainly when it launched its own review product in March: “Code review has become a bottleneck.”
You cannot fix a queue by writing code faster. You fix it by making each review cheaper. Below are six steps, each with the setup for Claude Code, Codex and GitHub. Each step helps on its own.
Agent-written pull requests wait far longer for a first review
Wait before anyone picks it up (p75)
3.4 hours- Written without AI
- 3.4 hours
- Written with AI
- 17.6 hours
Pull requests opened by agents
Review time once picked up (p75)
4.2 hours- Written without AI
- 4.2 hours
- Written with AI
- 6.4 hours
Pull requests opened by agents
Size (p75)
157 lines- Written without AI
- 157 lines
- Written with AI
- 408 lines
Pull requests written by people with AI help
Merged within 30 days
84.4 percent- Written without AI
- 84.4 percent
- Written with AI
- 32.7 percent
All AI pull requests
1. Keep each change small enough to read in one sitting
Size is the first cost. Cisco’s 2006 code review study, run with the review-tool vendor SmartBear across 2,500 reviews, advised keeping a review under 200 lines and never over 400, and under an hour: past 60 to 90 minutes, defect detection dropped sharply. Google’s own guidance calls 100 lines “usually a reasonable size” and 1,000 “usually too large”.
Agents push the other way: the pull requests they help write are larger. Google’s DORA research ties more AI use to higher throughput, but also to less stable delivery, and notes that “an increase in change volume leads to instability.”
Tell the agent the size you want, in the instruction file it reads every session. The numbers below are a starting point drawn from that guidance, not a law. Tune them for your codebase.
Claude Code · CLAUDE.md
## Pull requests
- One pull request does one thing. Aim for about 100 changed lines; past 400, split it.
- Split a large change in order: the refactor, then the behaviour change, then the cleanup.
- Never mix a rename or a formatting pass with a logic change.
- If a change cannot be split, say why in the description.Codex · AGENTS.md
## Pull requests
- One pull request does one thing. Aim for about 100 changed lines; past 400, split it.
- Split a large change in order: the refactor, then the behaviour change, then the cleanup.
- Never mix a rename or a formatting pass with a logic change.
- If a change cannot be split, say why in the description.2. Make the agent check its own work before it hands over
The cheapest bug for a reviewer is one the agent already fixed. Two checks belong before a person is asked to look: the tests, and a review of the agent’s own diff.
For the review, Claude Code has /code-review (/review is now an alias for it), plus /security-review for the security pass. Codex has /review in the session, or codex review --base main from the shell.
For the tests, use a Stop hook. Both tools run it when the agent is about to finish its reply. If it exits with code 2, the agent is sent back with your message as the reason. Both tools also pass a stop_hook_active flag that says the agent has already been sent back once. The script checks it, so a test that cannot pass sends the agent back only once and never loops. One script serves both tools:
Script · scripts/stop-check.sh
#!/usr/bin/env bash
# Runs when the agent is about to finish. If it changed code and the tests fail,
# it sends the agent back once, with the end of the test output as the reason.
input=$(cat)
# Already sent back once: let it finish, so a test that cannot pass never traps the session.
if printf '%s' "$input" | grep -Eq '"stop_hook_active"[[:space:]]*:[[:space:]]*true'; then
echo '{}'; exit 0
fi
# Nothing changed, uncommitted or committed since the main branch: nothing to check.
if [ -z "$(git status --porcelain 2>/dev/null)" ] && git diff --quiet origin/HEAD...HEAD 2>/dev/null; then
echo '{}'; exit 0
fi
# Swap in your own fastest meaningful test command.
if ! out=$(npm test 2>&1); then
printf 'Tests fail. Fix them, or say exactly what still fails:\n%s\n' "$(printf '%s' "$out" | tail -n 30)" >&2
exit 2
fi
echo '{}'Claude Code · .claude/settings.json
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/scripts/stop-check.sh"
}
]
}
]
}
}Codex · .codex/hooks.json
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "bash \"$(git rev-parse --show-toplevel)/scripts/stop-check.sh\"",
"timeout": 300
}
]
}
]
}
}Make the script executable (chmod +x). It checks both uncommitted work and commits not yet on the main branch, so an agent that commits as it goes is still tested. The settings are fragments, so merge them into the file you already have. In Codex, a new or changed hook does not run until you trust it with /hooks. See the Claude Code hooks and Codex hooks pages for the full input.
3. Send every pull request with its evidence
A reviewer’s first question is “how do I know this works?” If the pull request does not answer it, the reviewer has to run things themselves, and that is the slow part. Ask for the answer up front.
A pull request template in .github/ fills the description of pull requests opened on GitHub, once it is on the default branch. An agent that opens pull requests from the command line writes its own description, so a matching rule in the instruction file tells it to follow the template.
Template · .github/pull_request_template.md
## What this changes
<!-- One or two sentences. One pull request, one purpose. -->
## Why
<!-- Link the issue or the task. -->
## How it was checked
<!-- The commands you ran and what they showed. Paste the output, not "tests pass". -->
## What it does not do
<!-- Anything left out, deferred or knowingly not handled. -->
## Risk
<!-- What could break, and how to undo it. Name any migration, auth or payments change. -->Instruction file · CLAUDE.md or AGENTS.md
## Opening a pull request
- Before you open it, run the tests and a review of your own diff, and fix what they find.
- Fill in every section of .github/pull_request_template.md.
- Under "How it was checked", paste the commands and their real output.
- Under "What it does not do", list what you skipped. An empty section is a claim.“What it does not do” is the section that saves the most time. An agent will rarely volunteer what it skipped. Asking makes the gap visible before review, not after merge.
4. Let machines do the repetitive review
Anything a machine can check should never reach a person. Tests, lint and type checks become required status checks, so a pull request cannot merge until they pass.
Then add an AI first pass that comments before a person opens the pull request:
- Claude Code. Code Review runs a team of review agents on each pull request and posts inline comments. It is a research preview for Team and Enterprise plans, billed per review: Anthropic’s docs put the average at $15 to $25, and it is not available with Zero Data Retention. Choose whether it runs once per pull request or after every push. Otherwise, the GitHub Action (
anthropics/claude-code-action@v1, set up with/install-github-app) reviews when you mention@claude.
- Codex. Comment
@codex reviewon a pull request, or turn on automatic reviews in the Codex GitHub settings. On GitHub it flags only the two most serious levels, P0 and P1.
Both read review rules from the repository. Keep them short and about what matters:
Claude Code · REVIEW.md
# Review rules
- Report bugs, security issues and missing tests. Leave style and formatting to the linter.
- Rank findings by how costly each would be after merge.
- Any change under db/migrations/, src/auth/ or src/billing/ needs a code owner: say so.Codex · AGENTS.md
## Code Review Rules
### Report
- Bugs, security issues and missing tests. Leave formatting and lint to CI.
### Escalate
- Any change under db/migrations/, src/auth/ or src/billing/ needs a code owner: say so.Treat the AI pass as triage, not approval. Claude’s Code Review never approves or blocks a pull request: its check always finishes as neutral. Whichever tool you use, keep the approval that counts toward merging a person’s. My own convention is one review pass on the final diff, with at most five findings ranked by how costly each would be after merge. A short list gets read, and a long one gets skimmed.
5. Spend human review where the risk is
Not every pull request deserves the same attention. A copy fix and a migration should not wait in the same queue for the same reviewer. Decide in advance which paths are risky, and route those to the people who own them.
GitHub’s CODEOWNERS file does the routing. With “Require review from Code Owners” turned on, a change under a listed path needs an approval from one of its owners. Everything else needs one approval from anyone. These are the same triggers as the heavy lane in the setup guide: migrations, auth and payments.
CODEOWNERS · .github/CODEOWNERS
# Risky paths get a named owner. Everything else needs one approval from anyone.
/db/migrations/ @your-org/data-owners
/src/auth/ @your-org/security-owners
/src/billing/ @your-org/payments-ownersBranch rules · GitHub repository settings
Branch protection or a ruleset for main, in the repository settings:
- Require a pull request before merging, with 1 approval
- Require review from Code Owners
- Require status checks to pass: your test, lint and type-check jobs
Keep the approval a person's. The AI pass comments; it is not a required check.One agent-written pull request, from task to merge
Step 1
Write one small change
Builder agentMid tierClaude Code: Sonnet 5.5Codex: gpt-6.1-sol
The size rule in the instruction file keeps it to something a person can read in one sitting.
Step 2
Run the tests and review its own diff
Builder agentMid tierClaude Code: Sonnet 5.5Codex: gpt-6.1-sol
The Stop hook sends it back if tests fail. A bug it fixes now costs no reviewer's time.
Step 3
Open the pull request with evidence
Builder agentMid tierClaude Code: Sonnet 5.5Codex: gpt-6.1-sol
The template asks how it was checked and what it leaves out, so the reviewer does not have to find out.
Step 4
Run the required checks
CI
Tests, lint and types are settled by a machine before anyone looks.
Step 5
Post a first-pass review
AI reviewer
It comments and ranks findings. The approval still comes from a person.
Step 6
Approve the risky paths
Code owner
Only when the change touches a path listed in CODEOWNERS. Most pull requests skip this step.
Step 7
Read the evidence and approve
Reviewer
The person spends their time on judgment: is this the right change? The steps before took care of the rest.
6. Watch one number every week
Track the time from opening a pull request to its first review, and look at the size beside it. Google’s 2018 study of nine million reviewed changes found small changes got first feedback in a median of under an hour, against about five hours for very large ones. Google’s guidance sets one business day as the most a review request should wait.
Read the two numbers together:
- Wait up, size up: the agents are writing bigger changes. Go back to step 1.
- Wait up, size flat: more pull requests are arriving than reviewers can take. Steps 4 and 5 move work off people, or the team needs more review time.
- Wait flat, merge rate down: pull requests are being opened and abandoned. Ask why before you add more agents.
An engineering dashboard gives you both. Without one, a short script over last week’s merged pull requests will do. Check them weekly, the same way you check cost.
The playbook in six lines
- A size rule in the instruction file: about 100 lines, split past 400.
- Tests and a self-review before the agent hands over, with a Stop hook as the backstop.
- A pull request template that asks for evidence and for what was left out.
- Required checks plus an AI first pass that comments; a person approves.
- CODEOWNERS on risky paths, and one approval from anyone elsewhere.
- Time to first review and size, checked weekly.
Agents made writing code cheap. Reading it is where the time goes now, so that is the part worth making cheaper.