Cfn Loop Task

--- description: "Execute CFN Loop in Task Mode with direct agent spawning (visible in main chat)" argument-hint: "<task descri…

masharratt 14 updated 23d ago
Claude CodeGeneric
View source ↗
---
description: "Execute CFN Loop in Task Mode with direct agent spawning (visible in main chat)"
argument-hint: "<task description> [--mode=mvp|standard|enterprise] [--max-iterations=n]"
allowed-tools: ["Task", "TodoWrite", "Read", "Bash", "Grep", "Glob"]
---

# CFN Loop Task Mode

**You are the coordinator. You MUST execute this loop until PROCEED or max iterations.**

---

## ⚡ AUTONOMOUS PROGRESSION (CRITICAL)

**DO NOT stop to ask questions. Keep progressing by launching agents for next steps.**

| Stop For | Keep Going For |
|----------|----------------|
| Major regression (tests went from passing to failing) | Minor test failures (iterate to fix) |
| Structural mismatch (wrong architecture/framework) | Missing files (create them) |
| Security vulnerability found | Code style issues |
| Corrupted state requiring manual recovery | Ambiguous implementation details |
| Unclear requirements (feedback for epic improvement) | |

**Rules:**
- If uncertain about approach, pick the simpler option and iterate
- Spawn agents to investigate unknowns instead of asking user
- Only escalate to user for irreversible decisions or access issues
- Test failures are expected - that's why we iterate

---

## 🎯 0/0 POLICY (EXIT CRITERIA)

**Before PROCEED decision, verify:**

| Metric | Requirement |
|--------|-------------|
| Compilation errors (scoped work) | **0** |
| Compilation errors (scoped tests) | **0** |
| Todos remaining (scoped work) | **0** |

```bash
# Verify 0/0 before PROCEED
npm run typecheck 2>&1 | grep -c "error" || echo "0"  # Must be 0
npm run build 2>&1 | grep -c "error" || echo "0"      # Must be 0
# Review TodoWrite - all scoped items must be completed

If not 0/0: ITERATE, do not PROCEED. Fix errors before next gate check.


MANDATORY: Initialize State Tracking

IMMEDIATELY create this todo list using TodoWrite:

1. [pending] Parse arguments and initialize task
2. [pending] LOOP 3: Full epic implementation (all phases, TDD)
3. [pending] GATE CHECK: Run tests and validate pass rate
4. [pending] VOTE VERIFICATION: cfn-vote-implement on review manifest
5. [pending] FINAL ROUTING: Auto-impl unanimous, PO 2/3, batched user prompts for 1/3

You MUST update todo status as you complete each phase. Do NOT skip phases.


THE LOOP (Execute Until Done)

┌─────────────────────────────────────────────────────────────┐
│  PHASE A — IMPLEMENTATION (iterate until gate passes):      │
│    ITERATION = 1                                            │
│    WHILE iteration <= MAX_ITERATIONS:                       │
│      ├── LOOP 3: Spawn impl agents (full epic, TDD)         │
│      ├── GATE CHECK: Run tests, calculate pass rate         │
│      │     ├── IF pass_rate < threshold: iteration++, LOOP  │
│      │     └── IF pass_rate >= threshold: BREAK to Phase B  │
│      └── END WHILE                                          │
│                                                             │
│  PHASE B — VOTE VERIFICATION (single pass):                 │
│    ├── Generate review manifest from implementation         │
│    ├── /cfn-vote-implement on manifest                      │
│    │     ├── 3/3 votes: auto-implement immediately (TDD)    │
│    │     ├── 2/3 votes: spawn product-owner to decide       │
│    │     ├── 1/3 votes: queue for batched user prompts      │
│    │     └── 0/3 votes: skip silently                       │
│    └── After all votes processed:                           │
│          └── AskUserQuestion (4 per batch) on 1/3 queue     │
│                                                             │
│  EXIT — All vote outcomes resolved                          │
└─────────────────────────────────────────────────────────────┘

PHASE 1: Parse Arguments

Mark todo #1 as in_progress, then execute:

# Parse from $ARGUMENTS
MODE="standard"  # or mvp, enterprise
MAX_ITERATIONS=10
TASK_ID="cfn-task-$(date +%s)-${RANDOM}"
ITERATION=1
Mode Gate Threshold Consensus Threshold
mvp 70% 80%
standard 95% 90%
enterprise 98% 95%

Mark todo #1 as completed. Proceed to Phase 2.


PHASE 2: LOOP 3 - Full Epic Implementation

Mark todo #2 as in_progress.

Scope: Spawn agents to implement the entire epic (all phases of the plan) in one pass, not a single sprint slice. TDD throughout. Agent count and roles come from the plan generated by /write-plan.

Spawn implementer agents in parallel using Task tool (one per implementation lane):

TASK: Full epic implementation, iteration ${ITERATION}: ${TASK_DESCRIPTION}

SCOPE: Complete every phase of the linked plan (planning/PLAN_${SLUG}.md).
       Do NOT stop after a single sprint - implement the whole epic.

REQUIREMENTS:
1. Write failing tests FIRST (TDD red phase) for every acceptance criterion
2. Implement to satisfy tests (green phase)
3. Refactor for DRY / quality (refactor phase)
4. Run: npm test
5. Report: { "tests_passed": N, "tests_total": M, "files_modified": [...], "phases_complete": [...] }

AGENT_ID: loop3-impl-${TASK_ID}-iter${ITERATION}-<lane>

WAIT for all agents to complete and aggregate results.

Mark todo #2 as completed. Proceed to Phase 3.


PHASE 3: GATE CHECK (Mandatory Before Loop 2)

Mark todo #3 as in_progress.

YOU MUST RUN THIS - DO NOT SKIP:

# Run tests
npm test 2>&1 | tee /tmp/test-output-${TASK_ID}.txt

# Parse results (adjust grep pattern for your test runner)
PASS_COUNT=$(grep -oP '\d+(?= pass)' /tmp/test-output-${TASK_ID}.txt | head -1 || echo 0)
TOTAL_COUNT=$(grep -oP '\d+(?= (test|spec))' /tmp/test-output-${TASK_ID}.txt | head -1 || echo 1)
PASS_RATE=$(echo "scale=2; $PASS_COUNT / $TOTAL_COUNT" | bc)

echo "Gate Check: ${PASS_COUNT}/${TOTAL_COUNT}

Maintain Cfn Loop Task?

Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.

[Cfn Loop Task on getagentictools](https://getagentictools.com/loops/masharratt-cfn-loop-task-mode?ref=badge)