name: tdd description: TDD (Test-Driven Development) workflow. Use when writing tests, implementing features with TDD, or when user says "go" to proceed with plan.md allowed-tools: Read, Write, Edit, Bash, Grep, Glob
TDD Workflow
Follow Kent Beck's TDD cycle: Red → Green → Refactor
Cycle
- Red: Write the simplest failing test first
- Green: Implement minimum code to make tests pass
- Refactor: Improve structure only after tests pass
Test Writing
- Use meaningful names describing behavior (e.g.,
shouldSumTwoPositiveNumbers) - Make failures clear and informative
- Write one test at a time
Implementation
- Write just enough code to pass - no more
- Use the simplest solution that could possibly work
- Run all tests after each change
Defect Fixing
- Write an API-level failing test first
- Write the smallest test replicating the problem
- Get both tests to pass
Refactoring Phase
- Only refactor when tests are passing (Green phase)
- Use established patterns with proper names
- Make one change at a time
- Run tests after each step
- Prioritize removing duplication and improving clarity
Example Workflow
- Write a simple failing test for a small part of the feature
- Implement bare minimum to pass
- Run tests to confirm (Green)
- Use
tidy-firstskill for structural changes - Use
commitskill for committing - Add another test for next increment
- Repeat until complete