Guide / Code review

How to review an AI-generated pull request

Short answer

Review an AI-generated pull request starting from the requirement, not the diff. Restate what behavior should change, review test edits before code edits, read every removed guard, check trust boundaries such as authorization and input validation by hand, confirm new dependencies exist, and approve on reproducible evidence rather than the agent’s summary.

What’s different about reviewing AI-written code

Reviewing a colleague’s pull request relies on things that do not hold for a coding agent. A colleague usually knows the product rules, writes tests separately from the fix, and tells you when they are unsure. An agent produces more code, faster, in a uniformly confident style, and its pull request description is a claim about what it did, not evidence that it did it.

Three habits change as a result:

  • Read what was removed as carefully as what was added. Agents simplify aggressively, and a deleted line is often a deleted safety check.
  • Treat test changes as behavior changes. If the tests moved, the definition of correct moved with them.
  • Verify, don’t trust, the summary. “All tests pass” and “no breaking changes” are statements to check, not conclusions to accept.

The review order that catches the most

  1. Restate the intent. In one sentence, write what behavior this pull request should change and what it must not change. If you cannot, the agent could not either.
  2. Review the tests first. Look for changed expected values, weakened assertions, new skips, deleted cases, and mocks of the code under test. See how agents change tests to make them pass.
  3. Read every deletion. Removed if statements, early returns, throws, and where clauses deserve a reason.
  4. Check trust boundaries by hand. Authentication, ownership and tenant checks, permission logic, input validation, and anything that touches secrets.
  5. Confirm new dependencies are real. A study of 16 code-generating models found average hallucinated-package rates of at least 5.2% for commercial models and 21.7% for open-source models. Attackers register those invented names, a technique called slopsquatting.
  6. Require evidence. A link to a CI run of the relevant tests, and for critical paths, a mutation report showing those tests catch real breakage.

Failure patterns that look correct

These pass a quick read because the code is clean and idiomatic. They are wrong because of what the code no longer does.

Common AI pull request defects and how to catch them
PatternWhy it slips throughWhat to check
Dropped ownership checkA query by ID still returns the right record in every happy-path test.Does every lookup still filter by the current user, account, or tenant?
Boundary shift< becoming <= changes one edge case no test covers.Limits, quotas, pagination, and date ranges at exactly the boundary value.
Silent fallbackA catch block returning an empty list makes errors look like “no data”.Every new try/catch: is the failure logged, surfaced, or hidden?
Invented optionA plausible config flag or API parameter that the library silently ignores.Look up any unfamiliar option in the library’s actual documentation.
Scope creepA “small fix” that reformats or refactors unrelated files hides the real change.Ask for unrelated changes to be split out before reviewing.
Quiet rule changeA business constant changes, and its test is updated to match.Compare against the written requirement, not against the updated test.

A reviewer checklist

Review checklist
[ ] I can state in one sentence what behavior this PR changes
[ ] Test diffs reviewed first; no unexplained expected-value changes
[ ] No new .skip / .only / deleted test cases
[ ] Every removed guard, condition, or throw has a reason
[ ] Auth, ownership, and permission checks still apply on every path
[ ] New dependencies exist, are maintained, and are the intended package
[ ] Unfamiliar APIs and options checked against real documentation
[ ] Relevant tests ran in CI (not just "the agent said so")
[ ] Critical paths have a mutation check or equivalent evidence
[ ] Any intended behavior change is approved by its owner

Where AI review bots and verification fit

AI code review bots are a useful first pass. They catch typos, obvious bugs, and missing error handling quickly. But they read the same diff the coding agent produced and have no record of what the product promised, so they cannot tell an intended rule change from an accidental one. The comparison of review tools and verification covers which layer catches what.

For the parts of this checklist that can be automated, MaruCheck checks the diff against reviewed requirements, runs only the linked tests, detects behavior drift, runs mutation checks on changed code, and posts a ship-or-block decision from a least-privilege GitHub Actions workflow. The reviewer still owns the decision; the evidence just arrives with the pull request.

Frequently asked questions

How should I review an AI-generated pull request?
Start from the requirement, not the diff. Confirm what behavior the pull request was meant to change, review test changes before implementation changes, read every removed guard and condition, check authorization and data-access paths by hand, and require reproducible test evidence rather than the author's or agent's summary of what it did.
What should I look at first in an AI-written pull request?
Review the tests first. If the tests were changed to fit the new code, the rest of the review is built on a moving baseline. Changed expected values, deleted cases, and new mocks tell you what the AI decided the correct behavior is, which is the decision a human most needs to confirm.
Can an AI code reviewer approve AI-generated code?
AI review bots are useful for catching style issues, obvious bugs, and missing error handling, but they read the same diff the coding agent produced and have no independent record of what the product promised. Use them as a first pass, not as the approval. A human or an independent check should own behavior changes.

Last updated