Every bug that reached production becomes a permanent test

Our rule for software built with AI agents: a bug that reached a real user turns into an automated test that stays forever, listed in a test register with its origin and fix. Why, how, and what counts as a real test.

Published · 3 min read · Flowsmith editorialdevelopmentqualityAI agents

A dark shelf of identical small sealed jars in neat rows; one new jar at the end of the row is lit by a thin blue rim.
Illustration drawn for this article. No text in the image, so it works in every language.
In short
  • Rule: every bug that reached a real user becomes an automated test that stays forever.
  • The test must fail on the old code and pass on the fix. Otherwise it proves nothing.
  • All tests live in a test register on the project page: category, origin bug, fix, date. Retired only by a recorded decision.
  • With AI agents writing code, tests are the memory that survives between sessions.

An AI coding agent is fast, tireless and has no memory of last month. It will happily rewrite a function in a way that reintroduces a bug someone spent a day finding. A person on the team might remember; the agent will not. That is why our rule is short and strict: once a bug has reached a real user or a real device, it becomes a permanent automated test.

How a bug turns into a test

  1. Reproduce it in a test first. Before fixing, the agent writes a test that shows the bug: it fails on the current code.
  2. Fix the code. The same test now passes.
  3. Check the test catches the bug. Reintroduce the old behaviour for a moment; the test must fail again. Only then is it trustworthy.
  4. Register it. Add a line to the test register: what broke, where it was seen, the fix, the date.
  5. It runs forever. On every pull request, in CI, before anything merges. See letting AI agents merge their own pull requests.

Tests that reflect real behaviour

The most dangerous test is a green one that proves nothing. Patterns we refuse:

  • Mocking the part that broke. If the bug was in how the database query handled an empty result, a test with a fake database that always returns one row is decoration. Our tests for database logic run against a real SQLite engine, the same one under Cloudflare D1.
  • Checking a placeholder. A status page that shows "OK" by default passes a test that only checks for "OK". The test must check the real value or the honest "not known yet".
  • Testing the happy path only. Most production bugs live in the empty list, the duplicate message, the timeout.

The broader rule behind this: no release on tests that do not reflect real behaviour, and every release, even an early alpha, is fully tested within the scope of what it changed. More in alpha, beta, stable.

In depth: the test register

Tests in a folder are invisible to anyone who does not read code. So each project page has a test register: a table with filters by category (forms, money, permissions, languages, devices), the origin of each test (which bug, seen where), how it was fixed and when it was added. It answers questions colleagues actually ask: "Is the thing that broke in March covered now?"

Tests never disappear quietly. If a feature is removed and its tests with it, the register records the decision and who made it. A shrinking test count with no explanation is itself a warning sign.

Simulators before real devices

For anything that runs on hardware, new user-facing behaviour is debugged on a simulator page first and only then goes into firmware. Bugs found on real devices still become tests, often at the simulator level, so the next change is caught before it reaches a device again.

Start small

You do not need a big framework. The next time something breaks, write one test that fails before your fix and passes after, and keep it. Do that ten times and you have a safety net shaped exactly like your real problems. The Academy lessons reading errors and when failure looks like success show how to recognise bugs that hide behind green screens.

Frequently asked questions

What is a regression test?

An automated test that checks that something which once broke stays fixed. It runs on every change, so the same bug cannot come back unnoticed.

Why insist on this when AI agents write the code?

Agents change code quickly and confidently, and they do not remember last month's incident. A test is the memory that survives every session and every agent.

What is a test register?

A page that lists every test with its category, the bug it came from, how it was fixed and when. Tests leave it only by a recorded decision, never quietly.

What makes a test not count?

If it mocks away the part that broke, checks a placeholder instead of the real result, or passes even when the bug is reintroduced. A good regression test fails on the old code and passes on the fixed code.

Written from our own production systems by the Flowsmith editorial team, with AI assistance.

Want this running in your company?

Flowsmith designs and operates automations like this for small and mid-sized teams — with a person approving anything that leaves the building.

More from the blog