Multi-agent parallel development cycle with requirement analysis, exploration planning, code development, and validation. Supports continuous iteration with markdown progress documentation...
Multi-agent parallel development cycle using Codex subagent pattern with four specialized workers:
Orchestration logic (phase management, state updates, feedback coordination) runs inline in the main flow β no separate orchestrator agent is spawned. Only 4 worker agents are allocated.
Each agent maintains one main document (e.g., requirements.md, plan.json, implementation.md) that is completely rewritten per iteration, plus auxiliary logs (changes.log, debug-log.ndjson) that are append-only.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β User Input (Task) β
ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
β
v
ββββββββββββββββββββββββββββββββ
β Main Flow (Inline Orchestration) β
β Phase 1 β 2 β 3 β 4 β
ββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββΌβββββββββββββββββββββ
β β β
v v v
ββββββββββ ββββββββββ ββββββββββ
β RA β β EP β β CD β
βAgent β βAgent β βAgent β
ββββββββββ ββββββββββ ββββββββββ
β β β
ββββββββββββββββββββββΌβββββββββββββββββββββ
β
v
ββββββββββ
β VAS β
β Agent β
ββββββββββ
β
v
ββββββββββββββββββββββββββββββββ
β Summary Report β
β & Markdown Docs β
ββββββββββββββββββββββββββββββββ
history/ directorydiscoveries.ndjson β read on start, write as you discover, eliminating redundant codebase exploration| Arg | Required | Description |
|---|---|---|
| TASK | One of TASK or --cycle-id | Task description (for new cycle, mutually exclusive with --cycle-id) |
| --cycle-id | One of TASK or --cycle-id | Existing cycle ID to continue (from API or previous session) |
| --extend | No | Extension description (only valid with --cycle-id) |
| --auto | No | Auto-cycle mode (run all phases sequentially without user confirmation) |
| --parallel | No | Number of parallel agents (default: 4, max: 4) |
When --auto: Run all phases sequentially without user confirmation between iterations. Use recommended defaults for all decisions. Automatically continue iteration loop until tests pass or max iterations reached.
When prep-package.json exists at {projectRoot}/.workflow/.cycle/prep-package.json, Phase 1 consumes it to:
Prep packages are generated by the interactive prompt /prompts:prep-cycle. See phases/00-prep-checklist.md for schema.
Input Parsing:
ββ Parse arguments (TASK | --cycle-id + --extend)
ββ Convert to structured context (cycleId, state, progressDir)
ββ Initialize progress tracking: functions.update_plan([...phases])
Phase 1: Session Initialization
ββ Ref: phases/01-session-init.md
ββ Create new cycle OR resume existing cycle
ββ Initialize state file and directory structure
ββ Output: cycleId, state, progressDir
Phase 2: Agent Execution (Parallel)
ββ Ref: phases/02-agent-execution.md
ββ Tasks attached: Spawn RA β Spawn EP β Spawn CD β Spawn VAS β Wait all
ββ Spawn RA, EP, CD, VAS agents in parallel
ββ Wait for all agents with timeout handling
ββ Output: agentOutputs (4 agent results)
Phase 3: Result Aggregation & Iteration
ββ Ref: phases/03-result-aggregation.md
ββ Parse PHASE_RESULT from each agent
ββ Detect issues (test failures, blockers)
ββ Decision: Issues found AND iteration < max?
β ββ Yes β Send feedback via followup_task, loop back to Phase 2
β ββ No β Proceed to Phase 4
ββ Output: parsedResults, iteration status
Phase 4: Completion & Summary
ββ Ref: phases/04-completion-summary.md
ββ Generate unified summary report
ββ Update final state
ββ Sync session state: $session-sync -y "Dev cycle complete: {iterations} iterations"
ββ Close all agents
ββ Output: final cycle report with continuation instructions
Phase Reference Documents (read on-demand when phase executes):
| Phase | Document | Purpose |
|---|---|---|
| 1 | phases/01-session-init.md | Session creation/resume and state initialization |
| 2 | phases/02-agent-execution.md | Parallel agent spawning and execution |
| 3 | phases/03-result-aggregation.md | Result parsing, feedback generation, iteration handling |
| 4 | phases/04-completion-summary.md | Final summary generation and cleanup |
User Input (TASK | --cycle-id + --extend)
β
[Parse Arguments]
β cycleId, state, progressDir
Phase 1: Session Initialization
β cycleId, state, progressDir (initialized/resumed)
Phase 2: Agent Execution
ββ All agents read coordination/discoveries.ndjson on start
ββ Each agent explores β writes new discoveries to board
ββ Later-finishing agents benefit from earlier agents' findings
β agentOutputs {ra, ep, cd, vas} + shared discoveries.ndjson
Phase 3: Result Aggregation
β parsedResults, hasIssues, iteration count
β [Loop back to Phase 2 if issues and iteration < max]
β (discoveries.ndjson carries over across iterations)
Phase 4: Completion & Summary
β finalState, summaryReport
Return: cycle_id, iterations, final_state
{projectRoot}/.workflow/.cycle/
βββ {cycleId}.json # Master state file
βββ {cycleId}.progress/
βββ ra/
β βββ requirements.md # Current version (complete rewrite)
β βββ changes.log # NDJSON complete history (append-only)
β βββ history/ # Archived snapshots
βββ ep/
β βββ exploration.md # Codebase exploration report
β βββ architecture.md # Architecture design
β βββ plan.json # Structured task list (current version)
β βββ changes.log # NDJSON complete history
β βββ history/
βββ cd/
β βββ implementation.md # Current version
β βββ debug-log.ndjson # Debug hypothesis tracking
β βββ changes.log # NDJSON complete history
β βββ history/
βββ vas/
β βββ summary.md # Current version
β βββ changes.log # NDJSON complete history
β βββ history/
βββ coordination/
βββ discoveries.ndjson # Shared discovery board (all agents append)
βββ timeline.md # Execution timeline
βββ decisions.log # Decision log
Master state file: {projectRoot}/.workflow/.cycle/{cycleId}.json
{
"cycle_id": "cycle-v1-20260122T100000-abc123",
"title": "Task title",
"description": "Full task description",
"status": "created | running | paused | completed | failed",
"created_at": "ISO8601", "updated_at": "ISO8601",
"max_iterations": 5, "current_iteration": 0,
"agents": {
"ra": { "status": "idle | running | completed | failed", "output_files": [] },
"ep": { "status": "idle", "output_files": [] },
"cd": { "status": "idle", "output_files": [] },
"vas": { "status": "idle", "output_files": [] }
},
"current_phase": "init | ra | ep | cd | vas | aggregation | complete",
"completed_phases": [],
"requirements": null, "plan": null, "changes": [], "test_results": null,
"coordination": { "feedback_log": [], "blockers": [] }
}
Recovery: If state corrupted, rebuild from .progress/ markdown files and changes.log.
// Initialize progress tracking after input parsing
functions.update_plan([
{ id: "phase-1", title: "Phase 1: Session Initialization", status: "in_progress" },
{ id: "phase-2", title: "Phase 2: Agent Execution", status: "pending" },
{ id: "phase-3", title: "Phase 3: Result Aggregation", status: "pending" },
{ id: "phase-4", title: "Phase 4: Completion & Summary", status: "pending" }
])
// After Phase 1 completes
functions.update_plan([
{ id: "phase-1", status: "completed" },
{ id: "phase-2", status: "in_progress" }
])
// After Phase 2 completes
functions.update_plan([
{ id: "phase-2", status: "completed" },
{ id: "phase-3", status: "in_progress" }
])
// After Phase 3 β iterate or complete
// If iterating back to Phase 2:
functions.update_plan([
{ id: "phase-3", status: "completed" },
{ id: "phase-2", title: "Phase 2: Agent Execution (Iteration N)", status: "in_progress" }
])
// If proceeding to Phase 4:
functions.update_plan([
{ id: "phase-3", status: "completed" },
{ id: "phase-4", status: "in_progress" }
])
// After Phase 4 completes
functions.update_plan([{ id: "phase-4", status: "completed" }])
Archive: copy requirements.md β history/requirements-v1.0.0.md
Rewrite: overwrite requirements.md with v1.1.0 (complete new content)
Append: changes.log β {"timestamp","version":"1.1.0","action":"update","description":"..."}
| Agent Output | Rewrite (per iteration) | Append-only |
|---|---|---|
| RA | requirements.md | changes.log |
| EP | exploration.md, architecture.md, plan.json | changes.log |
| CD | implementation.md, issues.md | changes.log, debug-log.ndjson |
| VAS | summary.md, test-results.json | changes.log |
Execution Order: RA β EP β CD β VAS (dependency chain, all spawned in parallel but block on dependencies)
All agents share a real-time discovery board at coordination/discoveries.ndjson. Each agent reads it on start and appends findings during work. This eliminates redundant codebase exploration.
Lifecycle:
echo '...' >> discoveries.ndjson to append entriesFormat: NDJSON, each line is a self-contained JSON with required top-level fields ts, agent, type, data:
{"ts":"2026-01-22T10:00:00+08:00","agent":"ra","type":"tech_stack","data":{"language":"TypeScript","framework":"Express","test":"Jest","build":"tsup"}}
Discovery Types:
| type | Dedup Key | Writers | Readers | Required data Fields |
|---|---|---|---|---|
tech_stack |
singleton | RA | EP, CD, VAS | language, framework, test, build |
project_config |
data.path |
RA | EP, CD | path, key_deps[], scripts{} |
existing_feature |
data.name |
RA, EP | CD | name, files[], summary |
architecture |
singleton | EP | CD, VAS | pattern, layers[], entry |
code_pattern |
data.name |
EP, CD | CD, VAS | name, description, example_file |
integration_point |
data.file |
EP | CD | file, description, exports[] |
similar_impl |
data.feature |
EP | CD | feature, files[], relevance |
code_convention |
singleton | CD | VAS | naming, imports, formatting |
utility |
data.name |
CD | VAS | name, file, usage |
test_command |
singleton | CD, VAS | VAS, CD | unit, integration(opt), coverage(opt) |
test_baseline |
singleton | VAS | CD | total, passing, coverage_pct, framework, config |
test_pattern |
singleton | VAS | CD | style, naming, fixtures |
blocker |
data.issue |
any | all | issue, severity, impact |
Protocol Rules:
echo >> β don't batchtype + dedup key value already existsPHASE_RESULT:
- phase: ra | ep | cd | vas
- status: success | failed | partial
- files_written: [list]
- summary: one-line summary
- issues: []
Feedback via followup_task (file refs + issue summary, never full content):
## FEEDBACK FROM [Source]
[Issue summary with file:line references]
## Reference
- File: .progress/vas/test-results.json (v1.0.0)
## Actions Required
1. [Specific fix]
Rules: Only main flow writes state file. Agents read state, write to own .progress/{agent}/ directory only.
functions.update_plan initialization, then Phase 1 executionfunctions.update_plan at each phase transition| Error Type | Recovery |
|---|---|
| Agent timeout | followup_task requesting convergence, then retry |
| State corrupted | Rebuild from progress markdown files and changes.log |
| Agent failed | Re-spawn agent with previous context |
| Conflicting results | Main flow sends reconciliation request |
| Missing files | RA/EP agents identify and request clarification |
| Max iterations reached | Generate summary with remaining issues documented |
functions.update_plan with phase statusfunctions.update_plan phase completion| Document | Purpose |
|---|---|
| roles/ | Agent role definitions (RA, EP, CD, VAS) |
# Start new cycle
/parallel-dev-cycle TASK="Implement real-time notifications"
# Continue cycle
/parallel-dev-cycle --cycle-id=cycle-v1-20260122-abc123
# Iteration with extension
/parallel-dev-cycle --cycle-id=cycle-v1-20260122-abc123 --extend="Also add email notifications"
# Auto mode
/parallel-dev-cycle --auto TASK="Add OAuth authentication"