Test-Driven Development (TDD)
Clean code that works.
Kent Beck's Test-Driven Development is a software development discipline built around a strict three-phase cycle — Red, Green, Refactor — in which every line of production code is justified by a failing test written moments before it. The methodology is not about testing; it uses tests to drive design, forcing small, decoupled, working increments at every step. Formalized in Beck's 2002 book with two complete worked examples, TDD gives developers a precise decision rule for every moment of the coding loop.
“I need to write a function that converts temperature from Celsius to Fahrenheit. Python and pytest. Seems simple but I want to practice proper TDD.”
Write a failing test first — let it tell you exactly what code to write next
TDD operates through the Red-Green-Refactor cycle: (1) Red — write the smallest possible failing test that captures one desired behavior; (2) Green — write the minimum production code to make that test pass, even if it means hard-coding a return value ('Fake It Till You Make It'); (3) Refactor — clean up all duplication and improve design while keeping every test green. Beck prescribes starting each feature by writing a Test List — enumerating all known cases before touching code — and uses Triangulation (adding a second test with a different example) to force real generalization when a fake implementation has gone far enough. The Obvious Implementation shortcut lets developers skip faking when the solution is clear, but Beck's default is always the smallest safe step. This tight loop, completable in minutes, produces emergent, decoupled design as a side effect rather than an upfront requirement.
Most developers write code they hope works, then add tests as an afterthought — or skip them entirely under deadline pressure. This produces coupled, fragile codebases where bugs surface in QA or production, debugging sessions steal hours from building, and no one refactors because there is no safety net. TDD doesn't just add tests; it inverts the entire workflow so that untested code becomes literally unwritable by construction.
By following the Red-Green-Refactor cycle one baby step at a time, you will always know exactly what to write next, always have a passing test suite as a safety net, and produce a codebase whose design emerged from real constraints rather than speculation.
- A feature description, user story, or requirement you want to implement
- The programming language and test framework you're using (e.g., Python/pytest, JS/Jest, Java/JUnit, Ruby/RSpec)
- Any existing code context — class names, data structures, or interfaces already in place
- Your current position in the cycle — a failing test, a passing test, or working code in need of cleanup
- A Test List enumerating all known cases before you write a single line of production code
- A minimal failing test (Red) written Assert-First, testing exactly one behavior
- The smallest possible Green implementation — including Fake It stubs when appropriate — with a clear path to generalization via Triangulation
- A refactoring checklist that identifies duplication and design smells once tests are green, with every suggested change small enough to preserve the full green suite
Watch the methodology work.
Three specimens from a single real session: the same situation, unaided and calibrated, the full transcript, and the skill answering live in the channel where the work happens.
“You have a new feature to write, so you open a blank file and start coding — building out the logic, the conditionals, the edge case handling. An hour in, you write some tests to verify it. Two of them fail. You're now debugging code you just wrote, guessing which assumption was wrong, and the design has already calcified around untested behavior.”
“You write a Test List of seven cases before touching implementation. Each Red phase takes two minutes, each Green phase takes three. After five cycles, you have a fully tested, passing module — and its design is naturally decoupled because every piece of behavior was extracted only when a failing test demanded it. The Refactor phase finds one naming issue and removes duplicated setup. The test suite is the documentation.”
The same skill, where the work happens.
No new app to learn. The methodology runs over the WhatsApp Business API, so the answer lands as a reply in the thread you’re already in — same rigour, zero context-switch.
What it does, specifically.
Each capability is a distinct move drawn straight from the source methodology — not a generic assistant guessing.
Test List Generation
Before writing any code, enumerate all the cases your implementation must handle — happy paths, edge cases, error conditions, and boundary values. Getting everything out of your head and into an explicit list prevents scope creep mid-cycle and gives you a clear, finite runway.
Red Phase Failing Test Design
Write the smallest possible failing test for one item on your Test List, using the 'Assert First' pattern — beginning with the assertion you want to be true, then working backwards to the setup. The test must fail for the right reason before you touch production code.
Green Phase Implementation Strategy (Fake It / Obvious Implementation)
Choose between 'Fake It Till You Make It' (hard-code the simplest return value that passes) and 'Obvious Implementation' (write the real solution directly) based on how confident you are in the correct path. This keeps steps honest and prevents over-engineering during the Green phase.
Triangulation & Generalization Coaching
When a fake or hard-coded implementation has passed its first test, write a second test with a different concrete example to force real generalization. Triangulation is the disciplined escape from fake code — it lets the tests do the driving rather than your assumptions about what the general solution should look like.
Refactor Phase Code Review
Once all tests are green, scan both production code and test code for duplication, poor naming, and structural coupling, then suggest refactoring steps that preserve the green suite. Refactoring is strictly separated from the Green phase — no behavior changes while cleaning up.
Graded before it shipped.
Every skill is scored against independent scenarios for methodology fidelity before it goes live — not vibes, a rubric.
TDD Test List
A prioritized enumeration of all test cases for a given feature — happy paths, edge cases, error conditions — written before any production code. Serves as your roadmap and scope boundary for the entire development cycle.
Red-Green-Refactor Cycle Log
A running record of each mini-cycle: the failing test written, the implementation strategy chosen (Fake It or Obvious), and the refactoring applied. Makes the TDD discipline visible and reviewable by you or your team.
Fake-It-to-Real Generalization Trace
A documented path from a hard-coded fake implementation through successive Triangulation tests to a real, generalized solution — showing exactly how the tests drove the design rather than speculation.
Refactor Checklist
A post-green checklist of duplication, naming issues, and structural smells in both production and test code, with suggested refactoring steps each small enough to keep the suite fully green throughout.
Grounded in the original work.
Every answer traces back to a real source and the practitioner who wrote it — not a secondhand summary. Here is the source of record.
Kent Beck
Kent Beck is the creator of Extreme Programming (XP) and the author of 'Test-Driven Development: By Example' (Addison-Wesley, 2002), widely regarded as the definitive text on the discipline. He co-created JUnit with Erich Gamma — the framework that spawned pytest, RSpec, Jest, and virtually every xUnit-style test runner in use today. Beck was a signatory of the Agile Manifesto and later served as a Distinguished Engineer at Meta, applying and teaching TDD on production systems at scale.
Test-Driven Development: By Example (Addison-Wesley, 2002)
Creator of Extreme Programming; co-creator of JUnit with Erich Gamma; Agile Manifesto signatory; author of 'Test-Driven Development: By Example' (Addison-Wesley, 2002).
Be first to run it.
Test-Driven Development (TDD) is being built right now. Leave your email and we’ll tell you the moment it goes live.