| name | test-first |
| description | Drive one feature through a strict TDD Red-Green-Refactor cycle with checklists for each phase. Use when implementing new functionality test-first, or when the user runs /test-first. |
| user-invocable | true |
Test-Driven Development
Implement TDD for: $ARGUMENTS
Quick Steps
- Write a failing test
- Run test, confirm failure
- Write minimal code to pass
- Refactor while keeping tests green
- Repeat
Red Phase - Write Failing Test
Test Design Principles
- Test one specific behavior
- Test name describes expected result
- Test should fail (feature doesn't exist yet)
Must Test
Example
it('should return JWT token for valid credentials', async () => {
const res = await request(app)
.post('/auth/login')
.send({ email: 'test@example.com', password: 'password123' })
expect(res.status).toBe(200)
expect(res.body.token).toBeDefined()
})
Green Phase - Minimal Implementation
Implementation Principles
- Write ONLY enough code to pass the test
- Don't optimize yet
- Don't worry about elegance
- Just make it work
Refactor Phase - Clean Up
Refactoring Checklist
Refactoring Rules
- Keep tests passing
- Change one thing at a time
- Run tests frequently
Test Quality Checklist
Follow TDD strictly. No shortcuts.