Asking AI to Write Tests Before Code Might Just Be You Paying for Peace of Mind
An experiment on Martin Fowler's site: for the same tasks, AI completed two runs each with and without TDD. Non-TDD results took the top two spots and used 3 times fewer tokens. TDD is a patch for human cognitive limitations, and it may not fit the era of AI coding.
Do you require AI to "write tests first, then implementation" in your CLAUDE.md when asking it to write code?
If you do, you might just be paying for peace of mind.
There's an experimental report on Martin Fowler's website, written by Birgitta Böckeler — an engineer with over 20 years of experience who specializes in AI-assisted delivery. She ran a test: for the same set of tasks, she had an AI agent run through twice with TDD and twice without TDD, then sent the results to Opus for scoring, and Opus had no idea which code was produced with which method.
The result was consistent: for small and medium tasks, non-TDD runs took first and second place, while TDD runs came third and fourth.
Scores measuring how effectively tests actually caught bugs were identical between the two groups.
But TDD consumed at least 3 times more tokens.

Why is this?
Agents that don't follow TDD will work through the entire architecture, data structures, and edge cases before starting implementation. TDD instructions explicitly prevent this — moving forward one test at a time means the final design ends up being a collection of local decisions, locked into the shape defined by the very first test, with almost no adjustments made later.
What's more, any behavior the agent doesn't think to write a test for simply never gets implemented at all.
TDD is a solid paradigm for human programmers, but it is fundamentally a patch built to compensate for human cognitive limitations. Humans are prone to overthinking, going off track, and forgetting edge cases, so tests act as an anchor for our thinking. But AI doesn't have these flaws; its way of "cognition" is fundamentally different, so this old patch simply doesn't fit.
In the comments section, many people had their assumptions upended: some said they'd always loved TDD; others said they'd run into development issues lately from overusing TDD; and some had already stopped using the practice entirely. One developer even writes into their Agent md to tell the agent not to write tests, and instead does end-to-end simulation to test the real working pipeline directly when validation is needed. Another has the agent run real tests via miniflow after finishing coding, because "otherwise the tests AI writes are just a bunch of trivial 'happy path' tests that don't actually catch anything meaningful".
The original poster themself admitted that they used to require agents to write test cases first during Vibe Coding, but now plans to run their own comparative validation in their use case.
Technical paradigms need to evolve alongside technology. A lot of our default assumptions probably need to be re-verified from scratch.
What other "default correct" rules in your CLAUDE.md are actually slowing down your AI workflow right now?
发布时间: 2026-08-13 03:36