| name | tdd-workflow |
| description | Test-Driven Development workflow with strict Red-Green-Refactor cycle. Use when developing features with TDD, writing tests before code, or when test-driven approach is needed. MANDATORY order - test cases table BEFORE code, failing tests BEFORE implementation. |
TDD Workflow
Principle: Red -> Green -> Refactor (STRICT order!)
PHASE 0: Test Planning (FIRST STEP)
Fill test cases table BEFORE any code:
## TEST CASES (fill BEFORE implementation!)
| # | Scenario | Input | Expected Output | Type | Status |
|---|----------|-------|-----------------|------|--------|
| 1 | Happy path | <input> | <expected> | Unit | pending |
| 2 | Edge case: empty | [] | <expected> | Unit | pending |
| 3 | Edge case: null | null | Error | Unit | pending |
| 4 | Integration | <context> | <expected> | Integration | pending |
Coverage categories:
STOP: Do NOT proceed to Phase 1 until table is filled!
PHASE 1: RED -- Write Failing Tests
- Create test file (
feature.test.ts)
- Write tests for ALL cases from Phase 0 table
- Run tests -- they MUST FAIL:
npm test -- --grep "feature"
STOP: Do NOT write implementation until tests fail!
PHASE 2: GREEN -- Minimal Code
- Write MINIMAL code to make tests pass
- Do NOT optimize, do NOT add "for later"
- Run tests:
npm test -- --grep "feature"
- Repeat for each test case
STOP: Do NOT refactor until ALL tests are green!
PHASE 3: REFACTOR
- All tests green? -> Refactor
- Remove duplication, improve readability
- After EACH change:
npm test (must stay green)
PHASE 4: VERIFY
## TDD VERIFICATION
| Category | Written | Passing | Skipped |
|----------|---------|---------|---------|
| Happy path | X | X | 0 |
| Edge cases | X | X | 0 |
| Error cases | X | X | 0 |
| Integration | X | X | 0 |
| **TOTAL** | X | X | 0 |
FORBIDDEN
- Writing code BEFORE test cases table
- Writing code BEFORE failing tests
- Refactoring with red tests
- Skipping checkpoints
- "I'll write tests later"