--- title: "How to Review AI-Generated Code: A Checklist for Teams" author: "Shobit Singh" published: "2026-11-20T08:48:39.011Z" updated: "2026-11-20T08:48:39.011Z" url: "https://zyvop.com/how-to-review-ai-generated-code-a-checklist-for-teams-wkwyj" canonical: "https://zyvop.com/how-to-review-ai-generated-code-a-checklist-for-teams-wkwyj" tags: ["security","team workflow","AI coding","software quality","code-review"] --- # How to Review AI-Generated Code: A Checklist for Teams A practical checklist for reviewing code written by AI assistants: what to check, what to automate, and the team rules that keep quality high. ![Cover image]() > AI assistants can now write a working feature in minutes. The hard part has moved to the other side: someone has to decide whether that code is correct, safe, and something the team wants to maintain. Reviewing AI-generated code isn't a different discipline from normal code review, but it changes where mistakes hide. The code is fluent and confident, and it usually compiles and passes a quick test. That makes problems easier to miss. This post gives you a practical checklist, a few team rules that make reviews work, and Node.js examples of what to catch. It applies whichever tool wrote the code. ## Why AI-generated code needs extra attention A few patterns come up again and again: - **It looks right.** Clean formatting and confident naming create a false sense of correctness, and reviewers tend to skim code that reads well. - **It lacks your context.** The model doesn't know your domain rules, past incidents, internal libraries, or why a strange-looking workaround exists. - **It can invent things.** That includes functions, config options, and even whole packages that don't exist. - **It misses security more often than you'd like.** Security tests of AI-written code keep finding a large share of vulnerable output. - **There's a lot of it.** Output is cheap, so diffs get bigger and review becomes the bottleneck. The package problem is worth spelling out. A study of 16 code-generating LLMs found that the average share of hallucinated packages was at least 5.2% for commercial models and 21.7% for open-source models. Attackers can register those made-up names and put malware behind them. The models in that study are older now and current rates will differ, but verifying a dependency takes seconds. On security, Veracode's 2025 report found vulnerabilities in 45% of its test cases, and its July 2026 report put the figure at about 44%. An update reported in October 2026 found 38%, which Veracode described as its first meaningful improvement since the study began. That's progress, but it's still more than one in three. These are vendor-run tests on specific coding tasks, and the test sets differ between reports, so treat the exact numbers as a rough guide. The direction is what matters: AI-written code needs the same scrutiny as any other untrusted input. ## Ground rules before you review A checklist only works if the team around it does too. 1. **The author owns the code.** Whoever opens the pull request is accountable, whether they typed it or prompted it. They should read and understand every line before asking anyone else to. 2. **Keep changes small.** AI makes 800-line diffs easy to produce. Ask for smaller pull requests, because nobody reviews a huge diff well. 3. **Say when AI was used.** This isn't about blame. It tells reviewers where to look harder. One line in the PR template is enough. 4. **Let automation do the boring work.** Formatting, linting, type checks, tests, dependency audits, and security scans should run in CI so humans can focus on judgment. 5. **Protect sensitive areas.** Authentication, payments, cryptography, database migrations, and infrastructure should always need review from the people who own them. Here's how those pieces fit together: ```mermaid flowchart LR A["AI generates code"] --> B["Author reads and tests it"] B --> C["CI checks: lint, types, tests, security scans"] C -->|pass| D["Human review with checklist"] C -->|fail| B D -->|changes requested| B D -->|approved| E["Merge"] ``` ## The checklist Copy this into your PR template or review guide. Not every item applies to every change. ### 1\. Intent and scope - The change solves the problem in the ticket or spec, and nothing more. - There are no unrelated edits: refactors, renamed variables, reformatted files, or deleted comments. - The approach is one the team would have chosen, not just one that happens to work. - Any removed or changed behavior is intentional and explained. ### 2\. Correctness - The logic matches the business rules, not just the happy path. - Edge cases are handled: empty input, `null` or `undefined`, very large input, Unicode, time zones, duplicates. - Failure paths are handled: timeouts, retries, partial failures. - Concurrency is considered: races, double submits, idempotency. - There's no placeholder code: TODOs, stubbed functions, or hardcoded sample data. - Nothing special-cases the test inputs to make tests pass. ### 3\. Hallucinated APIs and dependencies - Every function, method, option, and config key exists in the version you actually use. - No deprecated or removed APIs are used. - Each new dependency exists, is the package that was intended (watch for lookalike names), is maintained, and has a compatible license. - Each new dependency is really needed. The standard library or an existing dependency might already cover it. - Lockfile changes match the dependency changes you expect. Don't trust that code is right because it reads well. Check it against the docs or type definitions, and run it. For a new npm package, `npm view ` shows the maintainers and when it was last published, and `npm view repository.url` shows where the source lives. That's a quick sanity check. ### 4\. Security - Input is validated at trust boundaries. - Authorization is checked on every access path, not just authentication. - There's no injection risk: SQL, shell commands, templates, XSS, or log injection. - No secrets, tokens, or credentials appear in code, logs, or test fixtures. - Cryptography uses vetted libraries: no home-grown crypto, MD5 or SHA-1 for passwords, or `Math.random()` for tokens. - Error messages don't leak internals. - File paths, URLs, and redirects built from user input are constrained, to prevent path traversal, SSRF, and open redirects. Veracode's latest tests found models getting better at cross-site scripting but still struggling with flaws that depend on data flowing across several functions, such as log injection. Those are exactly the bugs that are hard to spot in a quick read, so slow down on them. ### 5\. Tests - Tests assert behavior, not implementation details. - Tests fail when the code is wrong. Temporarily break the logic and confirm. - Edge cases and failure paths have tests. - No tests were deleted, skipped, loosened, or rewritten to match new behavior. - Mocks don't hide the thing being tested. ### 6\. Design and maintainability - The code follows the codebase's conventions and architecture. - It reuses existing helpers instead of reinventing them. - Nothing looks copied wholesale from another project, which could carry license obligations. - There are no unnecessary abstractions, layers, or settings for a simple need. - Names and comments explain intent. Comments don't just restate the code. - A teammate could explain and change this in six months. ### 7\. Performance and operations - There are no N+1 queries, unbounded loops, or whole datasets loaded into memory. - Network and database calls have timeouts, and retries have limits and backoff. - List endpoints have pagination or limits. - Nothing blocks the Node.js event loop, such as synchronous file reads or heavy CPU work. - Logs are useful and free of sensitive data. - Migrations are safe and reversible, and configuration comes from the environment. ## What to catch: an example Here's an endpoint that might come out of a quick prompt. It works, and a manual test would pass: ```javascript app.get("/users/:id/orders", async (req, res) => { const { rows } = await db.query( `SELECT * FROM orders WHERE user_id = '${req.params.id}'` ); res.json(rows); }); ``` It has several problems: - **SQL injection.** The ID is interpolated straight into the query. - **Broken access control.** There's no authentication or ownership check, so any caller can read anyone's orders. - **Over-exposure.** `SELECT *` returns every column, including internal ones. - **Missing error handling.** In Express 4, a failed query in an async handler never reaches your error handler, and the request hangs. Express 5 forwards the error for you, so check which version you're on. Here's a safer version: ```javascript app.get("/users/:id/orders", requireAuth, async (req, res, next) => { try { // ids are UUID strings in this example if (req.user.id !== req.params.id && !req.user.isAdmin) { return res.status(403).json({ error: "Forbidden" }); } const { rows } = await db.query( "SELECT id, status, total, created_at FROM orders WHERE user_id = $1", [req.params.id] ); res.json(rows); } catch (err) { next(err); } }); ``` Nothing in the first version would fail a happy-path test. That's the pattern to look for: code that behaves correctly for the expected input and badly for everything else. Tests deserve the same suspicion. AI-written tests often repeat the implementation, so they can only ever agree with it: ```javascript // Weak: the test re-implements the logic it is checking test("applies a discount", () => { const price = 100; expect(applyDiscount(price, 0.25)).toBe(price - price * 0.25); }); // Better: concrete expected values, including edge cases test.each([ [100, 0.25, 75], [100, 0, 100], [0, 0.5, 0], ])("applyDiscount(%d, %d) returns %d", (price, rate, expected) => { expect(applyDiscount(price, rate)).toBe(expected); }); ``` If the implementation and the test share the same mistake, the test still passes. ## Review techniques that work - **Read the tests first.** They show what the author believes the code does. - **Review in layers.** Start with whether it's the right problem and the right design. Then check the logic. Leave style for last. - **Run it.** Check out the branch and try bad input. Reading alone misses things. - **Ask the author to explain.** If they can't explain a block, it isn't ready. "Why this approach?" is a fair question. - **Break it on purpose.** Flip a condition or remove a check and see whether a test fails. - **Watch your own fatigue.** Long AI-generated diffs invite rubber-stamping. If a change is too big to review properly, say so and ask for it to be split. - **Use AI as a first pass, not the last.** An AI reviewer can catch typos and missing null checks, but it shares blind spots with the model that wrote the code and doesn't know your context. A human makes the call. ## Red flags at a glance Some signs deserve a closer look before you read a single line: - A large diff for a small task - Files changed that the ticket never mentioned - Tests changed or removed in the same PR as the code they cover - A new dependency for something trivial - `catch` blocks that swallow errors - Hardcoded values that match the test data - Placeholder comments such as "implement later" - Code in a different style from the rest of the file ## Make it easy: a PR template A template turns the checklist into a habit. Here's a short one to start from: ```markdown ## AI assistance - [ ] No AI used - [ ] AI used (tool: ______). What I asked it to do: ______ ## Author checklist - [ ] I read every line of this diff and can explain it - [ ] I ran it locally and tried edge cases and bad input - [ ] Tests fail when I break the behavior they cover - [ ] New dependencies are verified (exist, maintained, licensed, needed) - [ ] No secrets or customer data in code, logs, or prompts - [ ] No unrelated changes ``` ## Team policies that help - **Require CI to pass** before human review starts. Linting, type checks, tests, dependency audits, and security scans should all be in the pipeline. - **Use code owners for sensitive paths.** On GitHub, a `CODEOWNERS` file plus branch protection can require approval from the owners of the files a pull request touches. - **Agree on extra-scrutiny areas.** Authentication, payments, cryptography, migrations, and infrastructure changes deserve a second pair of eyes. - **Set a rule for prompts.** Don't paste secrets or customer data into AI tools. - **Learn from misses.** When an AI-written bug reaches production, add the lesson to the checklist. ## Key takeaways - Treat AI-generated code as untrusted input: read it, run it, and test it before it merges. - The author owns the change, no matter who or what wrote it. - Watch for hallucinated APIs and packages, missing authorization, weak tests, and unrelated edits. - Keep pull requests small and automate everything a machine can check. - Use AI as a first-pass reviewer if you like, but keep a human accountable for the final decision. - A short, shared checklist in the PR template beats an unwritten set of expectations. ## Further reading - Google Engineering Practices, [Code Review Developer Guide](). A widely used description of what reviewers should look for, including design, functionality, tests, and complexity. - Spracklen et al., ["We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs"](). The study behind the package hallucination figures above. - Veracode, [2025 GenAI Code Security Report announcement](), and TechRadar's coverage of the [October 2026 update](). - OWASP, [Top 10 Web Application Security Risks](). A starting point for the security items in the checklist. - GitHub docs, [About code owners](). How to require review from the people who own sensitive code.