|
| 1 | +--- |
| 2 | +name: spec-subagent-orchestrator |
| 3 | +description: Orchestrate complex work by combining spec-kit artifacts with the right subagent execution workflow. Use when a task should be structured through `spec.md`, `plan.md`, or `tasks.md` before implementation; when Codex needs to decide whether to fill missing spec-kit stages first; or when execution should be routed between direct work, `subagent-driven-development`, and `subagent-supervisor-constitution`. Triggers on requests to combine spec with subagents, run large multi-step delivery with explicit routing, or turn a spec-driven process into a governed execution system. |
| 4 | +--- |
| 5 | + |
| 6 | +# Spec Subagent Orchestrator |
| 7 | + |
| 8 | +## Overview |
| 9 | + |
| 10 | +Use this skill as a thin orchestration layer. Do not replace spec-kit or existing subagent skills; decide when to invoke them, in what order, and with which verification gates. |
| 11 | + |
| 12 | +Core rule: lock the right spec artifact first, then choose the lightest execution model that still protects quality and coordination. |
| 13 | +Execution model rule: assume a single master orchestrator with no recursive agent tree. To get value from subagents, slice work into atomic executor tasks and dispatch them in multiple rounds. |
| 14 | + |
| 15 | +## Workflow |
| 16 | + |
| 17 | +1. Inspect what already exists. |
| 18 | + Look for `spec.md`, `plan.md`, `tasks.md`, or equivalent spec-kit outputs before doing new work. |
| 19 | +2. Close the earliest missing artifact. |
| 20 | + If the work is still ambiguous, route to spec first. |
| 21 | + If the spec exists but execution shape does not, route to plan. |
| 22 | + If the plan exists but actionable slices are missing, route to tasks. |
| 23 | +3. Classify execution risk and coupling. |
| 24 | + Judge independence, write-scope overlap, review churn risk, blast radius, and whether the task can be expressed as an atomic executor unit. |
| 25 | +4. Route to the execution mode. |
| 26 | + Use direct execution for small, tightly scoped work. |
| 27 | + Use [$subagent-driven-development](/Users/welsir/.codex/superpowers/skills/subagent-driven-development/SKILL.md) when tasks are mostly independent and can be executed as separate atomic slices in the current session. |
| 28 | + Use [$subagent-supervisor-constitution](/Users/welsir/.codex/skills/subagent-supervisor-constitution/SKILL.md) when the work is medium/high risk, cross-module, drift-prone, or expensive to review incorrectly. |
| 29 | +5. Enforce closure gates. |
| 30 | + No task is complete until spec alignment, quality review, and local verification all pass. |
| 31 | + |
| 32 | +## Routing Rules |
| 33 | + |
| 34 | +Use this decision order: |
| 35 | + |
| 36 | +1. Is the task still underspecified? |
| 37 | + Route to the missing spec-kit stage instead of delegating early. |
| 38 | +2. Is the next step blocked on one tightly coupled change? |
| 39 | + Stay local only long enough to create atomic slices or dispatch a boundary-locking subagent. Do not keep the whole implementation on the master by default. |
| 40 | +3. Can the next work be written as one or more atomic executor tasks? |
| 41 | + If not, keep narrowing boundaries until it can. |
| 42 | +4. Are there task slices with clean ownership and low overlap? |
| 43 | + Route to `subagent-driven-development`. |
| 44 | +5. Are there repeated alignment loops, strict boundaries, or high regression risk? |
| 45 | + Route to `subagent-supervisor-constitution`. |
| 46 | +6. Are both true? |
| 47 | + Lock constitution first, then let the supervisor pattern govern dispatch. |
| 48 | + |
| 49 | +Default heuristics: |
| 50 | + |
| 51 | +- Prefer direct work when there are fewer than 3 short steps and no meaningful branch risk. |
| 52 | +- Prefer `subagent-driven-development` when tasks are already decomposed into atomic executor slices and write scopes are largely disjoint. |
| 53 | +- Prefer `subagent-supervisor-constitution` when task count is not the main problem but coordination risk is. |
| 54 | +- Prefer one boundary-locking subagent over long local reasoning when context pressure is rising but execution slices are not yet ready. |
| 55 | + |
| 56 | +Read [workflow-routing.md](references/workflow-routing.md) when the routing choice is not obvious. |
| 57 | + |
| 58 | +## Atomic Executor Rule |
| 59 | + |
| 60 | +Never dispatch a generic worker with a vague brief. Dispatch only atomic executor tasks. |
| 61 | + |
| 62 | +An atomic executor task must have: |
| 63 | + |
| 64 | +- One concrete goal |
| 65 | +- One primary deliverable |
| 66 | +- Explicit file or module boundaries |
| 67 | +- Explicit acceptance checks |
| 68 | +- Enough context to execute without re-discovering the whole project |
| 69 | + |
| 70 | +If a task fails these checks, it is not ready for delegation. Narrow it first or use a scoping pass to create smaller slices. |
| 71 | + |
| 72 | +## Lifecycle Slots |
| 73 | + |
| 74 | +Use fixed lifecycle slots, not a fixed cast of agent types: |
| 75 | + |
| 76 | +- `scope` |
| 77 | + Lock boundaries, ownership, and dependency edges. |
| 78 | +- `execute` |
| 79 | + Produce one atomic deliverable. |
| 80 | +- `review` |
| 81 | + Check spec alignment or quality for one slice. |
| 82 | +- `integrate` |
| 83 | + Combine accepted slices and resolve seams. |
| 84 | +- `repair` |
| 85 | + Fix a concrete failed gate. |
| 86 | + |
| 87 | +Each slot can be instantiated multiple times across rounds. Do not assume one broad executor can safely absorb multiple slots. |
| 88 | + |
| 89 | +## Operating Procedure |
| 90 | + |
| 91 | +### 1. Stabilize the artifact chain |
| 92 | + |
| 93 | +- Confirm which of these exists: problem statement, spec, plan, tasks, validation targets. |
| 94 | +- Do not let subagents invent scope that should have been locked in spec-kit artifacts. |
| 95 | +- If the user already has `spec.md`, `plan.md`, and `tasks.md`, treat those as the source of truth. |
| 96 | + |
| 97 | +### 2. Choose the execution wrapper |
| 98 | + |
| 99 | +- For independent implementation slices in the current session, invoke `subagent-driven-development`. |
| 100 | +- For high-risk or cross-boundary work, invoke `subagent-supervisor-constitution` first and follow its constitution, ownership, and gate rules. |
| 101 | +- If the task is exploratory, ambiguous, or mostly design, stay local only until a scoping pass can define the next atomic slice. |
| 102 | +- If context compression is already hurting the master, dispatch a scoping subagent before doing more local analysis. |
| 103 | + |
| 104 | +### 3. Preserve ownership clarity |
| 105 | + |
| 106 | +- Give each executor a precise write scope. |
| 107 | +- Keep the main agent responsible for routing, integration, and final verification. |
| 108 | +- Do not let executors redefine acceptance criteria. |
| 109 | +- Do not hand one executor multiple unrelated deliverables just because they touch nearby files. |
| 110 | + |
| 111 | +### 4. Dispatch in rounds, not trees |
| 112 | + |
| 113 | +- Assume subagents do not recursively spawn their own child graph. |
| 114 | +- Use the master to simulate depth through multiple dispatch rounds. |
| 115 | +- Typical pattern: `scope -> execute -> review -> repair -> integrate`. |
| 116 | +- Add more executors only when the extra slice lowers total coordination cost. |
| 117 | + |
| 118 | +### 5. Close with explicit gates |
| 119 | + |
| 120 | +- Spec gate: output matches `spec.md` and task scope. |
| 121 | +- Quality gate: code or deliverable is maintainable and regression-aware. |
| 122 | +- Command gate: rerun the important checks locally before claiming success. |
| 123 | + |
| 124 | +## Non-Goals |
| 125 | + |
| 126 | +- Do not rewrite spec-kit prompts or artifacts. |
| 127 | +- Do not duplicate the internal procedures of the subagent skills. |
| 128 | +- Do not dispatch vague, multi-goal executor tasks. |
| 129 | +- Do not force subagents into tiny tasks where the overhead is larger than the work. |
| 130 | +- Do not delegate before task boundaries are real. |
| 131 | +- Do not assume recursive subagent trees are available. |
| 132 | + |
| 133 | +## Outputs |
| 134 | + |
| 135 | +When using this skill, produce a short orchestration decision: |
| 136 | + |
| 137 | +1. Current artifact state |
| 138 | + Which spec-kit artifacts exist and which are missing. |
| 139 | +2. Chosen route |
| 140 | + Direct work, `subagent-driven-development`, or `subagent-supervisor-constitution`. |
| 141 | +3. Why this route |
| 142 | + Independence, risk, coupling, or review-cost reasoning. |
| 143 | +4. Next concrete action |
| 144 | + The exact next command, skill, or task slice to run. |
| 145 | +5. Atomic slice definition |
| 146 | + If delegating, state the exact deliverable, write boundary, and acceptance check for the next executor. |
0 commit comments