Coding with AI tools

Stage 5 · Lesson 2 of 6

Red, green, refactor with an AI tool

Tests first, so AI output is checked

(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

Practise

  • Every exercise ships with tests: practise reading them first, then writing your own extras

Keep handy

Also worth your time

Mark this stage as not done?