Agent skill
tdd
Implement features following Test-Driven Development methodology. Red-Green-Refactor cycle with phased approach and verification at each step.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/tdd-charly-vibes-wai-3
SKILL.md
Implement with TDD Workflow
Implement the requested feature following Test-Driven Development and a phased approach.
Core Principle: Red, Green, Refactor
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
Process
Phase 0: Plan (If needed)
For complex features, create a plan first:
- Read relevant code to understand current state
- Identify what needs to change
- Break work into logical phases
- Define success criteria (automated and manual)
- Get user approval of plan before implementing
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.
Phase 1: Implement First Component
For each phase:
Step 1: Write Failing Test
// 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)
Step 2: Implement Minimal Code
// 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
Step 3: Refactor If Needed
// 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
Step 4: Verify Phase Completion
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:
- [Specific manual tests from plan]
Step 5: Inform User
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.
Phase 2, 3, etc.: Repeat
Continue with each phase following the same Red-Green-Refactor cycle.
Key Guidelines
- Tests first, always - Write the test before the implementation
- Minimal implementation - Write just enough code to pass the test
- One phase at a time - Complete and verify before moving on
- Keep tests green - Never commit with failing tests
- Refactor with green tests - Only clean up when tests pass
- Verify at each phase - Automated and manual checks
- Update plan - Check off completed items as you go
When Things Don't Match
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.
Resuming Work
If resuming from an existing plan:
- Read the plan completely
- Check for items already checked off
- Start from first unchecked item
- Verify previous work if something seems off
- Continue with Red-Green-Refactor cycle
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?