Skip to content

Reviewing AI-written code

How to review AI-generated code.

When an assistant writes the code, your job moves from typing to judging. This checklist covers what to verify before you approve a change you did not write yourself.

A review checklist

  1. Start from the requirement, not the code

    Write down what the change must do before you read it. AI code is usually fluent and plausible, so reading it first makes it easy to accept a solution to a slightly different problem.

  2. Look for confident mistakes

    Check every API, flag and library call it uses. Generated code can call functions that do not exist, use an option that was removed, or mix two versions of a library while still looking correct.

  3. Trace the edge cases and failure paths

    Ask what happens with empty input, a missing record, a timeout, or a partial failure. Generated code often handles the happy path well and skips error handling, retries, and cleanup.

  4. Check access, data and secrets

    Confirm who is allowed to call the code and whose data it can reach. Look for missing permission checks, unvalidated input reaching a query or a shell, and credentials written into code or logs.

  5. Check that work finishes before it reports success

    Async code is a common trap: a function can start a task and return before the task completes. Make sure anything that reports done, ready or saved waits for the work it describes.

  6. Ask for the test that would prove it

    Do not stop at "looks good". Name the test or check that would fail if the code were wrong, and request it as part of the change.

See two of these in a real review

The worked examples follow a review from a first answer to a stronger one, with the evidence for each change.

Async completion: work that reports done too early

Access control: who should get the download link

Stop reading AI code. Start leading it.

Practice the review on short scenarios and get feedback on your reasoning.