CCW Chain Orchestrator
Chain-based workflow orchestrator using chain_loader for progressive step loading and LLM-driven decision routing.
Discovery
chain_loader list — list all chains with triggers, entries, and descriptions
- Match user intent to chain
triggers.task_types / triggers.keywords
chain_loader inspect — preview chain node graph and available entries
chain_loader start — begin from default entry, named entry (entry_name), or any node (node)
Execution Protocol
When chain_loader delivers a step node with a skill/command doc:
- Read the loaded doc content to understand the skill's purpose and interface
- Assemble the Skill call:
Skill(skill_name, args)
- First step:
args = "${analysis.goal}"
- Subsequent steps:
args = "" (auto-receives session context)
- Special args noted in step name (e.g.,
--bugfix, --hotfix, --plan-only)
- Propagate -y: If auto mode active, append
-y to args
- Execute:
Skill(skill_name, args) — blocking, wait for completion
- Advance:
chain_loader done to proceed to next step
const autoYes = /\b(-y|--yes)\b/.test($ARGUMENTS);
function assembleCommand(skillName, args, previousResult) {
if (!args && previousResult?.session_id) {
args = `--session="${previousResult.session_id}"`;
}
if (autoYes && !args.includes('-y') && !args.includes('--yes')) {
args = args ? `${args} -y` : '-y';
}
return { skill: skillName, args };
}
Auto Mode (-y / --yes)
- D1 Clarity Check: always choose "Clear" (skip clarification)
- Confirmation: skip, execute directly
- Error handling: auto-skip failed steps, continue pipeline
- Propagation:
-y injected into every downstream Skill call
Delegation Protocol
When chain_loader returns delegate_depth > 0:
- Continue normal execution (read content, assemble Skill, execute)
- On
returned_from_delegate: true, resume parent chain context
- Variables received from child chain are available for subsequent steps
Preloaded Context
When chain_loader start returns preloaded_keys:
- Preloaded content is available via
chain_loader content for the entire session
- Reference preloaded context when assembling Skill calls
- Use preloaded memory/project context to inform all downstream steps
Progress Visualization
After each chain_loader done, call chain_loader visualize to show progress.
Display the visualization in execution log for user awareness.
Variable Propagation
Intent analysis results (task_type, goal, auto_yes) are stored as chain variables.
assembleCommand() reads variables from chain_loader status for Skill args.
Variables automatically flow through delegation via pass_variables/receive_variables.
Phase-Level Execution (Skill Chain Delegation)
When the current chain is a skill-level chain (entered via delegation from a category chain):
- Each step delivers phase doc content directly (not SKILL.md)
- Execute phase instructions inline — do NOT wrap in
Skill() call
- Reference preloaded
skill-context for orchestration patterns (TodoWrite, data flow, error handling)
- Phase execution produces artifacts (files, session state) consumed by the next phase
- The chain system controls phase progression — no need for internal phase orchestration
Architecture: Chain Definition Layers
- Category chains (8):
ccw-chain/chains/ — routing and orchestration (ccw-main, ccw-standard, etc.)
- Workflow skill chains (7):
.claude/workflow-skills/*/chains/ — skill-level chains with phase content
- Phase content:
.claude/skills/*/phases/ — original phase files, referenced via @skills/ prefix
- Category chains delegate to workflow skill chains via
findChainAcrossSkills() fallback
- Content refs:
@phases/ = skill-relative, @skills/ = project .claude/skills/ relative
1---2name: ccw-chain3description: Chain-based CCW workflow orchestrator. Intent analysis, workflow routing, and Skill pipeline execution via progressive chain loading. Triggers on "ccw chain", "chain ccw", "workflow chain".4---56# CCW Chain Orchestrator78Chain-based workflow orchestrator using `chain_loader` for progressive step loading and LLM-driven decision routing.910## Discovery11121. `chain_loader list` — list all chains with triggers, entries, and descriptions132. Match user intent to chain `triggers.task_types` / `triggers.keywords`143. `chain_loader inspect` — preview chain node graph and available entries154. `chain_loader start` — begin from default entry, named entry (`entry_name`), or any node (`node`)1617## Execution Protocol1819When `chain_loader` delivers a step node with a skill/command doc:20211. **Read** the loaded doc content to understand the skill's purpose and interface222. **Assemble** the Skill call: `Skill(skill_name, args)`23 - First step: `args = "${analysis.goal}"`24 - Subsequent steps: `args = ""` (auto-receives session context)25 - Special args noted in step name (e.g., `--bugfix`, `--hotfix`, `--plan-only`)263. **Propagate -y**: If auto mode active, append `-y` to args274. **Execute**: `Skill(skill_name, args)` — blocking, wait for completion285. **Advance**: `chain_loader done` to proceed to next step2930```javascript31const autoYes = /\b(-y|--yes)\b/.test($ARGUMENTS);3233function assembleCommand(skillName, args, previousResult) {34 if (!args && previousResult?.session_id) {35 args = `--session="${previousResult.session_id}"`;36 }37 if (autoYes && !args.includes('-y') && !args.includes('--yes')) {38 args = args ? `${args} -y` : '-y';39 }40 return { skill: skillName, args };41}42```4344## Auto Mode (`-y` / `--yes`)4546- D1 Clarity Check: always choose "Clear" (skip clarification)47- Confirmation: skip, execute directly48- Error handling: auto-skip failed steps, continue pipeline49- Propagation: `-y` injected into every downstream Skill call5051## Delegation Protocol5253When `chain_loader` returns `delegate_depth > 0`:541. Continue normal execution (read content, assemble Skill, execute)552. On `returned_from_delegate: true`, resume parent chain context563. Variables received from child chain are available for subsequent steps5758## Preloaded Context5960When `chain_loader start` returns `preloaded_keys`:611. Preloaded content is available via `chain_loader content` for the entire session622. Reference preloaded context when assembling Skill calls633. Use preloaded memory/project context to inform all downstream steps6465## Progress Visualization6667After each `chain_loader done`, call `chain_loader visualize` to show progress.68Display the visualization in execution log for user awareness.6970## Variable Propagation7172Intent analysis results (`task_type`, `goal`, `auto_yes`) are stored as chain variables.73`assembleCommand()` reads variables from `chain_loader status` for Skill args.74Variables automatically flow through delegation via `pass_variables`/`receive_variables`.7576## Phase-Level Execution (Skill Chain Delegation)7778When the current chain is a skill-level chain (entered via delegation from a category chain):791. Each step delivers **phase doc content** directly (not SKILL.md)802. **Execute phase instructions inline** — do NOT wrap in `Skill()` call813. Reference preloaded `skill-context` for orchestration patterns (TodoWrite, data flow, error handling)824. Phase execution produces artifacts (files, session state) consumed by the next phase835. The chain system controls phase progression — no need for internal phase orchestration8485## Architecture: Chain Definition Layers8687- **Category chains** (8): `ccw-chain/chains/` — routing and orchestration (ccw-main, ccw-standard, etc.)88- **Workflow skill chains** (7): `.claude/workflow-skills/*/chains/` — skill-level chains with phase content89- **Phase content**: `.claude/skills/*/phases/` — original phase files, referenced via `@skills/` prefix90- Category chains delegate to workflow skill chains via `findChainAcrossSkills()` fallback91- Content refs: `@phases/` = skill-relative, `@skills/` = project `.claude/skills/` relative