From subagents
Ralph-style orchestrator loop — dispatches each phase as a subagent, hooks enforce progression
How this skill is triggered — by the user, by Claude, or both
Slash command
/subagents:workflowThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Dispatch each phase as a subagent. Hooks enforce output validation, gate checks, state advancement, and loop re-injection. This skill only handles the dispatch loop.
Dispatch each phase as a subagent. Hooks enforce output validation, gate checks, state advancement, and loop re-injection. This skill only handles the dispatch loop.
The orchestrator uses the Ralph Loop pattern: the Stop hook generates a phase-specific orchestrator prompt (~40-70 lines) via generate_phase_prompt() in schedule.sh every time Claude tries to stop. Claude reads state from disk and dispatches the current phase — no conversation memory required.
Claude dispatches phase N as a subagent (Task tool)
↓
Subagent completes
↓
SubagentStop hook fires:
- Validates output file exists
- Checks gate if at stage boundary
- Marks phase completed
- Advances state to phase N+1
- Exits silently (no stdout)
↓
Claude tries to stop (subagent done, nothing left to do)
↓
Stop hook fires:
- Generates phase-specific prompt via generate_phase_prompt() in schedule.sh
- Increments loopIteration in state
- Returns {"decision":"block","reason":"<phase-specific orchestrator prompt>"}
↓
Claude receives phase-specific orchestrator prompt
- Reads .agents/tmp/state.json (now pointing to phase N+1)
- Dispatches phase N+1 as a subagent
↓
Repeat until SubagentStop marks workflow "completed" → Stop hook allows exit
prompts/orchestrator-loop.md kept as reference only.| Phase | subagent_type | model | Notes |
|---|---|---|---|
| 0 | subagents:explorer | config | Parallel batch: dispatch 1-10 agents |
| 1.1 | subagents:brainstormer | config | Single agent |
| 1.2 | subagents:planner | config | Parallel batch: dispatch 1-10 agents |
| 1.3 | state.reviewer | inherit | Dynamic: codex-reviewer or claude-reviewer |
| 2.1 | complexity-routed agents | per-task | Easy→sonnet-task-agent, Medium→opus-task-agent, Hard→codex-task-agent (or opus if codexAvailable:false) |
| 2.2 | subagents:simplifier | config | Single agent |
| 2.3 | state.reviewer | inherit | Dynamic: codex-reviewer or claude-reviewer |
| 3.1 | state.testDeveloper | config | Dynamic: test-developer or codex-test-developer |
| 3.2 | state.failureAnalyzer | config | Dynamic: failure-analyzer or codex-failure-analyzer |
| 3.3 | state.testDeveloper | config | Dynamic: test-developer or codex-test-developer |
| 3.4 | state.reviewer | review-tier | Dynamic: codex-reviewer or claude-reviewer |
| 3.5 | state.reviewer | review-tier | Dynamic: codex-reviewer or claude-reviewer; coverage loop |
| 4.1 | state.docUpdater | config | Dynamic: doc-updater or codex-doc-updater |
| 4.2 | state.reviewer | inherit | Dynamic: codex-reviewer or claude-reviewer |
| 4.3 | subagents:completion-handler | config | Single agent |
For each phase dispatch, build the prompt as:
[PHASE {phase_id}]
{contents of prompts/phases/{phase_id}-*.md}
## Task Context
Task: {state.task}
## Input Files
{contents or summaries of input files for this phase}
The [PHASE {id}] tag is used by the PreToolUse hook to validate dispatches.
These phases dispatch multiple parallel subagents. The workflow skill:
The workflow skill does NOT handle errors directly. If a subagent fails:
If retries exhaust (hook keeps blocking):
/subagents:resumeIf configured (compaction.betweenStages or compaction.betweenPhases):
on-subagent-stop.sh hookon-subagent-stop.sh hookon-subagent-stop.sh hookon-stop.sh hookon-task-dispatch.sh hooknpx claudepluginhub kenkenmain/ken-cc-plugins --plugin subagentsProvides multi-agent workflow patterns: parallel dispatch, sequential pipelines, QC gates, and retry loops. Use when architecting systems with multiple agents or processing stages.
Defines orchestration protocols for multi-phase /workflow pipelines: handoffs, checkpoints, re-routing, parallel dispatch, and metrics tracking.
Guides using Claude Code dynamic workflows to orchestrate many subagents for large-scale tasks like codebase sweeps or migrations.