← ClaudeAtlas

dev-tddlisted

TDD development with Red-Green-Refactor cycle. Use to implement a feature by writing tests BEFORE the code. Trigger automatically when the user asks for TDD, wants to write tests first, mentions "test first", or asks to implement, add, create, fix, correct code, a new feature, a bugfix, or a functionality.
christopherlouet/claude-base · ★ 4 · AI & Automation · score 83
Install: claude install-skill christopherlouet/claude-base
# Test-Driven Development (TDD) ## Iron Law ``` NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST ``` If code was written before the test: delete it. Start over with TDD. - Don't keep it "as a reference" - Don't "adapt" it by writing the tests - Don't look at it - Delete = delete Implement from scratch starting from the tests. Period. ## TDD Cycle ``` ┌─────────┐ ┌─────────┐ ┌──────────┐ │ RED │ ──▶ │ GREEN │ ──▶ │ REFACTOR │ │ Test │ │ Code │ │ Clean │ │ fail │ │ pass │ │ up │ └─────────┘ └─────────┘ └──────────┘ ▲ │ └──────────────────────────────┘ ``` ## Phase 1: RED - Write a failing test ### Write ONE minimal test showing the expected behavior ```typescript describe('Module', () => { describe('function', () => { it('should [behavior] when [condition]', () => { // Arrange - Prepare // Act - Execute // Assert - Verify }); }); }); ``` ### Good test vs Bad test **Good**: Clear name, tests real behavior, one thing only ```typescript test('retries failed operations 3 times', async () => { let attempts = 0; const operation = () => { attempts++; if (attempts < 3) throw new Error('fail'); return 'success'; }; const result = await retryOperation(operation); expect(result).toBe('success'); expect(attempts).toBe(3); }); ``` **Bad**: Vague name, tests the mock instead of the code ```typescript test('retry works', async