Ppdd.bot
中EN

Check the agent's work

AI writes code fast, and when it's wrong it's convincingly wrong: it compiles, the tests are green, and the explanation sounds right. This page is about telling whether what it hands you is usable.

Four ground rules

1. Don't submit code you can't explain. For every line, you should be able to say why it's written that way. If a reviewer asks and you can't answer, that's on you, not the AI.

2. Green tests aren't enough. A person tries it at least once. Use it the way a user would, end to end, in a real environment. When the AI says "tests pass", that means the tests it wrote pass, not that the feature works.

3. When a test goes red, don't change the assertion. Work out whether the code is wrong or the requirement changed. If the requirement changed, someone has to sign off. It isn't up to you and the AI.

4. Stuck for 30 minutes? Ask a person. Bring three things: what you're trying to do, what you tried, and the exact error. Don't spend the afternoon going back and forth with the AI.

Reading a change, in order

  1. Look at the file list and line counts first. If changing a button label touched 20 files, stop and find out why.
  2. Read the tests before the implementation. Do they describe the requirement? Read the test names in a row; they should read like a list of requirements.
  3. Run it yourself. See the tests go green in your own terminal, then click through the feature end to end the way a user would (rule 2).
  4. Pick the most important part, have the AI explain it, then restate it in one sentence. If you can't, go back to rule 1.
  5. Go through the eight red flags below.

Eight red flags

1. Tests got loosened

To make a test pass, the assertion was weakened until anything passes, or the test was skipped.

- expect(total).toBe(1290)
+ expect(total).toBeTruthy()

How to check: whenever the diff touches a test file, read each assertion and ask whether it got weaker. Search for skip, only, and xit.

2. Errors got swallowed

A try/catch that returns an empty value. The error message is gone; the problem isn't.

try {
  await charge(order)
} catch (e) {
  return null
}

How to check: for every new catch, ask whether the caller finds out, and whether it shows up in the logs.

3. APIs that don't exist

A method, parameter, or config option that was made up, or that belongs to a different version.

How to check: jump to the definition in your editor. If you can't, read the official docs for the version your project uses.

4. More change than you asked for

A refactor here, some reformatting there, a dependency bump. Each one is reasonable on its own; together nobody can review them.

How to check: go through the files and ask, for each one, why it had to change. If there's no answer, send it back.

5. Hard-coded to pass the test

if (orderId === "order-123") return 1290

How to check: if a specific value from the test data shows up in the implementation, this is almost always why.

6. Behavior changed quietly

A default, a sort order, a time zone, rounding, a page size. The tests didn't cover it, so everything is green.

How to check: focus on changed constants, default parameters, and shared helpers in the diff. Ask who else depends on them.

7. A new dependency

A package appeared in the dependency file, maybe for something three lines of code would do.

How to check: can something already in the project do it? Is the package maintained? Is the license OK? If you're unsure, ask.

8. Secrets and personal data

A token written into the code, or a whole request, user data included, printed to the log.

How to check: search for key, token, secret, and password, and look at what every new log line prints.

A real example: stuck at 100%

Our product has a feature where users upload video straight from the browser. It shipped on September 9. AI wrote both the frontend and the backend, and every test was green.

Five weeks later, on October 14, I uploaded two videos myself in the test environment. The progress bar reached 100% and stopped. No error, no "done", and the submit button stayed locked. After a refresh, the file was actually there.

The cause was simple. When an upload finished, the backend returned the file's ID in a field called id. The API doc said attachment_id, and the frontend, following the doc, read attachment_id. It got nothing back, so it treated that row as "still uploading" forever.

Why nobody noticed for five weeks:

  • The frontend tests used fake data written from the doc. They proved the frontend matched the doc, not that it matched the backend.
  • No backend test checked what the response fields were called.
  • A missing ID didn't raise an error; the row just kept spinning. That's a variant of red flag 2: something went wrong and nobody found out.

Each side's tests were testing its own assumptions. Anyone who had uploaded a single video in those five weeks would have seen it the same day. That's rule 2: green tests aren't enough; a person tries it at least once.

How it was fixed:

  1. The backend now returns attachment_id, as the doc says.
  2. A new integration test calls the real endpoint and asserts that attachment_id is in the response. It was red before the fix and green after.
  3. The frontend got a fallback too: a response without an ID is an immediate error, and an upload with no progress for 30 seconds says it's stuck and offers a retry.

Words used here

  • Rules file (CLAUDE.md, AGENTS.md): the project rules an agent reads at the start of every session.
  • Skill: a set of steps for one job, which the agent reads only when it needs it.
  • PR (pull request): a request to merge your change after someone reviews it.
  • Diff: the difference between before and after a change.
  • Assertion: the line in a test that decides whether the result is right.
  • Regression test: a test kept after a bug fix so the same bug can't come back.
  • CI: the pipeline that runs checks automatically on every push.
  • Rollback: undoing a change that's already live.
  • Decision open to veto: a call the agent made with the recommended option, which a human can overrule.
  • Ledger: a directory in the repo for follow-ups, one file each.

Read next

Spotted a mistake, or do it differently? Write to me