AI Agents and Coding Assistants

Reviewing AI-Written Code: A Checklist for Humans

A practical order for reviewing AI-written code, from intent and scope to tests, security, dependencies and long-term upkeep.

Key takeaways

  • Write down what the change should do before reading it, so the code's own story does not set your expectations.
  • Inspect the whole set of changes, including deleted lines, edited tests, configuration and new dependencies.
  • Trace normal, boundary and failure cases, and run the code instead of relying on how convincing it reads.
  • Keep changes small enough to review properly, and send back anything nobody can explain.

Review AI-written code as you would a contribution from a capable newcomer who works very fast and does not know your project's history. Check first that it solves the right problem, then that it changed only what it should, then that it behaves correctly on awkward inputs, handles data safely and can be maintained. Do not approve anything you cannot explain.

Generated code often looks finished. Names are sensible, comments are tidy and the layout is clean. Those qualities used to hint that an author had taken care, and now they cost almost nothing to produce. Your attention has to go to behavior.

Why this review differs

A human colleague's mistakes tend to follow patterns you learn. A model's can appear anywhere, including inside confident, conventional-looking code. It may call a function that does not exist in your version of a library, repeat a pattern that is outdated or satisfy the literal request while missing its purpose.

The tool also does not carry responsibility. Whoever merges the change (adds it to the shared codebase) owns the result. Asking the assistant to review its own work can surface problems, but it may share the same blind spots, so treat that as an extra pass and not as approval.

Volume matters too. When code arrives faster than anyone can read it, review becomes the narrow point. Time saved in writing can reappear here, one reason findings on programmer speed differ.

Start with intent and scope

Before opening the changes, write two or three sentences: what should be different afterward, and what must stay the same. Compare the code with that note.

Then look at the list of files touched. Ask these questions.

  • Does every changed file have a reason connected to the task?
  • Was anything deleted or rewritten that nobody asked for?
  • Did permissions, settings, build scripts or data layouts change?
  • Were existing tests edited, skipped or removed?

That last item deserves special care. A tool asked to make tests pass may change what the test expects instead of fixing the fault. If the old expectation was correct, the change should be rejected.

Large mixed changes are hard to judge. Ask for the work split into steps, each doing one thing. A tool can produce that split quickly, and written project rules help, as in writing instructions for coding agents.

The review order

An order for reviewing a generated change
1 Intent State what should change and what must not 2 Scope Check every file, deletion and setting 3 Behavior Trace normal, edge and failure cases 4 Safety Check access, input handling and secrets 5 Dependencies Confirm new packages are real and needed 6 Upkeep Ask whether the next person can change it Intent State what should change and what must not 1 Scope Check every file, deletion and setting 2 Behavior Trace normal, edge and failure cases 3 Safety Check access, input handling and secrets 4 Dependencies Confirm new packages are real and needed 5 Upkeep Ask whether the next person can change it 6

Trace the behavior

Pick concrete inputs and walk them through. Consider this generated function meant to split a bill evenly, in cents.

def split_bill(total_cents, people):
    share = total_cents // people
    return [share] * people

The // operator divides and rounds down to a whole number. For 1,000 cents and 4 people, each share is 250, and the shares add to 1,000. Now try 3 people. Each share is 333, and three of them add to 999. One cent has vanished. With 0 people, the function raises a division error. A negative total or a negative number of people is not checked at all.

None of this is visible from a quick glance, and a test using only the first example would pass. Useful inputs to try include zero, one, a very large value, an empty list, a missing field, duplicate entries, unusual characters and two actions happening at once.

Also check what happens when something outside the code fails. If a network call times out halfway through, is data left half-updated? Are errors reported, or caught and silently ignored? A block that swallows every error is a common way for broken code to appear healthy.

Turn findings into a clear request

When you find a fault, describe it so that the fix can be checked. "The bill splitting is wrong" invites another guess. A stronger note reads like this: for 1,000 cents and 3 people, the shares must add to exactly 1,000; give the leftover cent to the first person; reject a count of zero or less and a negative total with a clear error.

