---
description: Orchestration - routes tasks to the right subagent automatically
alwaysApply: true
---

# Delegation

After reading memory-bank, check if the current task matches a subagent below. Delegate automatically; do not wait for user to name the agent.

## When to Delegate

| Intent / Trigger | Subagent |
|---|---|
| Editing `plugin/**`, SimHub SDK, incident detection, iRacing, SimHub dashboards, overlays, Dash Studio | simhub-developer |
| Writing tech plans, spike plans, technical design docs | simhub-developer |
| Editing `website/**`, Astro, Tailwind, landing page, docs site, Cloudflare Pages, marketing site | web-developer |
| "break this down", "scope", "plan feature", brainstorming, user stories, feature ideation, task decomposition | product-owner |
| Writing PRD specs, feature specs, detailed requirement docs | product-owner |
| After product-owner creates stories | priority-steward (schedule new tasks) |
| "what's next?", priorities, sprint, backlog, reprioritize | priority-steward |
| After completing a task or implementation | priority-steward (update Done, promote Next) |
| Code review, PR review, diff feedback | code-reviewer |
| Verify PRD compliance, trace FR-IDs, requirement gaps | prd-compliance |
| "update memory bank", after major implementation | memory-bank-updater |
| User gives process/workflow/style guidance | Handle directly: update relevant rules/skills/agents |

## Document Dependency Orchestration

When writing multiple dependent documents (PRD specs, tech plans, stories):

- **Orchestrator handles sequencing.** Read the dependency graph, identify which documents can be written in parallel (shared dependencies resolved), and launch subagents concurrently (max 4).
- **Tech plans gate PRD specs.** If a PRD spec depends on a tech plan (e.g., spike results), write the tech plan first, then launch the dependent PRDs.
- **Review at phase boundaries.** Delegate to prd-compliance after completing a phase (not per-document). Fix issues before proceeding.

## Model Preferences

- **code-reviewer, simhub-developer, web-developer**: Prefer code-focused model
- **product-owner, prd-compliance, memory-bank-updater**: Prefer reasoning model
- **priority-steward**: Default model is fine

## Rules

- Memory Bank rule takes priority over this rule when in conflict.
- All agents must follow `incremental-work.mdc`. Prefer small-to-medium incremental changes; large single-pass artifacts should be escalated to the user first.
- All agents may search the internet for additional context when project files are insufficient; prefer authoritative sources.
- All agents may use additional tooling, including command-line workflows and relevant CLIs, when needed to complete tasks.
- Do not delegate simple one-step tasks; handle them directly.
- When delegating, pass relevant context from the current conversation in the Task prompt. Subagents read only their domain-specific files (defined in each agent definition), not all memory-bank files.

## Mandatory Post-Implementation Review Path

- For implementation in `plugin/**`, use this sequence:
	1. Delegate implementation to `simhub-developer`.
	2. `simhub-developer` performs a successful build (msbuild or dotnet build) and self-review, then returns a reviewed, consolidated change set.
	3. The coding agent executes code changes once (single apply pass) after SimHub self-review is complete.
	4. **Deploy (mandatory):** The agent that applied plugin code—whether after a simhub-developer handoff or when implementing plugin changes directly—**must** run `plugin/scripts/deploy-plugin.ps1` at the end of that change iteration and report its output. Do not consider plugin implementation complete until deploy has been run and output reported.
- If plugin changes were made without delegating (e.g. plan execution or small fixes), the agent that made the changes still must run `plugin/scripts/deploy-plugin.ps1` and report output.
- `code-reviewer` is optional for plugin work unless the user explicitly requests it or confidence is Medium/Low.
- After implementation, document outcomes in Memory Bank (`activeContext.md`, `progress.md`, and `journal.md` as needed).
