Use when adding new error messages to React, or seeing "unknown error code" warnings.
8
2
# Install this skill:
npx skills add claude-world/director-mode-lite --skill "test-first"
Install specific skill from multi-skill repository
# Description
Test-Driven Development (TDD Red-Green-Refactor)
# SKILL.md
name: test-first
description: Test-Driven Development (TDD Red-Green-Refactor)
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
- [ ] Normal case
- [ ] Edge cases
- [ ] Error cases
- [ ] Invalid input
Example
// auth/login.test.ts
it('should return JWT token for valid credentials', async () => {
const res = await request(app)
.post('/auth/login')
.send({ email: '[email protected]', 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
- [ ] Is there code duplication?
- [ ] Are variable names clear?
- [ ] Are functions too long?
- [ ] Is the logic too complex?
Refactoring Rules
- Keep tests passing
- Change one thing at a time
- Run tests frequently
Test Quality Checklist
- [ ] Unit tests cover core logic
- [ ] Integration tests cover interactions
- [ ] Test names clearly describe intent
- [ ] Tests are independent and repeatable
- [ ] Tests run fast (unit tests < 100ms)
- [ ] Edge cases are covered
Follow TDD strictly. No shortcuts.
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Amp
Antigravity
Claude Code
Clawdbot
Codex
Cursor
Droid
Gemini CLI
GitHub Copilot
Goose
Kilo Code
Kiro CLI
OpenCode
Roo Code
Trae
Windsurf
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.