How to review an AI-generated pull request
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
- 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.
- 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.
- Read every deletion. Removed
ifstatements, early returns,throws, andwhereclauses deserve a reason. - Check trust boundaries by hand. Authentication, ownership and tenant checks, permission logic, input validation, and anything that touches secrets.
- 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.
- 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.
| Pattern | Why it slips through | What to check |
|---|---|---|
| Dropped ownership check | A 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 fallback | A catch block returning an empty list makes errors look like “no data”. | Every new try/catch: is the failure logged, surfaced, or hidden? |
| Invented option | A plausible config flag or API parameter that the library silently ignores. | Look up any unfamiliar option in the library’s actual documentation. |
| Scope creep | A “small fix” that reformats or refactors unrelated files hides the real change. | Ask for unrelated changes to be split out before reviewing. |
| Quiet rule change | A business constant changes, and its test is updated to match. | Compare against the written requirement, not against the updated test. |
A reviewer 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 ownerWhere 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.
Related guides
How to verify AI-generated code before it ships
A tool-agnostic process for verifying code from Claude Code, Cursor, Copilot, or Codex: keep the spec outside the tests, target risk, and test the tests.
GUIDEWhy AI coding agents change tests to make them pass
Why Claude Code, Cursor, and other coding agents edit, weaken, or skip tests to get a green run, how to spot it in a diff, and five controls that stop it.
GUIDEAI code review tools vs. verification: what each one catches
AI review bots, static analysis, tests, mutation testing, and independent verification compared: what each catches in AI-generated code and what it misses.
GUIDEMutation testing in TypeScript and JavaScript
What mutation testing is, how to read a mutation score, running StrykerJS with Jest or Vitest, and mutation-testing only the code an AI just changed.
Last updated