Implement a plan with iterative loop until completion
Executes plan files iteratively with automatic verification until all requirements and exit criteria pass.
/plugin marketplace add GantisStorm/essentials-claude-code/plugin install essentials@essentials-claude-code<plan_path> [--step|--auto] [--max-iterations N]Execute a plan file iteratively until all todos are complete AND exit criteria pass.
IMPORTANT: The plan file is your source of truth. Exit Criteria MUST pass before the loop will end.
Iterative implementation with automatic verification ensures plans are fully executed with quality checks.
This command works with plans from:
/plan-creator - Implementation plans/bug-plan-creator - Bug fix plans/code-quality-plan-creator - LSP-powered quality plansThe command accepts:
<plan_path>: Path to the plan file (required)--step: Step mode (default) - pause after each todo for human control--auto: Auto mode - skip pauses but still follow todo order--max-iterations N: Maximum number of iterations before stopping"${CLAUDE_PLUGIN_ROOT}/scripts/setup-implement-loop.sh" $ARGUMENTS
You are now in implement loop mode. Your task is to implement the plan completely.
Read the plan file specified above. Extract:
After reading the plan, automatically assess and decompose if thresholds are exceeded:
| Signal | Threshold | Action |
|---|---|---|
| Files to modify | >5 files | AUTO decompose by file group |
| Total lines | >500 lines | AUTO decompose by feature |
| Subsystems | >2 unrelated areas | AUTO decompose by subsystem |
| Dependencies | Complex ordering | AUTO decompose with ordering |
This is AUTOMATIC - no user prompt needed. If triggers are met, decompose immediately.
Auto-Decomposition Process:
/proposal-creator → /beads-loopReport in output:
COMPLEXITY ASSESSMENT:
- Files: N (threshold: 5)
- Lines: N (threshold: 500)
- Subsystems: N (threshold: 2)
- Decision: [DIRECT | AUTO_DECOMPOSED]
- Groups created: [list if decomposed]
Use TodoWrite to create a todo for each:
Example todo structure:
1. [pending] Implement changes to src/auth/handler.py
2. [pending] Create new file src/auth/oauth_provider.py
3. [pending] Write unit tests per Testing Strategy
4. [pending] Run test suite and fix failures
5. [pending] Run exit criteria verification
6. [pending] Complete post-implementation verification
For each todo:
Before declaring completion:
## Exit Criteria section in the plan### Verification Script commandWhen you try to exit:
If context is compacted and you lose track:
## Exit Criteria sectionAdditional notes:
Step mode pauses after each todo for human control. This prevents context compaction and quality degradation on large plans.
After completing each todo, you MUST:
Before pausing, output execution status:
===============================================================
TODO COMPLETED: <todo-name>
===============================================================
Progress: N/M todos complete
EXECUTION ORDER (remaining):
Next → Todo 3: Add validation logic
Then → Todo 4: Write unit tests
Then → Todo 5: Run exit criteria
===============================================================
Then use AskUserQuestion:
The options MUST include:
Example:
Use AskUserQuestion with:
- question: "Todo complete. Next: Add validation logic. Continue?"
- header: "Next step"
- options:
- label: "Continue (Recommended)"
description: "Proceed to: Add validation logic"
- label: "Stop"
description: "End the implement loop here"
Based on the response:
Auto mode (--auto flag): Skips pauses but still follows todo order.
/implement-loop <plan_path> [--step|--auto]
│
▼
┌───────────────────────────────────────────────────────────────┐
│ STEP 1: SETUP │
│ │
│ • Run setup-implement-loop.sh with arguments │
│ • Enter implement loop mode │
└───────────────────────────────────────────────────────────────┘
│
▼
┌───────────────────────────────────────────────────────────────┐
│ STEP 2: READ PLAN │
│ │
│ • Extract files to edit/create │
│ • Extract implementation instructions │
│ • Extract exit criteria and verification script │
│ • Extract testing strategy, risk analysis, success metrics │
└───────────────────────────────────────────────────────────────┘
│
▼
┌───────────────────────────────────────────────────────────────┐
│ STEP 3: AUTO-ASSESS & DECOMPOSE │
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ COMPLEXITY CHECK: │ │
│ │ │ │
│ │ Files >5? → AUTO decompose by file group │ │
│ │ Lines >500? → AUTO decompose by feature │ │
│ │ Subsystems >2? → AUTO decompose by subsystem │ │
│ │ │ │
│ │ Output: COMPLEXITY ASSESSMENT report │ │
│ └─────────────────────────────────────────────────────────┘ │
└───────────────────────────────────────────────────────────────┘
│
▼
┌───────────────────────────────────────────────────────────────┐
│ STEP 4-5: CREATE & IMPLEMENT TODOS │
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ TODO LOOP: │ │
│ │ │ │
│ │ For each todo: │ │
│ │ 1. Mark in_progress │ │
│ │ 2. Read relevant plan section │ │
│ │ 3. Implement changes │ │
│ │ 4. Verify implementation │ │
│ │ 5. Mark completed │ │
│ │ │ │
│ │ Step mode: Pause after each todo (AskUserQuestion) │ │
│ │ Auto mode: Continue without pauses │ │
│ └─────────────────────────────────────────────────────────┘ │
└───────────────────────────────────────────────────────────────┘
│
▼
┌───────────────────────────────────────────────────────────────┐
│ STEP 6-7: EXIT CRITERIA VERIFICATION │
│ │
│ • Run verification script from plan │
│ • If PASS (exit 0) → Implementation complete │
│ • If FAIL → Fix issues, retry loop │
│ • If todos incomplete → Continue loop │
└───────────────────────────────────────────────────────────────┘
│
▼
┌───────────────────────────────────────────────────────────────┐
│ OUTPUT: Implementation Complete │
│ │
│ • All todos marked completed │
│ • Exit criteria verification passed │
│ • Success metrics validated │
└───────────────────────────────────────────────────────────────┘
| Scenario | Action |
|---|---|
| Plan file not found | Report error and exit |
| Exit criteria fail | Fix issues and retry verification |
| Context compacted | Re-read plan file, check todo status, continue |
| Implementation issues | Consult Risk Analysis for rollback strategy |
| Very large plan (>1000 lines) | Suggest escalating to /proposal-creator → /beads-loop |
| Todos remain incomplete | Loop continues until all complete |
# Implement a feature plan with step mode (default)
/implement-loop .plans/add-user-auth.md
# Implement with auto mode (no pauses)
/implement-loop .plans/fix-memory-leak.md --auto
# Implement with maximum iterations limit
/implement-loop .plans/refactor-api.md --max-iterations 10
# Implement a bug fix plan
/implement-loop .plans/bug-null-pointer.md --step