Agent skill
tdd-loop
Test-Driven Development loop for audit refactor tasks. Automatically picks next task, enforces test-first, runs validation. Based on Ralph Wiggum AI Loop Technique.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/tdd-loop
SKILL.md
TDD Loop Skill
Automated Test-Driven Development workflow for completing audit refactor tasks.
When to Use
- Running
/tdd-loopto start automated task completion - Working through
skill_audit_refactor.jsontasks systematically - Enforcing test-first development with automated validation
Commands
| Command | Description |
|---|---|
/tdd-loop |
Start TDD loop for next priority task |
/tdd-next |
Show next task without starting loop |
/tdd-summary |
Show audit refactor progress summary |
/tdd-loop --skill <name> |
Loop on specific skill tasks |
/tdd-loop --priority P0 |
Loop on specific priority level |
How It Works
Based on Ralph Wiggum AI Loop Technique:
┌─────────────────────────────────────────────────────────────┐
│ TDD LOOP WORKFLOW │
├─────────────────────────────────────────────────────────────┤
│ │
│ 1. PICK TASK │
│ └─ Read skill_audit_refactor.json │
│ └─ Select highest priority task with test_exists: false │
│ │
│ 2. RED PHASE (Create Failing Test) │
│ └─ Create test file at specified path │
│ └─ Write test cases for expected behavior │
│ └─ Run test (should FAIL) │
│ └─ Update test_exists: true │
│ │
│ 3. GREEN PHASE (Implement Fix) │
│ └─ Implement the fix in source file │
│ └─ Run test (should PASS) │
│ └─ Update implemented: true │
│ │
│ 4. VISUAL PHASE (If Needed) │
│ └─ Take screenshot with Chrome DevTools MCP │
│ └─ Compare with baseline │
│ └─ Verify UI renders correctly │
│ │
│ 5. VALIDATE & LOOP │
│ └─ Update tested: true in audit file │
│ └─ Commit changes │
│ └─ Continue to next task │
│ │
└─────────────────────────────────────────────────────────────┘
TDD Guard Hooks
The TDD Loop uses hooks to enforce test-first:
PreToolUse Hook (tdd-guard.js)
- Intercepts Edit/Write operations
- Checks if target file has test_exists: false
- BLOCKS implementation if test doesn't exist
- Provides guidance on creating tests first
PostToolUse Hook (test-validator.js)
- Runs after file modifications
- Executes related tests automatically
- Updates task status on success
- Recommends visual testing for UI components
Usage Example
# Start TDD loop for highest priority task
/tdd-loop
# Work on specific skill
/tdd-loop --skill nuxt
# Work on critical issues only
/tdd-loop --priority P0-critical
# Check progress
/tdd-summary
Task File Structure
Tasks are defined in skill_audit_refactor.json:
{
"id": "sec-1",
"description": "Fix non-timing-safe CSRF comparison",
"file": "server/utils/cartSecurity.ts",
"test_file": "tests/server/utils/__tests__/cartSecurity.test.ts",
"test_exists": false,
"implemented": false,
"tested": false,
"tasks": [
{ "id": "sec-1-a", "task": "Create unit test for timing-safe comparison", "type": "test-first" },
{ "id": "sec-1-b", "task": "Replace string comparison with crypto.timingSafeEqual()", "type": "implementation" },
{ "id": "sec-1-c", "task": "Run unit test to validate fix", "type": "validation" },
{ "id": "sec-1-d", "task": "Visual test: verify cart operations work", "type": "visual-test" }
]
}
Loop Control
The loop continues until:
- All tasks in filter are completed
- Maximum iterations reached (default: 50)
- User cancels with
/cancel-tdd - An error requires manual intervention
Best Practices
- Always check progress first: Run
/tdd-summarybefore starting - Start with P0-critical: Focus on security and critical fixes first
- Commit frequently: After each task completion
- Review visual tests: Don't skip UI verification for components
- Update audit file: Mark tasks complete as you go
References
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?