Red → Green → Refactor — write tests first to drive design, reduce bugs, and build confidence in every change.
Five passes over the same idea, each from a different angle. Do them in order, or jump to whichever you need.
TDD inverts the traditional code-then-test workflow. Write a failing test (red), write minimal code to pass (green), then refactor. Benefits include better API design, fewer bugs, built-in regression protection, and documentation. TDD works best with clear requirements and pure functions.