Execute an approved implementation plan following TDD methodology. Works through phases with Red-Green-Refactor cycles, verifying completion at each step.
Implement an approved plan following Test-Driven Development methodology.
When given a plan path:
If no plan path provided, ask the user which plan to implement or list available plans.
Follow the Red, Green, Refactor cycle:
Never skip the Red phase - watching tests fail confirms they actually test something.
// Example: Write failing test first
describe('validateToken', () => {
it('should accept valid JWT tokens', async () => {
const token = 'valid.jwt.token'
const result = await validateToken(token)
expect(result.valid).toBe(true)
})
})
// Run test: npm test
// ❌ FAILED: validateToken is not defined
// Good - fails for the right reason
// Minimal implementation to pass test
export async function validateToken(token: string) {
const decoded = jwt.verify(token, SECRET)
return { valid: true, userId: decoded.sub }
}
// Run test: npm test
// ✓ PASSED
// Refactored with better error handling
export async function validateToken(token: string): Promise<TokenResult> {
try {
const decoded = jwt.verify(token, getSecret()) as JWTPayload
return {
valid: true,
userId: decoded.sub
}
} catch (error) {
return {
valid: false,
userId: null,
error: error.message
}
}
}
// Run test: npm test
// ✓ Still passing after refactor
Automated verification:
# Run all tests (not just the new ones)
npm test
# Type checking (if applicable)
npm run type-check # or tsc --noEmit
# Linting (if applicable)
npm run lint
# Build (if applicable)
npm run build
Manual verification:
Phase [N] Complete - Ready for Verification
Automated verification:
- [x] All tests pass (15 tests, 3 new)
- [x] Type checking passes
- [x] Build succeeds
Manual verification needed:
- [ ] [Manual step 1 from plan]
- [ ] [Manual step 2 from plan]
Changes made:
- src/auth/validate.ts:25-45 - Added validateToken function
- tests/auth/validate.test.ts:12-28 - Added 3 tests for token validation
Let me know when verified so I can proceed to Phase [N+1].
Wait for user confirmation before proceeding to next phase.
If the plan doesn't match what you find:
Issue in Phase [N]:
Expected (from plan): [What the plan says]
Found (in codebase): [Actual situation]
Why this matters: [Impact explanation]
Options:
1. Adapt implementation to current reality
2. Update the plan to reflect new understanding
3. Ask user for guidance
How should I proceed?
Important: Don't blindly follow an outdated or incorrect plan. Reality wins.
If the plan has checkmarks indicating completed work:
Phase [N]: The tests I was about to write already pass. It appears this work was already completed.
Verification:
- [x] Tests exist and pass
- [x] Implementation matches plan requirements
Marking phase complete and moving to next phase.
Phase [N]: Issue encountered
I wrote tests for [feature] but after [X] attempts, can't make them pass due to [specific reason].
Options:
1. Revise the approach (suggest alternative)
2. Update the plan (if requirements changed)
3. Need more research/context
How should we proceed?
Phase [N]: Alternative approach discovered
While implementing [feature], I discovered [better pattern/approach].
Current plan: [Approach from plan]
Alternative: [New approach]
Tradeoffs: [Pros/cons]
Should I:
1. Continue with plan as written
2. Update plan and use new approach
3. Discuss further
Phase [N]: Blocked by external dependency
Cannot proceed because [dependency] is [unavailable/broken/different than expected].
Impact: [What this blocks]
Workaround options: [If any]
Need guidance on how to proceed.
If using an issue tracker (GitHub Issues, Jira, etc.):
Before starting:
# Note the issue ID in commits
# Reference the plan in issue comments
After completing a phase:
# Update issue with progress
# Link commits to issue
# Add "Completed Phase N" comment
After completing all phases:
# Close or mark issue as ready for review
# Link to relevant commits/PRs
After implementation:
/commit skill to commit changes thoughtfully/describe-pr skill to create comprehensive PR descriptions/code-review skill to self-review before committingIf need to pause:
wai close (or /create-handoff skill) to document progress