← ClaudeAtlas

test-driven-developmentlisted

Enforce RED-GREEN-REFACTOR discipline for every implementation task. Use for all new features, bug fixes, and refactors. The core rule — if you didn't watch the test fail, you don't know if it tests the right thing.
RBraga01/a-team · ★ 6 · AI & Automation · score 71
Install: claude install-skill RBraga01/a-team
# Test-Driven Development ## The Core Rule ``` IF YOU DIDN'T WATCH THE TEST FAIL, YOU DON'T KNOW IF IT TESTS THE RIGHT THING. ``` A green test you've never seen red is not a test — it's a decoration. ## The Three Phases (Non-Negotiable) ### Phase RED — Write a Failing Test Write the test FIRST. Not after. Not "I'll add it later." **First.** The test must: - Describe the behavior you want, not the implementation - Be specific enough to fail for the right reason - Cover the exact scenario you're about to implement ```typescript // RED: Write this BEFORE writing the function test('returns empty array when no users match the filter', () => { const result = filterActiveUsers([]) expect(result).toEqual([]) }) ``` **Run it. Watch it fail.** ```bash npm test -- --testPathPattern="user-filter" # Expected: FAIL (function doesn't exist yet) ``` If the test passes before you write the implementation: the test is wrong. Rewrite it. ### Phase GREEN — Write Minimal Implementation Write the **smallest possible code** that makes the test pass. Nothing more. - No extra features "while I'm here" - No optimization - No handling of edge cases not yet covered by tests - Ugly code that passes is better than beautiful code that doesn't exist yet ```typescript // GREEN: Minimal implementation that passes the test function filterActiveUsers(users: User[]): User[] { return users.filter(u => u.active) } ``` **Run it. Watch it pass.** ```bash npm test -- --testPathPattern="user-fil