TDD With an AI: Write the Test First, Then Prompt
Test first works better with an AI, with three traps: a red run that fails for the wrong reason, a green run the AI faked, and tests it quietly edits.
Tests that catch real bugs in AI-built apps, how to tell whether the AI's tests test anything, and test-first prompting.
Test first works better with an AI, with three traps: a red run that fails for the wrong reason, a green run the AI faked, and tests it quietly edits.
When an AI fix turns a test red, it edits the test. Behavior tests survive that; tests of internals do not. A runnable before and after, plus a commit guard.
A green test run proves little if the AI wrote the tests from its own code. Ask for rule-based tests, then break one line on purpose to see if they notice.
A test suite is what stops an AI fix from silently breaking other things. A runnable example with real before and after output, and what tests can't catch.
Authentication asks who you are. Authorization asks what you may touch. How the second goes missing in AI-built apps, and 25 tests that catch it.
Check an AI's change in this order: files touched, new dependencies, tests, deleted lines, then run it. A runnable example with four hidden problems.
Tests that always pass prove nothing. Break your code on purpose and see which tests fail: in one scratch run, 5 of 9 tests never failed once.
Mutation testing plants fake bugs in your code and counts how many your tests catch. A real Stryker run on a small JavaScript function, and what 100% misses.
Count queries instead of timing them. A two-test setup that fails when an AI rewrite brings back an N+1 loop, or quietly drops rows while fixing it.
Explaining a bug to an AI works like a rubber duck, until the AI agrees with your wrong theory. A four-step routine and a runnable example.
Use a Stripe sandbox and its test keys, run six test-card scenarios, and check that a failed payment never unlocks the paid plan. Includes runnable tests.
Stuck with a vibe-coded app? I'll fix it.
Email me