Editorial illustration: four-stage engineering review pipeline before merging AI-generated code into production.
Published on October 20, 2026.
AI coding assistants are genuinely great at getting you past a blank file. Whether you are scaffolding an ASP.NET Core controller, writing a quick WordPress filter, or translating a messy bash script into Python, they cut out a lot of boilerplate.
The catch is that fast code generation shifts your job from typing to verification, and verification is where tired developers cut corners. A generated function almost always looks neat, well-commented, and confident—even when it quietly misses an authorisation check, duplicates a helper you already wrote last month, or invents a configuration flag that does not exist in your framework version.
If you are about to merge AI-assisted code into a real repository, here is the review pass that actually catches the expensive mistakes.
Define the contract before reading the diff
The biggest trap in reviewing generated code is reading the diff first. Well-formatted code is persuasive; a tidy method name with docblocks makes an incomplete requirement feel finished.
Before inspecting a single line, write down in plain English what the change must do—and what it must not do. For an invoice download endpoint, that contract might be: “An authenticated user can download a PDF only for an invoice belonging to their own organisation; missing or foreign IDs return 404 without leaking whether the invoice exists.” Having that boundary written down makes scope creep and missing checks jump off the screen immediately.
Read the surrounding codebase, not just the snippet
An AI assistant usually sees only the files you fed into context. It may not know about your custom Result<T> wrapper, your global exception middleware, or the fact that your WordPress theme already sanitises and formats dates in inc/helpers.php.
Check the callers, the database schema, and the config files around the change. Search the repo before accepting a new utility function—two slightly different date or currency formatters living in different folders will drift apart within a month. Ask yourself what silent assumptions the generated code is making about nullability, database transactions, or environment variables, and verify each one in the actual source.
Test the awkward paths that demos skip
Generated code is almost always written for the happy path first. Your job is to throw the awkward edge cases at it:
- Empty,
null, malformed, or unexpectedly huge inputs. - Double-clicks and duplicate webhook deliveries (idempotency).
- Expired, revoked, or already-used tokens.
- A user who is logged in, but does not own the target record (IDOR).
- A third-party API timing out after you already wrote to your local database.
- Timezone boundaries (for example, UTC vs
Asia/Kuala_Lumpur+08:00around midnight when generating daily LHDN or sales reports).
Checking for HTTP 200 is not enough. Make sure the failure paths return the right status code and log useful context without dumping raw stack traces or user secrets.
Do a dedicated pass for trust boundaries
Do not mix your functional review and your security review—do a separate pass specifically tracing untrusted input from where it enters (query string, POST body, uploaded file, webhook header) to where it is used.
Look closely for the classics:
- String-concatenated SQL, shell commands, or raw HTML rendering (
Html.Raw,echowithoutesc_html()). - Missing ownership or capability checks—for example, an AI-generated WordPress AJAX handler that checks
is_user_logged_in()or a nonce, but forgetscurrent_user_can('manage_options'). - Secrets, connection strings, or internal tokens accidentally pasted into test fixtures or logged in error handlers.
- Unvalidated file paths (
../traversal) or open redirects onreturnUrlparameters. - Overly permissive CORS headers (
Access-Control-Allow-Origin: *paired with credentials) or catastrophic regexes that can stall the thread.
Never trust a comment that says // Input is sanitised above—follow the variable and verify the actual validation or parameterised query.
Audit new packages and permissions
A small prompt can quietly add a heavy dependency. Always inspect package.json, composer.json, .csproj, and the lockfile diff (git diff --stat), not just the source file. Ask whether the library is actively maintained, whether its license fits your project, and whether your standard library or an existing package already solves the problem in ten lines.
Watch IAM roles, Dockerfiles, and GitHub Actions permissions just as closely. AI tools love generating chmod 777, AdministratorAccess, or overly broad permissions: write-all YAML blocks because they make tutorials work on the first try. Trim every permission down to the minimum required.
Match the repository’s existing shape
Code that works in isolation can still make a codebase harder to live in. Check naming conventions, error-handling style, logging format, and folder structure.
AI assistants have a habit of over-engineering simple tasks into a UserNotificationManagerFactory when your project just uses plain service methods—or, at the other extreme, stuffing validation, SQL, and HTML rendering into one 180-line controller action. Refactor the diff into the smallest, clearest shape that fits the rest of your repo.
Treat passing tests as a baseline, not proof
If you asked the same AI tool to write both the implementation and the unit tests, be extra skeptical. A generated test suite can easily mirror the exact same wrong assumption as the implementation, or mock away the database and auth middleware so completely that the test passes even when the real query crashes.
Read the assertions. Does the test actually fail if you break the core logic? For security-critical code, always write negative tests too: verify that an unauthorised user gets 403/404, an invalid signature is rejected, and sensitive fields are absent from JSON responses. Then run your project’s linter, type checker, and integration suite.
Prompt the model to poke holes in its own output
Once you have read the diff yourself, you can use the AI tool as an adversarial reviewer instead of a yes-man. Specific prompts work far better than “Is this code good?”:
- “List every assumption this method makes about authentication and tell me which line enforces it.”
- “What happens if the database commit succeeds here, but the HTTP call on the next line times out?”
- “Give me three malformed payloads that would bypass this validation.”
Treat its answers as leads to verify, not a sign-off. And for anything touching money, billing, personal data, or irreversible migrations, get another human developer to review the PR—especially when you were the one who wrote the prompt.
Keeping generated code maintainable months later
The real cost of unreviewed AI code rarely shows up on deploy day; it shows up three months later during a 2 a.m. incident when nobody on the team understands why a helper exists or which edge case it was supposed to guard.
Keep your PRs small enough to read line by line, never paste production secrets or customer data into unapproved external tools, and stick to one simple rule before hitting merge: if you cannot explain the failure modes and point to the tests that cover them, the code is not ready to ship—no matter how fast it was written.
For related guides that complement this checklist, see:
- Malaysia’s 300,390 Android Botnet Figure: What the XCPE Story Really Means
- What Your Browser Extensions Can Actually See: Auditing Permissions and Data Risk
- Passkeys Are Easier Than Passwords—Until You Lose Your Phone: A Recovery Checklist