A pull request workflow for code written by agents

By

Updated

Tagged: Git

Review agent-written code with a practical pull request workflow: focused tests, independent review, human approval, merge queues, and deployment checks.

When coding agents can spin up several changes while you’re busy doing something else, code review quickly becomes the bottleneck.

Piling up more pull requests just shifts the work onto your plate. You need a clear way to tell which changes deserve your eyes, what your tests cover, and which commit is safe to ship.

The Claude Code team wrote about how it reviews code at Anthropic. They mix agent reviews with automated tests, human approvals tied to risk, and a merge queue that tests changes together before they land.

You don’t need a big company setup to borrow the good parts of that. Below are two practical workflows you can run in a normal GitHub repository.

Start with a change you can review

Hand an agent a vague task like “fix password reset” and it’ll start guessing. Should tokens expire faster? Should requesting a new link kill the old one? Do existing sessions stay logged in after a password change?

Spell out the exact behavior you want before any code gets written. Say you narrow this down to two rules: reject expired tokens, and stop any token from being used twice. Leave the email template and session policy alone.

Put that scope right in the pull request description, too. Without it, a reviewer can look at clean code and approve the wrong fix.

Have the author (human or agent) fill in four things on every PR:

  • What was broken and how to reproduce it.
  • What changes after the patch.
  • Which checks ran and what they tested.
  • Anything that hasn’t been verified yet, plus how to roll it back.

Keep cleanup out of the diff. Renaming the auth module in the same PR as a token-expiration fix just buries the bug fix in noise.

If you want a quick refresher on branches and merging, the free Git course covers the fundamentals.

Workflow 1: agents prepare pull requests

Have the agent build the reset-token fix as a small patch, and make sure it verifies the behavior before opening the PR.

That means testing four things: an expired token fails, a valid token updates the password, reusing that same token fails, and two concurrent requests with the same token only let one through. Run a quick browser check too so you know the error state leaves the user on a sensible screen. Seeing “all tests passed” doesn’t help much when the suite only tests some unrelated helper.

Add a regression test and run it before applying the fix. If it passes on the broken code, it’s not testing the bug. A test that only checks for an error response can pass because the database connection failed, not because the token was rejected.

Next, hand the diff to a fresh reviewer agent. Give it the original task and ask for concrete bugs with a file path and line number for every issue it reports.

On a password reset flow, tell the reviewer to trace the token end to end: creation, storage, expiration, and consumption. Looking only at the diff hides bad assumptions sitting in the callers.

Fig 1 · 1/4Review the revision that will merge
The agent prepares and checks a small change

Give the reviewer something specific to investigate

A fresh reviewer doesn’t carry the author’s conversation history or blind spots, which helps a lot. You still need to hand it the task description, your project rules, and read access to the surrounding files. Two agents can easily make the same mistake, so a thumbs-up only counts when it comes with real evidence.

For our password reset example, you can prompt the reviewer like this:

Review this pull request against the stated requirement: expired reset tokens must fail, and a successful reset must consume the token. Read the callers and storage code too. Look for concrete failures, including two requests using the same token at once. For each finding, give the file and line, the conditions that trigger it, and the resulting behavior. Separate bugs introduced here from existing problems. Say when you found no actionable issues.

Think about the race condition here. If the code checks whether a token is unused, updates the password, and then marks the token as consumed, two simultaneous requests can both get past that first check. You want the reviewer looking at the storage layer to see if the database prevents that.

A good review comment walks through that exact sequence. Writing “this may have a race condition” just sends the author on a treasure hunt.

Clear up every finding before you ask for a merge. If the reviewer flags a false positive, write down why you dismissed it so the next person reading the PR can follow your reasoning. And treat an agent’s sign-off as supporting evidence, not a replacement for a human approval slot.

Keep review from becoming an endless rewrite

When a reviewer catches a real bug, fix the root cause, add a test for it, and re-check the parts of the flow it touches. When a finding is wrong, note why (maybe the database query already consumes the token atomically) and move on.

Don’t let two agents ping-pong rewrites back and forth forever. Set a stopping rule: after a few failed rounds, pause and look at the approach yourself. Repeated review comments usually point to a fuzzy requirement or a patch that’s trying to do too much at once.

Anthropic ran into the same loop. Their team capped the number of review rounds and narrowed later passes to focus on the new commits instead of re-auditing the whole diff. Once a pass comes back clean, let the PR move on instead of nudging the reviewer to invent another nitpick.

Here’s how that bounded review loop runs:

Decide what to do with a review findingA concrete bug needs a fix, a focused check, and review of the affected behavior. A false positive needs a recorded explanation. Once all findings are resolved, the change is ready for the merge decision.YesNoReview findingConcrete bug?Fix causeand add a checkReview fix andaffected behaviorResolve all findingsRecord why it isa false positiveReady for themerge decision