With that rule, the expected shares are 334, 333 and 333, which add to 1,000. You can now ask for a test of that case before the change, watch it fail, apply the fix and watch it pass. The order matters because a test that never failed has not shown that it can detect the problem.

After the fix, read the new version from the start. A second attempt may repair the named case and disturb something nearby, such as changing what the function returns or removing a check that worked. Compare it with your original note on what must stay the same.

If the tool keeps circling after two or three tries, stop prompting and work out the logic yourself, or ask a colleague. Repeated attempts tend to add special cases on top of a mistaken approach, and each layer makes the eventual review harder.

Check safety and data handling

Look wherever information enters or leaves.

  • Is input from users, files or other services validated before use?
  • Are database queries built with parameters, which keep data separate from commands, and not by gluing text together?
  • Is every sensitive action checked for permission on the server?
  • Are passwords, keys or tokens written into the code or printed into logs?
  • Does the change send personal data somewhere new?

Common security mistakes in generated code covers these in more detail. For anything involving payments, health information, authentication or encryption, bring in someone with the relevant expertise.

Verify dependencies and claims

Every new package is code you are choosing to trust. Confirm that it exists in the official registry, that it is the one intended, that it is maintained and that its license fits your project. Assistants sometimes propose names that are made up, a hazard described in invented package names.

Verify unfamiliar function calls and settings against the documentation for the version you use. Treat the assistant's summary of its work as a claim. "All tests pass" means little until you have seen them run, and "handles errors" should point to specific lines.

If a stretch of code looks as though it may reproduce a distinctive existing work, or carries someone else's copyright notice, pause and check the licensing before keeping it.

Judge the tests and the future

Good tests would fail if the behavior broke. Read their expected values and ask where they came from. If they were copied from whatever the code produced, they only confirm that the code does what it does. Writing tests with AI explains how to avoid that loop.

Then think about the next person. Does the change duplicate logic that already exists? Does it introduce a second way of doing something your project does one way? Is it more elaborate than the problem needs? Comments should explain why a choice was made, since the code already shows what it does.

A fair final test: could you fix a fault in this code on a busy day without the tool? If not, simplify it or study it until you can.

A checklist to copy

Area Question to answer
Purpose Does it do what was asked, for the reason it was asked?
Scope Is every change, including deletions, justified?
Correctness Did you run normal, boundary and failure cases?
Security Are input, permissions, secrets and logs handled safely?
Dependencies Is each new package real, needed and acceptably licensed?
Tests Would they catch a plausible mistake?
Upkeep Can a teammate understand and change it?
Recovery Can the change be rolled back?

Scale the effort to the stakes. A throwaway script on a copy of data needs far less than a change to how customers are billed.

Keep review honest as a team

A checklist fails when people are too rushed to use it. If generated changes pile up, agree on limits: a maximum size, a named reviewer and time set aside for the job. Let automated tools handle formatting, type checks and known security patterns so that people can spend attention on meaning and design.

Ask authors to say how a change was produced where that helps the reviewer, and to state what they checked themselves. An author who submits code without having run or read it has moved their work onto someone else. When a fault does slip through, add the case to the tests or the checklist, and look at why it was missed without turning it into blame.

Common questions

Should I use a second AI tool as the reviewer?

It can catch some problems and is cheap to try. It can also miss real faults and raise false alarms. Keep a person accountable for the decision.

How large should one change be?

Small enough that a reviewer can hold it in mind and finish with full attention. If you find yourself skimming, ask for it to be divided.

What should I tell the author when rejecting generated code?

The same things you would tell any author: the failing case, the expected behavior and the project convention involved. Concrete feedback also makes a better instruction if the tool takes another attempt.

Written for 4ArtificialIntelligence with AI writing tools and not reviewed line by line by a person. Check anything you rely on against a textbook or primary source. Report an error.

Keep reading

All 46 articles in AI Agents and Coding Assistants →

Latest news on this topic