main

name: test-driven-development description: Test-first implementation for behavior changes and bug fixes. USE WHEN the user requests tests, a behavior change, or a bug fix with practical automated coverage.

Test-Driven Development

Use TDD when automated coverage is practical. For configuration, documentation, or exploratory work, choose proportionate verification instead.

  1. Identify one observable behavior or regression.
  2. Write one focused test describing that behavior.
  3. Run it and confirm it fails for the expected missing behavior.
  4. Implement the smallest change that makes it pass.
  5. Run the focused test, then the relevant wider suite.
  6. Refactor only after everything is green.

Rules

  • Test behavior, not implementation details.
  • Keep each test focused; split tests that prove unrelated behaviors.
  • Use real code where practical; mock only unavoidable boundaries.
  • If a test is difficult to write, simplify the design or ask for guidance.
  • A test written after the implementation is useful coverage, but is not evidence that the test would have caught the regression.

Verify

Before completion, report the tests run and their outcome. If coverage was not practical, say why and report the alternative verification used.