Ralph-style orchestrator loop — dispatches each phase as a subagent, hooks enforce progression
View on GitHubplugins/subagents/skills/workflow/SKILL.md
February 5, 2026
Select agents to install to:
npx add-skill https://github.com/kenkenmain/ken-cc-plugins/blob/main/plugins/subagents/skills/workflow/SKILL.md -a claude-code --skill workflowInstallation paths:
.claude/skills/workflow/# Workflow Orchestration
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.
## Execution Flow (Ralph-Style)
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
```
### Key Design: Separation of Concerns
- **SubagentStop hook** = pure side-effects (validate, advance state, exit silently)
- **Stop hook** = prompt re-injection (generates phase-specific prompt via schedule.sh, ~40-70 lines)
- **Orchestrator prompt** = phase-specific, generated per-iteration (reads state, dispatches current phase). `prompts/orchestrator-loop.md` kept as reference only.
## Phase Dispatch Mapping
| Phase | subagent_type | model | Notes |
| ----- | -------------------------- | -------- | ---------------------------------------- |
| 0 | subagents:explorer | config | Parallel batch: dispatch 1-