Stage 5 · Lesson 2 of 6
Red, green, refactor with an AI tool
(TDD) is a short loop. Red: write a failing test and run it, so you see it fail for the right reason. Green: make the smallest change that passes it.
: tidy the code while the tests stay green. With an AI tool, you write the red test, the tool proposes the green change, you both run the tests, and you refactor with the tool's help and the tests as a safety net. Seeing red first proves the test can fail; a test that has never failed may be checking nothing.
Keep each loop small: one behaviour at a time. You do not need strict TDD for everything, but for AI-assisted work it is the most reliable way to know the code does what you meant.
Common trapskipping the red step, then trusting a test that would have passed anyway.
A question to check yourself, an AI practice session and 1 cheat sheet entry come when you add the roadmap to your account. Add it
Resources for this stage
Start with· follow one of these
- BookFreeTest-Driven Development with Python (Obey the Testing Goat)
Harry Percival · Intermediate
Free online: test-driven development taught step by step on a real web app
- BookPaidTest Driven Development: By Example
Kent Beck (Addison-Wesley) · Intermediate · Paid
Kent Beck's short classic on the red, green, refactor loop, worked through by example