In October, Google told investors that more than a quarter of all new code at Google is generated by AI, then reviewed and accepted by engineers. Across the industry, the share of AI-assisted code is growing fast. That makes code review, always important, the central control for quality and security.
Reviewing AI-generated code is not quite the same as reviewing a colleague's. The failure modes are different, and the volume is higher. Here is how experienced engineers approach it.
Start with intent, not syntax
AI-generated code is usually syntactically clean, well formatted and plausibly named. That surface polish can pull reviewers into line-by-line reading before they have asked the most important questions:
- Does this solve the problem described in the ticket, or a slightly different one?
- Is this the right place in the codebase for this logic?
- Is this the simplest approach, or did the assistant build more than needed?
- Should this code exist at all, or does something similar already exist?
If the answer to any of these is wrong, line-level review is wasted effort.
Know the characteristic failure modes
AI-generated code tends to go wrong in predictable places. Check them deliberately:
| Failure mode | What to look for |
|---|---|
| Happy-path bias | Missing handling for empty inputs, nulls, timeouts, partial failures |
| Swallowed errors | Broad except/catch blocks, errors logged and ignored |
| Invented APIs | Methods or parameters that do not exist in your library version |
| Outdated patterns | Deprecated APIs, old framework idioms |
| Security gaps | Missing authorisation, unsanitised input, disabled TLS verification, secrets in code |
| Duplication | A new helper that duplicates an existing one |
| Tests that test nothing | Assertions mirroring the implementation, mocks that bypass the logic under test |
| Over-engineering | Abstractions, options and configuration nobody asked for |
A classic example that passes a quick glance:
def get_invoice(request, invoice_id):
try:
invoice = Invoice.objects.get(id=invoice_id) # no ownership check (IDOR)
return JsonResponse(invoice.to_dict())
except Exception: # hides real failures
return JsonResponse({"error": "not found"}, status=404)What a senior reviewer asks for:
def get_invoice(request, invoice_id):
invoice = get_object_or_404(
Invoice, id=invoice_id, account=request.user.account # scoped to the caller
)
return JsonResponse(InvoiceSerializer(invoice).data) # explicit fields onlyReview the tests as hard as the code
AI is very good at producing tests that pass. That is not the same as tests that would catch a bug. Check that:
- expected values come from requirements, not from running the code,
- negative cases and boundaries are covered,
- mocks do not replace the very behaviour being tested, and
- the tests would fail if the implementation were wrong. Mutation testing helps here.
Let automation do the mechanical work
Human attention is the scarce resource. Before a person reviews anything, automation should have checked:
- formatting, linting and type checking,
- unit and integration tests,
- SAST, dependency and secret scanning,
- new dependencies flagged for explicit approval, and
- duplication and complexity thresholds.
flowchart LR PR[AI-assisted PR] --> A[Automated gates<br/>tests, types, lint,<br/>SAST, SCA, secrets] A -->|fail| Back[Back to author] A -->|pass| H[Human review<br/>intent → behaviour →<br/>security → fit] H -->|risky paths| S[Second reviewer<br/>security / code owner] H --> M[Merge] S --> M
Keep diffs reviewable
AI makes large diffs cheap to produce and expensive to review. Set team norms:
- keep pull requests focused on one change,
- split generated refactors from behaviour changes,
- reject diffs too large to review properly, rather than skimming them, and
- ask authors to explain in the description what the AI generated and what they changed or verified.
Apply risk-based depth
Not every change needs the same scrutiny. Spend the most attention on:
- authentication, authorisation and session handling,
- payments and financial calculations,
- data access and privacy-sensitive code,
- database migrations and infrastructure changes, and
- concurrency and anything performance-critical.
Code-owner rules can route these paths to a second reviewer automatically.
Protect the reviewer
Review fatigue is a real risk when AI multiplies the volume of code. Rotate reviewers, limit review sessions, and treat time spent reviewing as real engineering work, not an interruption to it.
The bottom line
As more code is written by AI, the engineer's most important contribution shifts towards judging it: whether it solves the right problem, handles the real world, keeps data safe and fits the system it joins. Review with that order of priorities, let automation handle the rest, and keep changes small enough to review honestly.
Our secure code review service provides expert review of AI-assisted codebases, and our security training teaches development teams these review practices.