
Tdd
Write tests first, then code using strict red-green-refactor TDD workflow
What You Can Do
You'll follow the strict TDD workflow: write a failing test that defines expected behavior, verify it fails, write minimal production code to pass the test, then refactor for quality. This approach ensures complete test coverage, catches bugs early, and produces well-designed code backed by comprehensive test suites. Claude guides you through each phase with examples and enforces TDD principles to prevent shortcuts.
Features
structured prompts for writing failing tests, implementing minimal code, and refactoring safely
ensures production code only exists to satisfy failing tests, with no exceptions
explains TDD principles and the 'Iron Law' to build discipline and understanding
shows good vs. bad test patterns with TypeScript/JavaScript examples
applies TDD to fixes, ensuring bugs don't reoccur
teaches how to write clear, behavior-focused tests without over-mocking
confirms each phase is complete before moving to the next
Example Output
Example 1: Retry Logic Feature
// RED: Write failing test
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);
});
// GREEN: Implement minimal code
export async function retryOperation(fn, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (e) {
if (i === maxRetries - 1) throw e;
}
}
}
// REFACTOR: Improve design and clarity
Example 2: Form Validation
// Test validates email format before implementation exists
test('validates email format', () => {
expect(isValidEmail('user@example.com')).toBe(true);
expect(isValidEmail('invalid.email')).toBe(false);
});
What's Included
- SKILL.md: complete TDD workflow with philosophy, Red-Green-Refactor cycle, and enforcement rules
- Test writing template: structure for clear, behavior-focused test cases
- Implementation checklist: steps for RED phase, GREEN phase, and REFACTOR phase
- Good vs. bad patterns guide: examples of proper TDD vs. anti-patterns
- Bug fix workflow: regression test template for fixing issues TDD-style
Who It's For
- Backend engineers building APIs and services with full test coverage
- Frontend developers implementing interactive components with predictable behavior
- QA/test engineers designing feature test strategies before coding
- Full-stack developers maintaining projects where regressions are costly
- Technical leads enforcing code quality and testability standards
Best For
- Building new features with critical reliability requirements
- Fixing bugs while preventing regressions
- Refactoring legacy code with test safety nets
- Teaching testing discipline and best practices
- Ensuring production code quality in mission-critical systems