Give sensitive changes a human owner

In a small repo, start by putting a human reviewer in front of anything touching user data, authentication, payments, or deployment permissions. A copy fix doesn’t need the same friction.

Anthropic splits changes into risk tiers with protected paths, and ties every approval to a specific commit so new pushes need a fresh sign-off. That commit-level rule is worth copying right away.

Double-check what GitHub enforces in your repo settings. Branch protection lets you require reviews and status checks, and automatically dismiss stale approvals whenever new commits arrive. Check who has bypass permissions while you’re in there.

For a password reset change, require the reset-flow checks and a human approval, and turn on stale-review dismissal so late edits can’t sneak past an old sign-off. If you use code owners, require their review on sensitive paths. GitHub also has a setting that requires someone other than the last pusher to approve the most recent reviewable push.

Required checks confirm CI passed, and required approvals confirm someone signed off. Even with both turned on, the reviewer still needs to look at the tests and make sure they cover the right behavior.

If you tag changes as “low risk”, confirm you have a rule that reads that label instead of letting it sit there for decoration. Automated classifiers are handy for routing PRs, and any edit to the classifier or CI workflow itself should go through human review too.

Test the integrated revision

Two branches can both pass CI on their own and still break the moment they merge. One PR changes a function’s return shape while another adds a new caller expecting the old shape.

GitHub’s merge queue catches that by building a temporary branch with the target branch plus the queued PRs, then running your checks against the combined result.

If you’re new to CI, the GitHub Actions guide walks through how workflows and required checks fit together.

On GitHub Actions, any required workflow needs to listen for the merge_group event. If a workflow only triggers on pull requests, the merge queue will sit there waiting for a status check that never runs. You can check the details in GitHub’s workflow events reference.

In an existing workflow file, include both events in the trigger block:

on:
  pull_request:
  merge_group:
    types: [checks_requested]

That snippet only covers the trigger block. Keep your build and test jobs below it, and verify they report the exact status checks your branch protection rules require, or the queue will stay stuck.

Merge queues depend on your repository type and GitHub plan. If you don’t have access to them, merge one branch at a time: update your branch with the latest main, run the required checks on that updated commit, and merge before anything else lands in between.

Workflow 2: one owner integrates directly

On a solo project where you’re working on one change at a time, opening a PR for yourself often adds friction without much payoff. Review the local diff, click through the changed flow, run your focused tests, and commit straight to main.

A few guardrails keep this safe. Don’t let multiple unattended agents push competing edits to the same branch. Stay in charge of the final push, let CI run on that commit, and deploy the exact commit that passed CI instead of whatever happens to be at HEAD when a separate deploy job kicks off.

That lighter loop fits a solo repo well. Once you have a shared codebase with multiple contributors (or parallel agents), switching to pull requests, explicit approvals, and a merge queue starts paying for itself.

Which workflow would I choose?

For a personal project with one active change at a time, stick with direct commits to main until you hit a real reason to introduce pull requests. Once work passes between people, or several agents are opening changes in parallel, move to PRs so every change has its own review trail.

SituationStarting point
One owner, one change at a timeLocal review, focused checks, then a controlled push
Several changes waiting for reviewSmall PRs with evidence attached to each revision
Changes frequently collide on a busy branchRequired integration checks through a merge queue
Authentication or a destructive data migrationHuman review of behavior and recovery, whichever route carries the code

Diff size only tells you how long it’ll take to read the code. Risk comes from what the code does: a one-line permission change deserves far more care than a massive docs update. I dig into that same distinction in Proton’s AI manifesto and what it means to lead coding agents, including the argument for dropping most human code review.

Make the merge evidence easy to find

Whichever workflow you pick, keep the test results tied to the exact commit you reviewed, right next to the original task description. If a browser check relied on specific test data, write down the scenario. Leaving the review findings attached to the change helps whoever looks at it six months later understand why you shipped it that way.

Plan how you’ll spot a failure after deploy, too. Reverting a commit restores your code, but it won’t unsend a bad password-reset email or undo a destructive data migration.

After deploying a reset-token fix, test it with a test account right away: try a fresh link, confirm an expired link fails, and make sure reusing a consumed link fails as well. Keep an eye on error logs for the reset endpoint so you catch breakage before a customer emails you.

Put your repeatable rules in AGENTS.md so agents know which checks to run and which paths need human sign-off. Then turn on branch protection in your GitHub repository settings so nothing can merge without meeting those requirements.

Want me to talk about your product? You can sponsor this site.

Related posts about git: