How to Review AI-Written Code and Keep Your Project Safe

A practical checklist for reviewing code from AI assistants and agents: correctness, tests, security, secrets, dependencies and permissions — so speed doesn’t cost you quality.

AI tools can produce more code in an afternoon than most of us can carefully read. That’s the real risk: not that the code is bad, but that it arrives faster than our attention. Reviewing AI-written code is a skill, and it’s a little different from reviewing a colleague’s.

Why AI code needs a different eye

Human mistakes tend to look like mistakes: typos, half-finished thoughts. AI mistakes often look polished. The code is well-formatted, well-named and confidently commented — and calls a function that doesn’t exist in your library version, or quietly skips an edge case. Fluency is not correctness.

The review checklist

1. Does it do what was asked — and only that?

Agents sometimes “helpfully” refactor nearby code, rename things or add features nobody requested. Scope creep makes diffs harder to review and introduces risk. Ask for the change to be split or reverted where it wandered.

2. Do the tests prove it?

  • Run the full test suite yourself, not just the tests the tool mentioned.
  • Read the new tests. Check they’d actually fail if the feature broke — a test that asserts true is decoration.
  • Watch for tests that were changed to match new behaviour rather than fixed code.

3. Are the APIs real?

Check imported functions, flags and config keys against the version you actually use. Hallucinated or outdated APIs are one of the most common AI errors, and your editor’s type checker or a quick look at the docs catches most of them.

4. Security basics

  • Input handling: SQL built from strings, shell commands with user input, unescaped HTML.
  • Auth checks: new endpoints that forgot to require login or check ownership.
  • Secrets: keys or tokens written into code, tests or logs.
  • Error messages that leak internals to users.

5. Dependencies

Every new package is code you didn’t review. Ask: is it needed, is it well-maintained, and is the name exactly right? Typo-squatted package names are a real attack, and AI tools can suggest plausible-but-wrong names.

6. Does it fit the codebase?

Matching existing patterns matters for whoever maintains this next. Duplicate helpers, a second way of doing logging, inconsistent naming — these are cheap to fix now and expensive later.

Make review easier before it starts

  1. Ask for small changes. One feature, one pull request.
  2. Ask the tool to explain its change and list anything it’s unsure about. You’ll be surprised how often it flags its own weak spots.
  3. Keep a project instructions file (many agents read one, such as CLAUDE.md or AGENTS.md) with your conventions, test commands and things never to do.
  4. Limit permissions. Let agents edit and run tests freely; require approval for deleting files, installing packages, pushing or deploying.
  5. Commit often so any step can be rolled back.
Rule of thumb: you own every line you merge, whoever — or whatever — typed it.

Speed and safety together

The goal isn’t to slow AI down; it’s to put your attention where it matters. Let tools handle the typing and the first pass. Spend your time on intent, tests and security. And if agents run while you’re away, tools like Sync Log let you approve the risky steps from your phone instead of granting blanket permissions — see Run coding agents from your phone.

Keep reading

More from the blog

What Are AI Coding Tools? A Plain-English Guide

AI coding tools use large language models to suggest, write, explain and test code. Here’s what they are, how they work, what they’re good at and where they still need you.

Autocomplete, Chat or Agent? The Three Kinds of AI Coding Tools

AI coding tools come in three flavours: inline autocomplete, chat assistants and autonomous coding agents. How each works, what each is best at, and how to pick.