Contact
DR
David R. Fajardo••9 min read

How I Review AI-Written Code Before It Reaches Production

AI can write the code. You still have to sign off on it. The checklist I use on every AI-generated change to the systems businesses depend on.

#AI#Code Review#Best Practices#Testing
How I Review AI-Written Code Before It Reaches Production

When an agent writes most of a change, reviewing becomes the most important part of my job. A careful review is where I add value; a skimmed one is where bugs get in. Here is the checklist I run, roughly in order.

Why this became my hardest job

When I wrote everything by hand, I reviewed as I typed. Now an agent can produce a day's worth of changes before lunch, and the struggle is attention: reading the fiftieth generated function as carefully as the first. That is why I review with a checklist instead of willpower.

Tests carry part of the load. TapMo shipped with 600 Playwright tests that try every endpoint as every role. OREA has about 330 test files, including a 5,000-worker payroll run on staging. Golden Paws has end-to-end tests for accounting, the customer portals and phone layouts. The checklist below covers what tests can't.

1. Did it do what I asked, and only that?

Agents like to be helpful. Sometimes that means renaming things you didn't ask about, "improving" a neighbouring function, or reformatting a whole file. Unrequested changes are where surprises hide. I check the list of touched files first and question anything outside the task.

2. Read the data flow, not just the code

For every change I trace one real example through it. A purchase order arrives, gets received, moves stock, posts a journal entry. Does each step read and write what I expect? This catches more bugs than reading line by line, because AI mistakes are usually wrong assumptions, not typos.

3. The usual suspects

  • Dates and timezones: is "today" the server's today or the clinic's today in the Philippines?
  • Money: floats where there should be integers or decimals, rounding at the wrong step.
  • Permissions: is the check on every path, including the API route and the export, not just the page?
  • Empty and missing data: what happens with zero items, a deleted customer, a null branch?
  • Concurrency: two cashiers, two devices offline, one webhook delivered twice.
  • Errors: are failures shown to the user in plain language, or swallowed silently?

4. Does it fit the codebase?

Generated code often reinvents something the project already has: a second date formatter, a new fetch wrapper, a hand-rolled table when there's a shared one. Each duplicate is small, but together they make the codebase harder to change. I ask the agent to reuse what exists.

5. Tests that would actually fail

AI-written tests sometimes just confirm what the code does, including its bugs. I check that at least one test would fail if the rule were broken. A quick trick: change the rule on purpose and make sure a test goes red.

6. Run it like a user

Before anything ships, I click through it: on a phone if it's a phone screen, offline if it's meant to work offline, with a realistic amount of data. Type checks and tests passing is not the same as the feature working.

If I can't explain a change to the person who will use it, I'm not ready to ship it.

Keep changes reviewable

The best review habit starts before the code is written: ask for small changes. One feature, one migration, one refactor at a time. A 200-line diff gets a real review. A 3,000-line diff gets a skim, and a skim is how production breaks.

Related Posts

All posts