Implement Plan
Execute approved technical plans from thoughts/shared/plans/ with optional TDD mode.
When to Use
- •
/implement_plan [plan-path] - •"implement plan", "execute plan", "follow the plan"
- •按计划实现, 执行方案
- •"use tdd", "test driven", "测试驱动开发" (enables TDD mode)
Execution Modes
| Mode | When to Use |
|---|---|
| Direct (default) | 1-3 tasks, quick focused work |
| Agent Orchestration | 4+ tasks, context preservation critical |
| TDD Mode | User requests test-driven development |
TDD Mode (RED-GREEN-REFACTOR)
Triggers: "use tdd", "test driven", "测试驱动", "red green refactor"
When TDD mode is detected, follow this cycle for each feature:
RED: Write Failing Test
- •Write a test for the next small behavior
- •Run the test - it should FAIL
- •Commit:
test(scope): add test for [feature]
GREEN: Make It Pass
- •Write minimal code to make the test pass
- •Run the test - it should PASS
- •Commit:
feat(scope): implement [feature]
REFACTOR: Clean Up
- •Improve code structure without changing behavior
- •Run all tests - they should still pass
- •Commit:
refactor(scope): [description]
TDD Principles
- •Small steps: Each cycle 5-15 minutes
- •Fast feedback: Tests should run quickly
- •No premature optimization: Get it working first
- •Test behavior, not implementation: Focus on what, not how
TDD Checklist
- • Test is written before implementation
- • Test fails before implementation (RED)
- • Minimal code to pass (GREEN)
- • Refactor while tests pass
- • All tests pass after refactor
Getting Started
Detect Mode
Check user input for TDD keywords:
- •Contains "tdd", "test driven", "测试驱动" → TDD Mode
- •Otherwise → Standard Mode
Standard Mode Steps
- •Read plan completely (check existing
[x]marks) - •Read original ticket + all mentioned files (FULLY)
- •Create tasks with
TaskCreatefor each phase (set dependencies) - •Start implementing (update task status as you go)
TDD Mode Steps
- •Read plan and identify testable units
- •For each unit:
- •RED: Write failing test
- •GREEN: Implement to pass
- •REFACTOR: Clean up code
- •Verify all tests pass
- •Update plan checkboxes
Reference Menu
| Reference | Load When |
|---|---|
references/task-management.md | Task creation/tracking patterns |
references/agent-orchestration.md | Using agent mode (4+ tasks) |
references/task-executor.md | Single task TDD workflow |
Direct Implementation
For small plans (≤3 tasks):
Standard Mode
- •Implement each phase yourself
- •Run success criteria checks
- •Update checkboxes in plan
- •Pause for manual verification per phase
TDD Mode
- •Break down into testable units
- •For each unit, cycle through RED-GREEN-REFACTOR
- •Commit after each phase (RED/GREEN/REFACTOR)
- •Run full test suite after refactor
- •Update checkboxes in plan
Verification Flow
code
Phase N Complete - Ready for Manual Verification Automated verification passed: - [List automated checks] Please perform manual verification: - [List manual items from plan] Let me know when ready for Phase N+1.
Agent Orchestration
For larger plans (4+ tasks), use agent orchestration:
code
"I'll use agent orchestration for this plan"
Then follow references/agent-orchestration.md.
Quick Setup
bash
mkdir -p thoughts/handoffs/<session-name> # See references/task-executor.md for TDD workflow
Resuming Work
If plan has existing [x] marks:
- •Trust completed work is done
- •Pick up from first unchecked item
- •Verify previous work only if something seems off
If Things Don't Match
code
Issue in Phase [N]: Expected: [what the plan says] Found: [actual situation] Why this matters: [explanation] How should I proceed?
Resumable Agents
Check .claude/cache/agents/agent-log.jsonl for agent IDs.
code
Task( resume="<agentId>", prompt="Phase 2 isn't matching. Can you clarify..." )