Team Dispatch
Subagent dispatch arm. The PhaseSpec v1 contract is the only handoff format used between parent and child agents.
PhaseSpec v1 (the contract)
phase_id: <stable id, used as filename prefix and progress.md anchor>
parent_plan_ref: <pointer to task_plan.md#phase-N>
goal: <one sentence>
done_when: # testable exit criteria, no goalpost moving
- <criterion 1>
- <criterion 2>
inputs:
files: [<read-only file refs>]
memory_keys: [<keys for memory-layer recall>]
tools_allowed: [<list>]
tools_denied: [<list>]
budget:
max_tool_calls: <int>
max_wall_seconds: <int>
hitl_checkpoints: [<named checkpoint strings the child surfaces>]
return_contract:
format: markdown+frontmatter
fields: [summary, artifacts, open_questions, next_phase_hint]
Six load-bearing properties:
parent_plan_ref is a pointer (file path with anchor), not a copy of the phase text. The child reads the file itself.
done_when is testable. Without it, completion is hallucinatable.
tools_allowed and tools_denied map onto the Claude Code permission model and any other framework's permission story.
hitl_checkpoints are named strings the child surfaces by printing HITL_CHECKPOINT: <name> to stdout.
return_contract forces structured output. The child returns markdown with frontmatter; the parent parses it deterministically.
phase_id doubles as the filename prefix for any artifacts the child writes.
Available subagents
Each is defined as agents/<name>.md in this plugin.
| Subagent |
When to pick |
planner |
A phase exists in task_plan.md but has no PhaseSpec yet. The planner drafts one. |
executor |
Default. A PhaseSpec exists; the work is straightforward; one specialist runs it end to end. |
reviewer |
Auto-approve mode is on; we need a surrogate human to check the executor's return against done_when. |
memory-keeper |
Stop hook fired; we need to classify session output into scratch/WHERE/WHY. |
design-archeologist |
/mddesign:harvest invoked; long-running codebase scan needed. |
Operation: /mddesign:team dispatch <phase_id> [--agent <name>]
Step 1: Resolve the phase
- Read
task_plan.md.
- Find the section header matching
phase_id (case-insensitive).
- If not found, refuse.
Step 2: Pick the subagent
- If
--agent <name> was passed, use it.
- Else infer from the phase: phases with "design", "ui", "tokens" in the title default to
design-archeologist if /mddesign:harvest-shaped, else executor. All others default to executor.
Step 3: Build the PhaseSpec
- Pull
goal from the phase title or first bullet.
- Pull
done_when from the phase's "Status / Done When / Acceptance" section if it exists, else infer from the bullets and ask the user to confirm.
- Set
inputs.files to [task_plan.md, findings.md] plus any files the phase mentions.
- Set
tools_allowed to a sensible subset based on the phase (default: Read Write Edit Bash Glob Grep).
- Set
budget defaults: max_tool_calls: 80, max_wall_seconds: 600.
- Set
hitl_checkpoints to [before_commit, before_destructive_edit] plus phase-specific ones.
Step 4: HITL gate before dispatch
- Print the full PhaseSpec to the user.
- The PreToolUse hook intercepts the next
Agent tool invocation (named checkpoint: before_subagent_dispatch) and requires approval.
Step 5: Dispatch
- Call the
Agent tool with subagent_type: <chosen subagent> and a prompt that contains:
- The full PhaseSpec YAML
- Plain-English instruction: "You are running PhaseSpec phase-. Read every file in inputs.files. Do the work. Return a markdown document with the four fields in return_contract. If you hit any hitl_checkpoint, print
HITL_CHECKPOINT: <name> and stop."
Step 6: Receive the return, validate
- Parse the subagent's final message.
- Verify it has the four required fields (
summary, artifacts, open_questions, next_phase_hint).
- If invalid, log the failure and surface to user.
Step 7: Write to progress.md
Append under ### Phase <phase_id> Result:
### Phase <phase_id> Result
**Subagent:** <name>
**Status:** complete | partial | blocked
**Wall time:** <seconds>
**Tool calls used:** <int>
#### Summary
<from return.summary>
#### Artifacts
<from return.artifacts>
#### Open questions
<from return.open_questions>
#### Next phase hint
<from return.next_phase_hint>
Step 8: Optional review
- If auto-approve mode is on, dispatch
reviewer with the executor's return + the PhaseSpec.
- If reviewer says
approve, mark phase as complete in progress.md.
- If
reject, append the reason to progress.md and surface to user.
- If
escalate, halt and ask user.
Core rules
- Subagents never edit
task_plan.md directly. Only this skill writes to progress.md, and only under ### Phase <id> Result.
- The PhaseSpec is the entire handoff. Subagents do not see the parent conversation.
- Markdown on disk is the shared state. No in-memory shared store across agents.
- Every dispatch goes through the
before_subagent_dispatch HITL gate.
1---2name: team-dispatch3description: Turns a plan phase into a PhaseSpec v1 and dispatches it to a specialist subagent via the Agent tool. Subagent reads files itself, returns a structured result, the result is logged into progress.md. Markdown is the shared state; no in-memory shared store across agents.4---56# Team Dispatch78Subagent dispatch arm. The PhaseSpec v1 contract is the only handoff format used between parent and child agents.910## PhaseSpec v1 (the contract)1112```yaml13phase_id: <stable id, used as filename prefix and progress.md anchor>14parent_plan_ref: <pointer to task_plan.md#phase-N>15goal: <one sentence>16done_when: # testable exit criteria, no goalpost moving17 - <criterion 1>18 - <criterion 2>19inputs:20 files: [<read-only file refs>]21 memory_keys: [<keys for memory-layer recall>]22tools_allowed: [<list>]23tools_denied: [<list>]24budget:25 max_tool_calls: <int>26 max_wall_seconds: <int>27hitl_checkpoints: [<named checkpoint strings the child surfaces>]28return_contract:29 format: markdown+frontmatter30 fields: [summary, artifacts, open_questions, next_phase_hint]31```3233Six load-bearing properties:34351. `parent_plan_ref` is a pointer (file path with anchor), not a copy of the phase text. The child reads the file itself.362. `done_when` is testable. Without it, completion is hallucinatable.373. `tools_allowed` and `tools_denied` map onto the Claude Code permission model and any other framework's permission story.384. `hitl_checkpoints` are named strings the child surfaces by printing `HITL_CHECKPOINT: <name>` to stdout.395. `return_contract` forces structured output. The child returns markdown with frontmatter; the parent parses it deterministically.406. `phase_id` doubles as the filename prefix for any artifacts the child writes.4142## Available subagents4344Each is defined as `agents/<name>.md` in this plugin.4546| Subagent | When to pick |47|---|---|48| `planner` | A phase exists in `task_plan.md` but has no PhaseSpec yet. The planner drafts one. |49| `executor` | Default. A PhaseSpec exists; the work is straightforward; one specialist runs it end to end. |50| `reviewer` | Auto-approve mode is on; we need a surrogate human to check the executor's return against `done_when`. |51| `memory-keeper` | Stop hook fired; we need to classify session output into scratch/WHERE/WHY. |52| `design-archeologist` | `/mddesign:harvest` invoked; long-running codebase scan needed. |5354## Operation: `/mddesign:team dispatch <phase_id> [--agent <name>]`5556### Step 1: Resolve the phase57- Read `task_plan.md`.58- Find the section header matching `phase_id` (case-insensitive).59- If not found, refuse.6061### Step 2: Pick the subagent62- If `--agent <name>` was passed, use it.63- Else infer from the phase: phases with "design", "ui", "tokens" in the title default to `design-archeologist` if `/mddesign:harvest`-shaped, else `executor`. All others default to `executor`.6465### Step 3: Build the PhaseSpec66- Pull `goal` from the phase title or first bullet.67- Pull `done_when` from the phase's "Status / Done When / Acceptance" section if it exists, else infer from the bullets and ask the user to confirm.68- Set `inputs.files` to `[task_plan.md, findings.md]` plus any files the phase mentions.69- Set `tools_allowed` to a sensible subset based on the phase (default: `Read Write Edit Bash Glob Grep`).70- Set `budget` defaults: `max_tool_calls: 80`, `max_wall_seconds: 600`.71- Set `hitl_checkpoints` to `[before_commit, before_destructive_edit]` plus phase-specific ones.7273### Step 4: HITL gate before dispatch74- Print the full PhaseSpec to the user.75- The PreToolUse hook intercepts the next `Agent` tool invocation (named checkpoint: `before_subagent_dispatch`) and requires approval.7677### Step 5: Dispatch78- Call the `Agent` tool with `subagent_type: <chosen subagent>` and a prompt that contains:79 - The full PhaseSpec YAML80 - Plain-English instruction: "You are running PhaseSpec phase-<id>. Read every file in inputs.files. Do the work. Return a markdown document with the four fields in return_contract. If you hit any hitl_checkpoint, print `HITL_CHECKPOINT: <name>` and stop."8182### Step 6: Receive the return, validate83- Parse the subagent's final message.84- Verify it has the four required fields (`summary`, `artifacts`, `open_questions`, `next_phase_hint`).85- If invalid, log the failure and surface to user.8687### Step 7: Write to progress.md88Append under `### Phase <phase_id> Result`:8990```markdown91### Phase <phase_id> Result9293**Subagent:** <name>94**Status:** complete | partial | blocked95**Wall time:** <seconds>96**Tool calls used:** <int>9798#### Summary99<from return.summary>100101#### Artifacts102<from return.artifacts>103104#### Open questions105<from return.open_questions>106107#### Next phase hint108<from return.next_phase_hint>109```110111### Step 8: Optional review112- If auto-approve mode is on, dispatch `reviewer` with the executor's return + the PhaseSpec.113- If reviewer says `approve`, mark phase as complete in progress.md.114- If `reject`, append the reason to progress.md and surface to user.115- If `escalate`, halt and ask user.116117## Core rules118119- Subagents never edit `task_plan.md` directly. Only this skill writes to `progress.md`, and only under `### Phase <id> Result`.120- The PhaseSpec is the entire handoff. Subagents do not see the parent conversation.121- Markdown on disk is the shared state. No in-memory shared store across agents.122- Every dispatch goes through the `before_subagent_dispatch` HITL gate.