|
| 1 | +--- |
| 2 | +name: workflow-router |
| 3 | +model: sonnet |
| 4 | +description: Routes user goals to the appropriate specialist agent workflow with resource allocation confirmation. Use when: the user wants to start a task but hasn't specified a workflow, asks "how should I approach this?", or needs orchestration across research → plan → build → fix stages. |
| 5 | +category: agent-orchestration |
| 6 | + |
| 7 | +inputs: |
| 8 | + - name: goal |
| 9 | + type: string |
| 10 | + description: User's stated goal or task description — the router will classify and route it |
| 11 | + required: false |
| 12 | +outputs: |
| 13 | + - name: routed_workflow |
| 14 | + type: string |
| 15 | + description: Confirmation of the agent(s) dispatched and their assigned tasks, with handoff paths |
| 16 | +--- |
| 17 | + |
| 18 | +# Workflow Router |
| 19 | + |
| 20 | +Routes user goals to the appropriate specialist agent workflow with explicit resource allocation and confirmation before dispatch. |
| 21 | + |
| 22 | +## Description |
| 23 | + |
| 24 | +Classifies an incoming goal into one of four categories (Research, Plan, Build, Fix), maps it to the appropriate specialist agent(s), confirms resource allocation with the user, and dispatches. Handles the Fix workflow as a two-stage process (investigate first, then implement). Preserves context across agent handoffs using shared handoff documents. This skill is the entry point for multi-agent orchestration when the user knows what they want to accomplish but not which agent or workflow to use. |
| 25 | + |
| 26 | +## When to Use |
| 27 | + |
| 28 | +- User wants to start a non-trivial task without specifying a workflow |
| 29 | +- User asks "how should I approach this?" or "what's the best way to tackle X?" |
| 30 | +- A task requires multiple sequential agents (Research → Plan → Build) |
| 31 | +- You need explicit resource allocation agreement before spawning agents |
| 32 | + |
| 33 | +## Workflow |
| 34 | + |
| 35 | +### Step 1: Classify the Goal |
| 36 | + |
| 37 | +If the goal is not provided or is ambiguous, ask: |
| 38 | + |
| 39 | +``` |
| 40 | +What's your primary goal for this task? |
| 41 | +
|
| 42 | +- Research — Understand/explore something (unfamiliar code, libraries, concepts) |
| 43 | +- Plan — Design/architect a solution (implementation plans, problem decomposition) |
| 44 | +- Build — Implement/code something (new features, components, implementation from a plan) |
| 45 | +- Fix — Debug/fix an issue (investigate and resolve bugs, failing tests) |
| 46 | +``` |
| 47 | + |
| 48 | +If intent is clear from context (e.g., "this test is failing" → Fix), infer without asking. |
| 49 | + |
| 50 | +### Step 2: Check for Existing Plans |
| 51 | + |
| 52 | +```bash |
| 53 | +ls thoughts/shared/plans/*.md 2>/dev/null || ls docs/plans/*.md 2>/dev/null |
| 54 | +``` |
| 55 | + |
| 56 | +- **Build goal:** Ask if implementing an existing plan; load it to avoid duplication |
| 57 | +- **Plan goal:** Surface existing plans to prevent redundant work |
| 58 | +- **Research / Fix:** Proceed without plan check |
| 59 | + |
| 60 | +### Step 3: Confirm Resource Allocation |
| 61 | + |
| 62 | +Present options and confirm before spawning: |
| 63 | + |
| 64 | +``` |
| 65 | +How would you like to allocate resources? |
| 66 | +
|
| 67 | +- Conservative — 1-2 agents, sequential (minimal context, simple tasks) |
| 68 | +- Balanced (recommended) — appropriate agents for the task, some parallelism |
| 69 | +- Aggressive — max parallel agents (time-critical tasks) |
| 70 | +- Auto — system decides based on complexity |
| 71 | +``` |
| 72 | + |
| 73 | +Default to **Balanced** for unspecified or Auto selection. |
| 74 | + |
| 75 | +### Step 4: Map Goal to Agent |
| 76 | + |
| 77 | +| Goal | Primary Agent Type | Description | |
| 78 | +|------|-------------------|-------------| |
| 79 | +| Research | general-purpose (research mode) | Multi-source research using web and documentation tools | |
| 80 | +| Plan | Plan | Create phased implementation plans with architectural trade-offs | |
| 81 | +| Build | general-purpose (implementation mode) | Coding tasks, feature implementation, component creation | |
| 82 | +| Fix | general-purpose (debug mode) → then implementation | Investigate first, implement fix after diagnosis | |
| 83 | + |
| 84 | +**Fix workflow (two stages):** |
| 85 | +1. Spawn debug agent to investigate: produce diagnosis and recommended fix |
| 86 | +2. If fix requires code changes, spawn implementation agent with the diagnosis as context |
| 87 | + |
| 88 | +### Step 5: Show Execution Summary and Confirm |
| 89 | + |
| 90 | +``` |
| 91 | +## Execution Summary |
| 92 | +
|
| 93 | +Goal: [Research / Plan / Build / Fix] |
| 94 | +Resource Allocation: [Conservative / Balanced / Aggressive] |
| 95 | +Agent(s) to dispatch: [agent descriptions] |
| 96 | +
|
| 97 | +What will happen: |
| 98 | +- [Brief description of each agent's task] |
| 99 | +- [Expected output / deliverable and where it will be written] |
| 100 | +
|
| 101 | +Proceed? [Yes / Adjust settings] |
| 102 | +``` |
| 103 | + |
| 104 | +Wait for confirmation before dispatching. If "Adjust settings", return to the relevant step. |
| 105 | + |
| 106 | +### Step 6: Dispatch Agents |
| 107 | + |
| 108 | +#### Research |
| 109 | + |
| 110 | +``` |
| 111 | +Dispatch: general-purpose agent (research mode) |
| 112 | +
|
| 113 | +Prompt: |
| 114 | + Research: [topic] |
| 115 | + Scope: [what to investigate — libraries, APIs, patterns, concepts] |
| 116 | + Output: Write findings to research/[topic-slug].md and summarize key points |
| 117 | +``` |
| 118 | + |
| 119 | +#### Plan |
| 120 | + |
| 121 | +``` |
| 122 | +Dispatch: Plan agent |
| 123 | +
|
| 124 | +Prompt: |
| 125 | + Create implementation plan for: [feature/task] |
| 126 | + Context: [relevant codebase context, constraints, goals] |
| 127 | + Output: Save plan to docs/plans/[plan-slug].md with phased breakdown and trade-offs |
| 128 | +``` |
| 129 | + |
| 130 | +#### Build |
| 131 | + |
| 132 | +If a plan exists, summarize risks before dispatching: |
| 133 | +- Identify any HIGH severity blockers (missing dependencies, ambiguous interfaces) |
| 134 | +- Surface them to the user before proceeding |
| 135 | + |
| 136 | +``` |
| 137 | +Dispatch: general-purpose agent (implementation mode) |
| 138 | +
|
| 139 | +Prompt: |
| 140 | + Implement: [task] |
| 141 | + Plan: [path to plan, if applicable] |
| 142 | + Constraints: [language, framework, test requirements] |
| 143 | + Output: Working implementation with tests passing; write handoff to handoffs/[session]/ |
| 144 | +``` |
| 145 | + |
| 146 | +#### Fix (two stages) |
| 147 | + |
| 148 | +``` |
| 149 | +Stage 1 — Dispatch: general-purpose agent (debug mode) |
| 150 | +
|
| 151 | +Prompt: |
| 152 | + Investigate: [issue description] |
| 153 | + Symptoms: [what's failing, error messages, test output] |
| 154 | + Output: Diagnosis document with root cause and recommended fix path |
| 155 | +
|
| 156 | +Stage 2 — (after diagnosis) Dispatch: general-purpose agent (implementation mode) |
| 157 | +
|
| 158 | +Prompt: |
| 159 | + Fix: [issue as diagnosed] |
| 160 | + Diagnosis: [diagnosis document path] |
| 161 | + Output: Working fix with tests passing |
| 162 | +``` |
| 163 | + |
| 164 | +## Handoff Preservation |
| 165 | + |
| 166 | +Each dispatched agent should write a handoff before completing: |
| 167 | +``` |
| 168 | +handoffs/{session-id}/{agent-type}-{timestamp}.md |
| 169 | +``` |
| 170 | + |
| 171 | +The handoff captures: what was accomplished, what was found, decisions made, open questions, and what the next agent needs to know. |
| 172 | + |
| 173 | +## Output |
| 174 | + |
| 175 | +A confirmation message showing: |
| 176 | +- Which agent(s) were dispatched |
| 177 | +- Their assigned prompts |
| 178 | +- Expected output locations |
| 179 | +- Status after dispatch completes |
0 commit comments