Task Router - CEO's Decision Engine
The brain of CodeCrew. When a task comes in, this skill classifies it, picks the right agents, decides the execution strategy, and kicks off the work.
When to Activate
- User runs
/crew task "description"
- CEO agent needs to route a subtask
Prerequisites
These files MUST exist (run /crew init first):
.claude/crew-profile.md — project context
.claude/crew-team.json — agent configuration
.claude/crew-skills.json — skill catalog
.claude/crew-index.json — codebase index (Layer 1)
.claude/crew-symbols.json — symbol map (Layer 2)
If any are missing, tell the user to run /crew init first.
Routing Algorithm
Step 1: Read Context
1. Check if .claude/.index-stale exists
- If yes: read the file paths listed, invoke index-updater for those files, then delete .claude/.index-stale
- This handles files edited outside of /crew task (e.g., manual edits, other tools)
2. Read .claude/crew-profile.md for project context
3. Read .claude/crew-team.json for available agents
4. Read .claude/crew-config.json (if exists) for user overrides (default mode, budgets, etc.)
5. Read .claude/crew-index.json for codebase awareness
Step 2: Classify Task
Task Type (pick one):
| Type |
Signals |
bug-fix |
"fix", "bug", "broken", "error", "crash", "not working", "issue" |
feature |
"add", "implement", "create", "build", "new", "feature" |
refactor |
"refactor", "clean up", "reorganize", "restructure", "improve" |
docs |
"document", "readme", "comment", "explain", "docs" |
test |
"test", "coverage", "spec", "TDD", "unit test", "e2e" |
security |
"security", "vulnerability", "auth", "permission", "XSS", "injection" |
devops |
"deploy", "docker", "CI/CD", "pipeline", "kubernetes", "build" |
review |
"review", "check", "audit", "quality" |
performance |
"slow", "optimize", "performance", "speed", "memory", "cache" |
Complexity (assess based on scope):
| Level |
Signals |
trivial |
Single word change, typo, formatting, one-line fix |
simple |
Single file, clear fix, under 20 lines changed |
moderate |
2-4 files, some design decisions, 20-100 lines |
complex |
5+ files, architecture decisions, new patterns, 100+ lines |
architectural |
System-wide changes, new subsystems, major refactors |
Step 3: Select Agent Chain
Based on (type, complexity), select the execution plan:
ROUTING TABLE:
bug-fix:
trivial → junior-dev (haiku)
simple → debugger (sonnet) investigates → junior-dev (haiku) fixes
moderate → debugger (sonnet) investigates → senior-dev (sonnet) fixes
complex → CEO reads index → debugger investigates → senior-dev fixes → code-reviewer reviews
architectural → CEO + vp-engineering analyze → debugger + senior-dev → vp-quality reviews
feature:
trivial → junior-dev (haiku)
simple → senior-dev (sonnet)
moderate → vp-engineering plans → senior-dev implements → test-engineer tests
complex → CEO + vp-engineering architect → [parallel: senior-dev implements, test-engineer writes tests] → code-reviewer reviews
architectural → CEO designs → vp-engineering plans → [parallel: multiple senior-devs] → vp-quality reviews all
refactor:
any → vp-engineering plans → senior-dev executes → code-reviewer reviews
docs:
any → doc-writer (haiku)
test:
trivial/simple → test-engineer (sonnet)
moderate+ → vp-quality strategizes → test-engineer implements
security:
any → security-analyst (sonnet) → senior-dev fixes findings
devops:
trivial/simple → devops-engineer (haiku)
moderate+ → senior-dev (sonnet) handles complex infra
review:
any → code-reviewer (sonnet) → report to user
performance:
any → vp-engineering analyzes → senior-dev optimizes → test-engineer verifies
Step 4: Decide Execution Strategy
PARALLEL when:
- Subtasks operate on DIFFERENT files (check via crew-index.json)
- Implementation + test writing (test-engineer works on test files, senior-dev on source files)
- Multiple independent bug fixes
- Documentation for different components
SEQUENTIAL when:
- Investigation must complete before fix begins
- Planning must complete before implementation
- Implementation must complete before review
- Subtasks modify the SAME files
HYBRID (most common for moderate+ tasks):
1. Sequential: investigation/planning phase
2. Parallel: independent implementation subtasks
3. Sequential: integration review
Step 5: Inject Relevant Skills
Read .claude/crew-skills.json and select skills to inject into agent prompts:
1. Always include: "always" category skills
2. Add stack-specific skills based on detectedStack
3. Add task-type skills based on classified type
4. Each agent gets ONLY the skills relevant to their subtask (not all skills)
Step 6: Generate Execution Plan
Create a structured plan before executing:
[FULL] {type}/{complexity}: "{task}"
1. {agent} → {subtask}
2. {agent} + {agent} → {subtask A} | {subtask B}
3. {agent} → {review}
Display this plan to the user, then execute.
Step 7: Execute
Use the execution-orchestrator skill to dispatch agents according to the plan.
For each agent dispatch, construct a self-contained prompt that includes:
- The subtask description
- Relevant project context from crew-profile.md
- The Index-First Protocol instructions
- Injected skill guidance
- Files the agent should focus on (from index analysis)
- Expected output format
Step 8: Collect Results & Report
After all agents complete:
- Collect each agent's output
- Check for conflicts (multiple agents editing same lines)
- If conflicts: escalate to vp-engineering for resolution
- Auto-update index for all
FILES_MODIFIED (handled automatically by execution-orchestrator)
- Log task to
.claude/crew-history.json (including skillsInjected and agent details)
- Report final status to user (including index update status and skills injected)
- Include skills used in the report — execution-orchestrator's Result Collection template handles the format
Error Handling
- If agent fails → retry once with more context
- If agent reports index is stale → trigger incremental update, then retry
- If parallel agents conflict → fall back to sequential for conflicting files
- If task is unclear → CEO asks user for clarification instead of guessing
1---2name: task-router3description: CEO's task decomposition and routing engine. Classifies tasks by type and complexity, selects agents with appropriate model tiers, decides parallel vs sequential execution, and auto-injects relevant skills.4---56# Task Router - CEO's Decision Engine78The brain of CodeCrew. When a task comes in, this skill classifies it, picks the right agents, decides the execution strategy, and kicks off the work.910## When to Activate1112- User runs `/crew task "description"`13- CEO agent needs to route a subtask1415## Prerequisites1617These files MUST exist (run `/crew init` first):18- `.claude/crew-profile.md` — project context19- `.claude/crew-team.json` — agent configuration20- `.claude/crew-skills.json` — skill catalog21- `.claude/crew-index.json` — codebase index (Layer 1)22- `.claude/crew-symbols.json` — symbol map (Layer 2)2324If any are missing, tell the user to run `/crew init` first.2526## Routing Algorithm2728### Step 1: Read Context29```301. Check if .claude/.index-stale exists31 - If yes: read the file paths listed, invoke index-updater for those files, then delete .claude/.index-stale32 - This handles files edited outside of /crew task (e.g., manual edits, other tools)332. Read .claude/crew-profile.md for project context343. Read .claude/crew-team.json for available agents354. Read .claude/crew-config.json (if exists) for user overrides (default mode, budgets, etc.)365. Read .claude/crew-index.json for codebase awareness37```3839### Step 2: Classify Task4041**Task Type** (pick one):42| Type | Signals |43|------|---------|44| `bug-fix` | "fix", "bug", "broken", "error", "crash", "not working", "issue" |45| `feature` | "add", "implement", "create", "build", "new", "feature" |46| `refactor` | "refactor", "clean up", "reorganize", "restructure", "improve" |47| `docs` | "document", "readme", "comment", "explain", "docs" |48| `test` | "test", "coverage", "spec", "TDD", "unit test", "e2e" |49| `security` | "security", "vulnerability", "auth", "permission", "XSS", "injection" |50| `devops` | "deploy", "docker", "CI/CD", "pipeline", "kubernetes", "build" |51| `review` | "review", "check", "audit", "quality" |52| `performance` | "slow", "optimize", "performance", "speed", "memory", "cache" |5354**Complexity** (assess based on scope):55| Level | Signals |56|-------|---------|57| `trivial` | Single word change, typo, formatting, one-line fix |58| `simple` | Single file, clear fix, under 20 lines changed |59| `moderate` | 2-4 files, some design decisions, 20-100 lines |60| `complex` | 5+ files, architecture decisions, new patterns, 100+ lines |61| `architectural` | System-wide changes, new subsystems, major refactors |6263### Step 3: Select Agent Chain6465Based on (type, complexity), select the execution plan:6667```68ROUTING TABLE:6970bug-fix:71 trivial → junior-dev (haiku)72 simple → debugger (sonnet) investigates → junior-dev (haiku) fixes73 moderate → debugger (sonnet) investigates → senior-dev (sonnet) fixes74 complex → CEO reads index → debugger investigates → senior-dev fixes → code-reviewer reviews75 architectural → CEO + vp-engineering analyze → debugger + senior-dev → vp-quality reviews7677feature:78 trivial → junior-dev (haiku)79 simple → senior-dev (sonnet)80 moderate → vp-engineering plans → senior-dev implements → test-engineer tests81 complex → CEO + vp-engineering architect → [parallel: senior-dev implements, test-engineer writes tests] → code-reviewer reviews82 architectural → CEO designs → vp-engineering plans → [parallel: multiple senior-devs] → vp-quality reviews all8384refactor:85 any → vp-engineering plans → senior-dev executes → code-reviewer reviews8687docs:88 any → doc-writer (haiku)8990test:91 trivial/simple → test-engineer (sonnet)92 moderate+ → vp-quality strategizes → test-engineer implements9394security:95 any → security-analyst (sonnet) → senior-dev fixes findings9697devops:98 trivial/simple → devops-engineer (haiku)99 moderate+ → senior-dev (sonnet) handles complex infra100101review:102 any → code-reviewer (sonnet) → report to user103104performance:105 any → vp-engineering analyzes → senior-dev optimizes → test-engineer verifies106```107108### Step 4: Decide Execution Strategy109110```111PARALLEL when:112- Subtasks operate on DIFFERENT files (check via crew-index.json)113- Implementation + test writing (test-engineer works on test files, senior-dev on source files)114- Multiple independent bug fixes115- Documentation for different components116117SEQUENTIAL when:118- Investigation must complete before fix begins119- Planning must complete before implementation120- Implementation must complete before review121- Subtasks modify the SAME files122123HYBRID (most common for moderate+ tasks):1241. Sequential: investigation/planning phase1252. Parallel: independent implementation subtasks1263. Sequential: integration review127```128129### Step 5: Inject Relevant Skills130131Read `.claude/crew-skills.json` and select skills to inject into agent prompts:132133```1341. Always include: "always" category skills1352. Add stack-specific skills based on detectedStack1363. Add task-type skills based on classified type1374. Each agent gets ONLY the skills relevant to their subtask (not all skills)138```139140### Step 6: Generate Execution Plan141142Create a structured plan before executing:143144```145[FULL] {type}/{complexity}: "{task}"146 1. {agent} → {subtask}147 2. {agent} + {agent} → {subtask A} | {subtask B}148 3. {agent} → {review}149```150151Display this plan to the user, then execute.152153### Step 7: Execute154155Use the **execution-orchestrator** skill to dispatch agents according to the plan.156157For each agent dispatch, construct a self-contained prompt that includes:1581. The subtask description1592. Relevant project context from crew-profile.md1603. The Index-First Protocol instructions1614. Injected skill guidance1625. Files the agent should focus on (from index analysis)1636. Expected output format164165### Step 8: Collect Results & Report166167After all agents complete:1681. Collect each agent's output1692. Check for conflicts (multiple agents editing same lines)1703. If conflicts: escalate to vp-engineering for resolution1714. Auto-update index for all `FILES_MODIFIED` (handled automatically by execution-orchestrator)1725. Log task to `.claude/crew-history.json` (including `skillsInjected` and agent details)1736. Report final status to user (including index update status and skills injected)1747. Include skills used in the report — execution-orchestrator's Result Collection template handles the format175176## Error Handling177178- If agent fails → retry once with more context179- If agent reports index is stale → trigger incremental update, then retry180- If parallel agents conflict → fall back to sequential for conflicting files181- If task is unclear → CEO asks user for clarification instead of guessing