Reviewing AI-Generated Code: A Human-in-the-Loop Checklist
Reviewing AI-generated code before merge: a practical checklist for correctness, security, tests, dependencies and hallucinated APIs, so AI speed stays safe.
By Victor Sanchez
The pull request looks great. The code compiles, the tests are green, the description is tidy and the variable names are better than ours. That is exactly why reviewing AI-generated code is hard: it looks finished. In our experience the bugs hide in places that a confident, well-formatted diff makes easy to skip. This is the checklist we use before any AI-written change is merged.
Why does AI-generated code need a different review?
Reviewing a colleague's code, you can lean on context: you know how they work, what they usually miss, and you can ask why they did something. An agent has no memory of your last incident, no stake in the outcome, and it will explain a wrong decision as fluently as a right one. Some failure modes are specific to it, whichever of the AI coding tools you use:
- Plausible but wrong. The code matches the shape of a correct solution but misses an edge case or a business rule that was never written down.
- Hallucinated APIs. A method, option or package that does not exist, or existed in a different version.
- Scope creep. The agent "improves" files you did not ask it to touch.
- Tests that test nothing. Tests written to pass against the implementation, not to check the requirement.
- Silent dependency changes. A new package, a version bump or a changed lockfile.
Our rule is simple: AI executes, the human reviews, and the human who approves owns the change as if they had written it.
How to review AI-generated code, step by step
1. Check the size and scope first
Before reading any line, look at what changed:
git diff --stat main...HEAD
git diff --name-only main...HEAD
If files outside the task appear, ask why or revert them. If the diff is too large to review carefully in one sitting, split it. A small diff reviewed well beats a large diff skimmed.
2. Re-read the requirement, then the code
Read the ticket again before the diff. Then check that the change does what the ticket asks, and nothing else. Look at the boundaries: empty inputs, nulls, time zones, rounding, permissions, concurrency. These are the cases agents skip most often in our experience.
3. Verify every API you do not recognize
When you see a method or option you have not used before, open the official docs or the library source. Do not ask the same model whether it exists. Compiling is not enough in dynamic languages, and even in typed languages an overload can exist with different semantics than the agent assumed.
4. Inspect dependencies
Any change to package.json, a .csproj or a lockfile gets its own review. Confirm the package is the one you think it is (names can be typosquatted), that it is maintained, and that it has no known vulnerabilities (more in our post on outdated and compromised packages):
npm view <package> repository.url time.modified
npm audit
dotnet list package --vulnerable --include-transitive
5. Review security like an attacker
Look for string-built SQL, missing authorization checks, secrets in code or logs, unvalidated input reaching the file system or a shell, overly broad CORS, and disabled certificate checks. Agents tend to reach for the shortest working path, and the shortest path is often the insecure one. Our pull request security checklist mapped to the OWASP Top 10 goes category by category.
6. Read the tests as critically as the code
Ask: would this test fail if the feature were broken? Delete or break the key line of the implementation locally and run the test. If it still passes, it is not testing the requirement. Check for mocks that replace the very thing under test.
7. Run it yourself
Pull the branch, build it and exercise the change: the UI flow, the endpoint, the migration on a copy of the data. Green CI is necessary, not sufficient.
8. Sign off with ownership
The approver must be able to explain the change without the AI's help. If you cannot, you are not done reviewing.
Common pitfalls when reviewing AI code
- Reviewing the summary instead of the diff. The agent's description of its change is a claim, not evidence.
- Asking the same model to review its own work and stopping there. It can help, especially with a different model or a fresh session, but it does not replace a human.
- Rubber-stamping because the tests pass. AI-written tests often share the same misunderstanding as the AI-written code.
- Accepting large refactors "while it was there". Unrequested changes hide the requested ones.
- Review fatigue. If agents produce more pull requests than the team can review properly, the fix is fewer pull requests, not faster reviews.
The AI code review checklist
- Scope: only files related to the task changed; the diff is small enough to review properly.
- Correctness: the requirement is met, including edge cases and business rules.
- APIs: every unfamiliar method, option and flag verified in official docs.
- Dependencies: new or bumped packages are legitimate, maintained and free of known vulnerabilities.
- Security: input validation, authorization, parameterized queries, no secrets, safe error messages.
- Tests: they fail when the feature is broken; mocks do not hide the behavior under test.
- Behavior: run locally or in a preview, not just in CI.
- Readability: it follows the project's conventions and someone new could maintain it.
- Ownership: the approver can explain the change without the AI.
Key takeaways
- AI-generated code fails in specific ways: plausible logic, hallucinated APIs, scope creep, weak tests and silent dependency changes.
- Start the review with the size and scope of the diff, then the requirement, then the code.
- Verify unfamiliar APIs and packages against official sources, never against the same model.
- The person who approves the pull request owns it. That rule is what makes AI speed safe.
Sources
Need help reviewing AI-generated code?
Santhor builds software from scratch and upgrades existing projects using AI-assisted workflows with senior human review. We also help teams set up these tools safely: skills, persistent memory and review processes that keep quality up. We are based in Costa Rica and work nearshore with teams in the U.S. and Latin America. Tell us about your project