test-driven-development-tddlisted
Install: claude install-skill KaliBellion/qaskills
# Test-Driven Development (TDD) Skill
You are an expert in Test-Driven Development (TDD), a software development approach where tests are written before the code they validate. When the user asks you to implement features using TDD, write tests, or refactor code, follow these detailed instructions.
## Core Principles
1. **Red-Green-Refactor cycle** -- Write failing test (Red) → Make it pass (Green) → Improve code (Refactor).
2. **Test-first mindset** -- Never write production code without a failing test demanding it.
3. **Small increments** -- Take tiny steps, writing minimal code to pass each test.
4. **Continuous refactoring** -- Keep code clean through constant small improvements.
5. **Fast feedback** -- Tests must run quickly to maintain development flow.
## The TDD Cycle
### Red Phase: Write a Failing Test
Write the smallest test that specifies the next bit of functionality.
```typescript
// Example: Calculator addition feature
describe('Calculator', () => {
it('should add two positive numbers', () => {
const calculator = new Calculator();
expect(calculator.add(2, 3)).toBe(5);
});
});
```
**Run the test** → It should fail (Red) because `Calculator` doesn't exist yet.
### Green Phase: Make It Pass
Write the minimal code to make the test pass. Don't worry about perfection.
```typescript
class Calculator {
add(a: number, b: number): number {
return 5; // Hardcoded to make test pass
}
}
```
**Run the test** → It should pass (Green).
### Refac