.wai/resources/agent-config/skills/tdd/SKILL.md
Implement features following Test-Driven Development methodology. Red-Green-Refactor cycle with phased approach and verification at each step.
npx skillsauth add charly-vibes/wai tddInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Implement the requested feature following Test-Driven Development and a phased approach.
Red: Write a failing test that describes desired behavior Green: Write minimal code to make the test pass Refactor: Clean up code while keeping tests green
For complex features, create a plan first:
Plan structure:
# [Feature Name] Implementation Plan
## Current State
[What exists now]
## Desired End State
[What will exist, how to verify]
## Out of Scope
[What we're NOT doing]
## Phase 1: [Name]
### Changes Required
- File: `path/to/file.ext`
- Changes: [Description]
- Tests: [What tests to write]
### Success Criteria
#### Automated:
- [ ] New tests pass
- [ ] Existing tests still pass
- [ ] Type checking passes (if applicable)
#### Manual:
- [ ] [Specific manual verification]
## Phase 2: [Name]
[Continue...]
Get plan approved before proceeding.
For each phase:
// RED: Test describes what should happen
describe('UserAuthentication', () => {
it('should validate JWT tokens', async () => {
const token = 'valid.jwt.token'
const result = await validateToken(token)
expect(result).toEqual({ userId: '123', valid: true })
})
})
Run test: Confirm it fails (and fails for the right reason)
// GREEN: Minimal implementation to pass test
async function validateToken(token: string) {
// Simplest thing that could work
const decoded = jwt.verify(token, SECRET)
return {
userId: decoded.sub,
valid: true
}
}
Run test: Confirm it passes
// REFACTOR: Clean up while keeping tests green
async function validateToken(token: string): Promise<TokenResult> {
try {
const decoded = jwt.verify(token, getSecret()) as JWTPayload
return {
userId: decoded.sub,
valid: true
}
} catch (error) {
return { userId: null, valid: false, error: error.message }
}
}
Run tests: Confirm they still pass
Automated verification:
# Run all tests
npm test
# Run type checking (if applicable)
npm run type-check
# Run linting (if applicable)
npm run lint
Manual verification:
Phase 1 Complete - Ready for Verification
Automated verification:
- [x] Tests pass (12 new tests, all existing tests still passing)
- [x] Type checking passes
- [x] Linting passes
Manual verification needed:
- [ ] [Manual verification step 1]
- [ ] [Manual verification step 2]
Changes made:
- src/auth/validate.ts: Added validateToken function
- tests/auth/validate.test.ts: Added 12 tests covering valid/invalid tokens
Let me know when verified so I can proceed to Phase 2.
Wait for user confirmation before proceeding.
Continue with each phase following the same Red-Green-Refactor cycle.
If reality doesn't match the plan:
Issue in Phase [N]:
Expected: [What the plan says]
Found: [Actual situation]
Why this matters: [Explanation]
Options:
1. Adapt implementation to reality
2. Update plan to reflect new understanding
3. Discuss with user
How should I proceed?
Don't blindly follow an outdated plan.
If resuming from an existing plan:
testing
Compare original and distilled prompts to verify the distillation is faithful and lossless. Checks completeness, accuracy, and appropriate conciseness.
development
Orchestrate multi-agent code review with three waves - parallel analysis, cross-validation, and convergence check. Simulates specialist reviewers and synthesizes findings.
development
Apply Steve Yegge's Rule of 5 iterative review to any artifact - code, plans, research, issues, specs, or documents. Five stages from draft through excellence.
documentation
Resume work from a handoff document. Reads the handoff, verifies current state against documented state, and presents analysis before continuing work.