一键导入
maestrodispatching
Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when bootstrapping, updating, or reviewing AGENTS.md — teaches what makes effective agent memory, how to structure sections, signal vs noise filtering, and when to prune stale entries
Use before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
Deep discovery and specification for ambitious features. Full BMAD-inspired interview with classification, vision, journeys, domain analysis, and FR synthesis. Same output contract (spec.md + plan.md) as a standard feature but far richer. Use for multi-component systems, regulated domains, or unclear requirements.
Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies
Use when working with Docker containers — debugging container failures, writing Dockerfiles, docker-compose for integration tests, image optimization, or deploying containerized applications
| name | maestro:dispatching |
| description | Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies |
One agent per independent problem domain. Let them work concurrently.
Core principle: If two tasks don't share state, they don't share an agent.
Violating independence assumptions will produce merge conflicts, wasted work, or silent bugs.
Always:
Never:
Thinking "they're probably independent"? Verify. Check the files each task will touch. One overlap means they are not independent.
NO DISPATCH WITHOUT VERIFIED INDEPENDENCE
Two tasks touching the same file? Sequential, not parallel. Unsure if they're independent? Sequential until proven otherwise.
Before dispatching, use maestro status to get the runnable list -- tasks whose dependencies are all satisfied.
Only dispatch tasks that are runnable. Never start tasks with unmet dependencies.
Only done satisfies dependencies (not blocked, failed, partial, cancelled).
Confirm with the operator first:
maestro context-writedigraph dispatch_decision {
rankdir=TB;
check [label="maestro status\nGet runnable tasks", shape=box];
count [label="How many\nrunnable?", shape=diamond];
one [label="Single Worker\n(Pattern 1)", shape=box, style=filled, fillcolor="#ccffcc"];
independent [label="Do they share\nfiles or state?", shape=diamond];
parallel [label="Parallel Workers\n(Pattern 2)", shape=box, style=filled, fillcolor="#ccffcc"];
dependent [label="Can you\nsequence them?", shape=diamond];
pipeline [label="Pipeline\n(Pattern 3)", shape=box, style=filled, fillcolor="#ccffcc"];
single [label="Single Worker\n(too coupled)", shape=box, style=filled, fillcolor="#ccffcc"];
check -> count;
count -> one [label="1"];
count -> independent [label="2+"];
independent -> parallel [label="no"];
independent -> dependent [label="yes"];
dependent -> pipeline [label="yes"];
dependent -> single [label="no"];
}
See reference/delegation-patterns.md for detailed pattern descriptions.
Worker prompts are the single most important factor in dispatch success. A vague prompt produces vague results.
Every worker prompt needs exactly five sections:
| Section | Purpose | Failure Mode If Missing |
|---|---|---|
| Goal | One sentence: what does "done" look like? | Worker thrashes, unclear when finished |
| Scope | Which files/directories the worker may touch | Worker refactors the world |
| Context | Error messages, signatures, design decisions | Worker wastes time exploring what you already know |
| Constraints | What the worker must NOT do | Worker makes "improvements" you didn't ask for |
| Output | What the worker must report back | You cannot verify the work without re-reading everything |
Error output:
TypeError: Cannot read property 'status' of undefined
at processTask (src/tasks/processor.ts:47)
The processTask function receives a TaskResult from executeStep().
executeStep returns undefined when the step is skipped (see src/steps/executor.ts:23).
Design decision: skipped steps should return { status: 'skipped' } not undefined.
Specific error, location, root cause hypothesis, design intent
</Good>
<Bad>
```markdown
## Context
The task processing is broken. Look at the processor and executor files.
There might be a null issue somewhere.
Vague, forces worker to explore everything
Rule of thumb: If removing a sentence doesn't change what the worker will do, remove it.
| Task Complexity | Context Length | Detail Level |
|---|---|---|
| Fix a known bug with stack trace | 10-20 lines | Error + location + hypothesis |
| Implement from spec | 20-40 lines | API signature + types + example usage + patterns |
| Refactor module | 30-50 lines | Current structure + target structure + constraints |
| Investigate unknown issue | 15-25 lines | Symptoms + what you've ruled out + where to start |
See reference/agent-prompt-templates.md for complete templates by task type.
Group tasks by what they touch:
Task A: Fix auth validation --> src/auth/*, tests/auth/*
Task B: Fix parser edge case --> src/parser/*, tests/parser/*
Task C: Fix renderer crash --> src/renderer/*, tests/renderer/*
Verify independence:
One "no" means the tasks are NOT independent. Use Pattern 1 or Pattern 3 instead.
# Verify all tasks are runnable
maestro status
# Start each task -- maestro generates worker-prompt.md with full context
maestro task-start --feature my-feature --task 01-fix-auth
maestro task-start --feature my-feature --task 02-fix-parser
maestro task-start --feature my-feature --task 03-fix-renderer
Each task-start creates a worktree and generates a worker-prompt.md. The worker reads that file and follows the instructions.
While workers are running:
maestro status to check progressblocked status -- a worker needs a decisionfailed status -- a worker crashed or produced bad outputMANDATORY. Never auto-merge.
For each completed worker:
# Read the worker's report
maestro task-report-read --feature my-feature --task 01-fix-auth
Review checklist:
Merge one worker at a time. Re-test after each merge.
# Merge first worker
maestro merge --feature my-feature --task 01-fix-auth
# Verify tests still pass after merge
bun test
# Merge second worker
maestro merge --feature my-feature --task 02-fix-parser
# Verify again
bun test
Why incremental? If Worker A and Worker C both pass independently but break when combined, incremental merging isolates the conflict to the second merge.
The worker encountered something it cannot resolve without a decision.
# 1. Read the blocker
maestro task-report-read --feature my-feature --task 01-fix-auth
# 2. Present to operator, get decision
# "Worker blocked: 'Auth module uses two different session formats.
# Should I normalize to format A or format B?'"
# 3. Resume with the decision
maestro task-start --feature my-feature --task 01-fix-auth \
--continue-from blocked \
--decision "Normalize to format A -- it's the newer format"
Do NOT guess the answer. Present to the operator. Wait.
The worker crashed, produced incorrect output, or left tests broken.
Diagnosis:
maestro task-report-read --feature my-feature --task 01| Root Cause | Recovery |
|---|---|
| Spec was ambiguous | Clarify spec, rewrite task, restart |
| Task was too broad | Split into subtasks, dispatch separately |
| Worker went out of scope | Add explicit constraints, restart |
| External breakage (build, deps) | Fix environment first, then restart |
| Stale/stuck worktree | maestro task-start --force to start fresh |
Good output mixed with problems.
# Resume from partial -- worker picks up where it left off
maestro task-start --feature my-feature --task 01-fix-auth \
--continue-from partial
src/auth/validator.ts, tests/auth/validator.test.ts
[error message, relevant function signature, design decision]
Do not change the executeStep API.
Root cause, fix applied, test added, all tests green.
States the problem, trusts the worker to solve it.
</Good>
### Under-Specifying Context
<Bad>
```markdown
Fix the auth bug.
Which auth bug? In which file? What does the error look like?
```markdown Fix: `processTask` in `src/auth/validator.ts:47` throws `TypeError: Cannot read property 'status' of undefined` when `executeStep` returns `undefined` for skipped steps. ``` Specific file, line, error, cause.Dispatching is not "fire and forget." Workers make systematic errors:
Always review before merge. Always run tests after merge.
Task A: Add new field to UserType --> src/types/user.ts
Task B: Use new UserType field --> src/auth/validator.ts
These look independent (different files), but Task B imports from Task A's output. Dispatching in parallel means Task B works with the OLD UserType and fails.
Test: If you reverse the merge order, do both still work? If not, they are coupled.
Even for truly independent tasks, merge one at a time and test between merges. "Independent" is your assessment -- the code is the truth.
"I have 5 failing tests. Let me dispatch 5 agents."
First: are the failures related? Run the tests, read the errors. If 4 of the 5 share a root cause, dispatching 5 agents wastes 4 agents.
Rule: Investigate enough to identify independent domains. Then dispatch.
Before marking dispatch complete:
maestro context-writeCannot check all boxes? You are not done.
Scenario: 6 test failures across 3 files after major refactoring.
Step 1 -- Investigate:
agent-tool-abort.test.ts: 3 failures (timing errors)
batch-completion-behavior.test.ts: 2 failures (tools not executing)
tool-approval-race-conditions.test.ts: 1 failure (execution count = 0)
Step 2 -- Verify independence:
Step 3 -- Dispatch:
Worker 1 --> agent-tool-abort.test.ts (timing issues)
Worker 2 --> batch-completion-behavior.test.ts (event structure)
Worker 3 --> tool-approval-race-conditions.test.ts (async waiting)
Step 4 -- Results:
Step 5 -- Integration:
Time saved: 3 problems solved in the time of 1.
| Problem | Solution |
|---|---|
| Workers keep editing same files | Tasks are coupled. Use Pattern 1 or Pattern 3. |
| Worker blocks on a question | Read blocker, present to operator, resume with decision. |
| Worker produces wrong output | Review spec -- was it clear? Rewrite and retry. |
| Merge conflicts after parallel work | Independence was misjudged. Resolve conflict, then re-verify remaining merges. |
| Not sure if tasks are independent | They are not. Start sequential, parallelize after first task proves isolation. |
| Too many tasks to dispatch at once | Batch into groups of 3-4. Merge one batch before starting the next. |
Parallel dispatch --> verified independent --> operator approved
Otherwise --> sequential
Worker done --> review report --> run tests --> merge
Otherwise --> not done
No exceptions without operator approval.