Launch offer: the first 1,000 users get Settl free for a year* Claim your spot
settlbuilding in public

The AI-TDD workflow guide (spec → failing test → agent)

The short version

Automated checks went from 36 to 617, and almost none of them were written by hand. The work was handed to AI agents as part of the normal build process rather than treated as a separate cleanup task.

The reason it works is not speed, it is consistency. Writing tests is boring, and boring work is the first thing a tired human silently drops, right when it matters most. An AI never decides a particular case probably does not need covering.

Copy these prompts

Paste them into Claude Code (or any AI that can see your project), in this order. Each one answers a different question, and the first is usually the one that matters.

1. Start where it would hurt most

List the parts of my app with the least test coverage and the highest damage if they broke, ranked. I want to start where it matters, not at the top of the file list.

2. Write the checks before the code

Set up a workflow where, for each new piece of work, the tests are written first from a description of what it should do, and then the code is written to satisfy them. Show me what that looks like for my next feature.

3. Make them run on every change

Make my tests run automatically on every change and tell me clearly when something breaks. If I have to remember to run them myself, I will stop. Show me the setup and what a failure looks like.

36 tests to 617, and I hand-wrote almost none of them. The arc, commit by commit: 36 → 47 → 67 → … → 617 backend tests, 127 → 639 Flutter tests, plus 2,847 analyzer warnings → 0 (827 of them fixed mechanically in a single sweep). The workflow that produced it: spec first, TDD tasks written into the plan, agents implementing test-first. Settl's balance math now has more tests than my last three jobs combined.

The workflow

  1. Spec before code. Every feature starts as a written spec (what "done" means, edge cases, wire formats). The spec is what makes step 3 possible: you can't write a failing test for behavior nobody defined.
  2. The plan is a list of TDD tasks. Implementation plans break into tasks of the shape "write test X (it will fail because Y) → implement until green." The agent receives tasks, not vibes:
Task 4: settlement note accepts null (REGRESSION-02)
  1. Add test "accepts a null note from the voice agent"; expect 201.
     RUN IT. It must FAIL with 400 validation_error.
  2. Fix the schema. RUN IT. Must pass. Run the full suite. No regressions.
  1. Red before green, enforced. The agent must run the new test and show it failing before implementing. A test that never failed proves nothing. This single rule is most of TDD's value and agents follow it perfectly when told.
  2. Exploit that AI doesn't get bored. Humans write 3 edge-case tests and get tired; an agent will write 40 (pre-join membership, multi-currency rounding, null-vs-omitted fields) at consistent quality. Point that stamina at the modules where wrongness is expensive (my balance engine).
  3. Every bug becomes a named regression test. My tests carry names like REGRESSION-02 tied to the incident. Bug → failing repro test → fix → test stays forever. The count grows because production teaches you.
  4. Fast suites keep the loop honest. 617 tests run in seconds (in-process requests against the app object, no server boot). If the suite is slow, agents (and you) stop running it, and the whole workflow decays.
  5. Mechanical sweeps for mechanical debt. The 2,847 → 0 analyzer cleanup wasn't heroism: configure the linter honestly, run the auto-fixer (827 fixes in one pass), let an agent grind the remainder, then hold zero. Zero-warning baselines make every NEW warning a signal.
  6. Coverage follows workflow, not willpower. I never set a coverage target. The count 17×'d as a side effect of "no task without a test". Process beats resolutions.

Steal this for your app

Run this on your codebase

Paste this into Claude Code in your repo:

Audit this repo's test discipline against the AI-TDD workflow.
Count tests per module and flag high-stakes code (money, auth, scoring) with thin coverage.
Check whether bug fixes in git history have named regression tests; list fixes with no matching test.
Time the test suite; flag anything slow enough that an agent loop would stop running it.
Check for written specs or plans that define behavior before implementation; flag features with code but no spec.
Report the current linter or analyzer warning count and whether a zero-warning baseline is enforced.
Report findings as a checklist before changing anything.

Get the next one in your inbox