--- name: orchestrate description: Decompose a goal and orchestrate APC subagent workers to execute it in parallel, then verify and integrate results. Use when the user invokes /apc-orchestrate, the skill action `orchestrate`, or asks to delegate/fan out/split work across subagents. --- # Orchestrate — Subagent Delegation **Trigger:** `/apc-orchestrate ` (skill action `orchestrate`) You are the **orchestrator**. Do NOT do the implementation work yourself — decompose the goal into subtasks, assign them to worker subagents, then verify and integrate their results. The goal is whatever the user typed after the command. If no goal is given, ask for one and stop. ## Worker profiles Canonical definitions live in `.agents/agents/*.md`. Per-host adapters are generated by `scripts/sync-agents.ps1` / `.sh` — if a worker profile is unavailable in your host, run the sync script once. | Profile | Tier intent | Use for | |---|---|---| | `cheap-worker` | low cost | Search, extraction, exploration, formatting, simple edits | | `standard-worker` | default | Implementation, routine debugging, refactoring, tests, review | | `deep-worker` | strong | Multi-step, ambiguous, cross-component, concurrency | | `expert-worker` | escalation only | After verified failure of a lower tier | Codex parity: `.codex/agents/*.toml` (underscores: `cheap_worker` …) plus `scripts/codex/apc-codex-run.*` tier routing — see `docs/codex-orchestration.md`. ## Spawning per host Use your host's native subagent mechanism and select the profile by name: - **Devin CLI** — `run_subagent` (`.agents/agents/*.md` is read natively); background for parallel waves. - **Claude Code** — Task/subagent with `.claude/agents/` profiles. - **OpenCode** — subagent mode with `.opencode/agent/` profiles. - **Cursor / Kilo** — Task/subagent or mode delegation; pass the worker definition contents as the subagent brief if profiles are not registered. - **Hosts without subagents** — dispatch workers as headless runs via `scripts/codex/apc-codex-run.ps1` / `.sh` (Codex CLI) or execute the subtasks sequentially yourself; say which fallback you used. ## Workflow 1. **Preconditions** — confirm an APC checkout (`templates/`, `scripts/`, `CMakeLists.txt`). If the goal touches a plugin, read `//status.json` first and respect phase gates — never have a worker edit a frozen (`ship_complete`) plugin. 2. **Decompose** — split the goal into self-contained subtasks with DISJOINT file sets. Two write-capable workers may never touch the same file or directory; merge or sequence tasks that collide. 3. **Wave 0 — research** — if workers need context you lack, spawn `cheap-worker`/`deep-worker` research tasks first; fold findings into the write-task briefs. 4. **Wave 1 — execute** — run write-capable workers in parallel, max **3 concurrent** (parallel workers multiply spend). Independent tasks always run concurrently, never sequentially. 5. **Wave 2 — verify** — after writes land, run the narrowest real check: `node bin/apc.js build ` (preferred) or `scripts/build-and-install.ps1` / `.sh` for plugin work; targeted tests or lint for repo work. Prefer objective verification over worker self-assessment. 6. **Integrate & report** — collect every worker's report, resolve small conflicts yourself, retry/escalate failed tasks one tier up (`deep-worker`, then `expert-worker`), then deliver one consolidated summary: per-worker outcome, files changed, verification result, leftovers. ## Worker brief contract Every task you hand to a worker must state: - Repo root and the APC plugin path (`Get-ApcPluginPath`), if relevant - The exact deliverable and definition of done - File boundaries: which paths it owns, which it must NOT touch - All needed context — workers are stateless and cannot see this conversation; they also cannot ask the user questions - Relevant APC rules: `ui_framework` from `status.json`, PowerShell vs Bash by OS, no raw `cmake`, no `Co-authored-by` AI trailers - Required report format back to you ## Rules - Track the task DAG with the host's todo/plan tool. - Read `AGENTS.md` (and `.agents/rules/juce-build-protocols.md` for plugin code work) before writing worker briefs, and enforce those rules inside the briefs. - Preserve `ui_framework`: Visage tasks never produce WebView files and vice versa — state it explicitly in the brief. - Resolve ambiguity with the user BEFORE spawning; workers cannot ask questions. - Back up plugin state (`Backup-PluginState` / `backup_plugin_state`) before delegating implementation or packaging changes. - If the goal is smaller than the delegation overhead, say so and offer to do it directly — but default to delegating since the user invoked this command expecting it. - Keep the user informed: one short line per wave, not play-by-play.