On this page9 sections
- 01Why AI code needs a different kind of review
- 02Step one: review the intent before the diff
- 03Step two: run it before you read it
- 04Step three: triage the diff by risk
- 05The AI failure patterns to hunt for
- 06Let tools do the boring reading
- 07Ask a second model to be the skeptic
- 08A review checklist you can reuse
- 09FAQ
The fastest safe way to review AI-written code is to review by risk, not by line. Confirm the change does what you asked, run it, read the dangerous parts closely, and let automated tools read the rest. Reading every line of a 900-line diff with equal care is how reviewers get tired and miss the one line that matters.
This guide gives you a repeatable method, the failure patterns AI code shows most, and a checklist you can use today.
- Start with intent: ask the agent to explain what it changed and why, then compare that to what you asked for.
- Run the code before you read it. Passing tests and a working screen answer half your questions.
- Sort the diff into risk levels and spend your attention on the red parts.
- Let linters, type checkers and security scanners do the tedious reading.
- Watch for classic AI mistakes: invented APIs, weakened tests, swallowed errors and new dependencies.
Why AI code needs a different kind of review
Human code review grew up around people who write a little code slowly. Coding agents turn that around. They produce a lot of code quickly, and it almost always looks tidy, which makes it easy to trust.
The data says that trust should be earned. Veracode tested code from more than 150 language models and found that tidy is not the same as safe:
Code that compiles and reads well can still be wrong in ways a quick skim will not catch. The answer is not to read slower. It is to read smarter.
Step one: review the intent before the diff
Before you open a single file, ask the agent for a short summary. You want to know what it changed, why, and what it chose not to do. Then compare that summary with your original request.
Before I review, summarize this change for me: 1. What problem it solves, in one sentence. 2. Every file you changed and why, one line each. 3. Anything you changed that I did not ask for. 4. Assumptions you made, and what would break if they are wrong. 5. How you tested it, and what you did not test.
Point three is the one to read twice. Agents like to be helpful, and “helpful” sometimes means renaming a function you depend on or rewriting a file you did not mention. Unrequested changes are where surprises hide.
Step two: run it before you read it
Reading code to find out whether it works is slow. Running it is fast. Do the cheap checks first:
Run the test suite
All tests should pass. If the agent added tests, run them against the old code too. A test that passes either way proves nothing.
Use the feature like a user would
Click through the main path once. Then try one unhappy path: an empty form, a wrong password, a slow network. Agents often build the happy path well and skip the rest.
Look at what changed on disk
Check for new files you did not expect, such as lockfile churn, generated files, a stray
.envor debug logs.
If any of these fail, stop and send it back. There is no point reviewing logic that does not run.
Step three: triage the diff by risk
Not every line deserves the same attention. Sort the changed files into three buckets before you read closely.
| Risk | What lives there | How to review |
|---|---|---|
| Red | Login and permissions, payments, deleting data, database migrations, anything touching secrets or user input | Read every line. Ask why for anything clever. |
| Amber | Business logic, public APIs, shared helpers, configuration | Read the logic and the edge cases. Skim the plumbing. |
| Green | Styling, copy, new tests, internal refactors covered by tests | Skim, and trust the tools and the tests. |
This is how senior engineers review large changes. The goal is to put your full attention where a mistake would hurt a user or leak data.
The AI failure patterns to hunt for
Coding agents make a recognizable set of mistakes. Knowing them turns review into a search rather than a slog.
Invented APIs. A function, option or package that sounds right but does not exist, or does not exist in your version.
Weakened tests. An assertion removed, a test skipped, or an expected value changed to match the new output.
Swallowed errors. A broad
tryandcatchthat logs nothing and returns a default, so failures become silent.New dependencies. A package added for something a few lines of code would do. Check that it is real and maintained, because attackers register names that AI tends to invent.
Duplicated helpers. A fresh utility that already exists elsewhere in your codebase under another name.
Hardcoded values. Keys, URLs, IDs or limits pasted inline instead of read from configuration.
Quiet scope creep. Formatting changes across whole files, which hide the real change inside noise.
Let tools do the boring reading
Humans are bad at spotting a missing null check on line 640. Tools are great at it. Before you review, make sure these ran and came back clean:
# Types and lint (JavaScript or TypeScript projects)
npx tsc --noEmit
npx eslint .
# Known vulnerabilities in dependencies
npm audit --omit=dev
# A quick look for secrets (a real scanner such as gitleaks catches more)
git diff --cached | grep -nE "(api[_-]?key|secret|token)\s*[:=]"Your project may use different commands, and that is fine. The principle is the same in every language: types, lint, tests, dependency audit and secret scanning run first, automatically, ideally in CI. Your human review then starts from a clean baseline. Dedicated AI code review tools now bundle many of these checks into one pass, if you would rather not wire them up yourself.
Ask a second model to be the skeptic
A useful trick is to ask a different model, or a fresh session, to review the diff with an adversarial brief. It does not replace your review, but it often finds the thing you were too close to see.
You are a skeptical senior engineer reviewing this diff before it ships to production. List only real problems, most severe first. For each one give the file and line, what goes wrong, and a concrete input that triggers it. Focus on: security, data loss, error handling, edge cases, concurrency, and tests that no longer test anything. Do not comment on style. If you find nothing serious, say so.
Treat its findings as leads, not verdicts. Confirm each one yourself before you act on it.
A review checklist you can reuse
FAQ
Do I really need to review code an AI wrote?
Yes. Studies keep finding security flaws in a large share of AI-generated code, and agents also make ordinary logic mistakes. Review is where you catch both, and it is still your name on the change.
How long should reviewing an AI change take?
It depends on risk, not size. A large change that only touches styling can take minutes. A small change to login or payments deserves a slow, line-by-line read.
Can one AI review another AI’s code?
It helps as a second opinion, especially with a skeptical brief. But models share blind spots, so treat an AI review as input to your decision, not the decision itself.
What should I do if a change is too big to review?
Send it back and ask for smaller steps. Big diffs are hard for people and agents alike. A plan with several small, testable commits is easier to trust. A large migration is the classic example, and our guide to migrating a codebase with AI shows how to break one into reviewable batches.
- Review by risk, not by line count.
- Check intent first, then run the code, then read.
- Spend full attention on auth, money, deletion, migrations, secrets and input handling.
- Hunt for known AI mistakes: invented APIs, weakened tests, swallowed errors, new dependencies.
- Automate the tedious checks so your attention goes where it counts.
Want to go deeper? Read our checklist for securing AI-generated code, learn how tests keep an agent honest, or set up a pair programming workflow that ships.
- Spring 2026 GenAI code security update, Veracode, March 2026
- 2025 GenAI Code Security Report, Veracode
- What to look for in a code review, Google engineering practices
- Secure code review cheat sheet, OWASP
- OWASP Top 10 for large language model applications, OWASP




