$npx -y skills add fusengine/agents --skill tddUse when writing production code that needs tests - new features, bug fixes, refactoring. Enforces RED-GREEN-REFACTOR cycle before any implementation.
| 1 | # TDD Skill |
| 2 | |
| 3 | Write the test first. Watch it fail. Write minimal code to pass. |
| 4 | |
| 5 | ## The Iron Law |
| 6 | |
| 7 | **No production code without a failing test first.** |
| 8 | |
| 9 | Every line of production code must be justified by a test that failed without it. |
| 10 | No exceptions. No shortcuts. No "I'll test after." |
| 11 | |
| 12 | --- |
| 13 | |
| 14 | ## Agent Workflow |
| 15 | |
| 16 | ``` |
| 17 | 1. DETECT -> Identify stack, test framework, existing test patterns |
| 18 | 2. RED -> Write ONE failing test for the next behavior |
| 19 | 3. VERIFY -> Run test, confirm it fails for the EXPECTED reason |
| 20 | IF the test fails for a DIFFERENT reason (syntax error, wrong import, missing fixture) → fix the test itself and re-run. Do NOT proceed to GREEN until the failure matches the intended behavior. |
| 21 | 4. GREEN -> Write the SIMPLEST code that makes the test pass |
| 22 | 5. VERIFY -> Run tests, confirm ALL pass (new + existing) |
| 23 | 6. REFACTOR -> Clean up while keeping all tests green |
| 24 | 7. REPEAT -> Next behavior = next failing test |
| 25 | ``` |
| 26 | |
| 27 | **CRITICAL**: Never skip VERIFY steps. A test that passes on first run proves nothing. |
| 28 | |
| 29 | --- |
| 30 | |
| 31 | ## RED-GREEN-REFACTOR Cycle |
| 32 | |
| 33 | See [references/red-green-refactor.md](references/red-green-refactor.md) for the detailed cycle with rules and verification steps. |
| 34 | |
| 35 | --- |
| 36 | |
| 37 | ## Reference Guide |
| 38 | |
| 39 | | Topic | Reference | |
| 40 | |-------|-----------| |
| 41 | | Full RED-GREEN-REFACTOR cycle | [red-green-refactor.md](references/red-green-refactor.md) | |
| 42 | | Common mistakes and red flags | [anti-patterns.md](references/anti-patterns.md) | |
| 43 | | Per-stack test commands | [stack-commands.md](references/stack-commands.md) | |
| 44 | |
| 45 | --- |
| 46 | |
| 47 | ## Quick Reference: Test Commands |
| 48 | |
| 49 | | Stack | Run Tests | Watch Mode | |
| 50 | |-------|-----------|------------| |
| 51 | | React/Next.js | `npx vitest run` | `npx vitest` | |
| 52 | | Laravel | `php artisan test` | `php artisan test --watch` | |
| 53 | | Swift | `swift test` | - | |
| 54 | | Generic TS | `bunx vitest run` | `bunx vitest` | |
| 55 | | Go | `go test ./...` | - | |
| 56 | | Rust | `cargo test` | `cargo watch -x test` | |
| 57 | |
| 58 | --- |
| 59 | |
| 60 | ## Forbidden Behaviors |
| 61 | |
| 62 | - Never write production code before a failing test |
| 63 | - Never skip the VERIFY RED step |
| 64 | - Never accept a test that passes on first run without investigation |
| 65 | - Never mock what you can test directly |
| 66 | - Never write more than one test at a time in RED phase |
| 67 | - Never add features beyond what the current test requires |