ワンクリックで
maestrodispatching
// Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies
// Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies
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 working with Docker containers — debugging container failures, writing Dockerfiles, docker-compose for integration tests, image optimization, or deploying containerized applications
Execute feature tasks following TDD workflow. Single-agent by default, --team for parallel Agent Teams, Sub Agent Parallels. Use when ready to implement a planned feature.
| name | maestro:dispatching |
| description | Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies |
| stage | execution |
| audience | orchestrator |
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_task_next (MCP) or maestro task-next (CLI) to get runnable tasks -- tasks whose dependencies are all satisfied and that are in pending state.
Only dispatch tasks that are runnable. Never claim tasks with unmet dependencies.
Only done satisfies dependencies (not blocked or pending).
Confirm with the operator first:
maestro_memory_writedigraph dispatch_decision {
rankdir=TB;
check [label="maestro_task_next\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.
# Find runnable tasks with compiled specs
maestro_task_next # MCP -- returns recommended task with spec
# Claim each task before dispatching a worker
maestro_task_claim --task 01-fix-auth # MCP: maestro_task_claim
maestro_task_claim --task 02-fix-parser
maestro_task_claim --task 03-fix-renderer
# Each claimed task gets a worker agent.
# The pre-agent hook auto-injects the task spec into the worker prompt.
While workers are running:
maestro_status to check progressblocked status -- a worker needs a decisionclaimed tasks -- a worker may have crashed (claim expired)MANDATORY. Never auto-merge.
For each completed worker:
# Read the worker's report
maestro task-report-read --task 01-fix-auth
Review checklist:
Mark each task done and merge one at a time. Re-test after each merge.
# Mark task done with summary
maestro_task_done --task 01-fix-auth --summary "Fixed null check in validator"
# Merge first worker
maestro merge --task 01-fix-auth
# Verify tests still pass after merge
bun test
# Mark and merge second worker
maestro_task_done --task 02-fix-parser --summary "Added edge case handling"
maestro merge --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.
# The worker calls maestro_task_block with a reason.
# The task moves to `blocked` state.
# 1. Check status to see blocked tasks
maestro_status
# 2. Read the blocker details
maestro task-report-read --task 01-fix-auth
# 3. Present to operator, get decision
# "Worker blocked: 'Auth module uses two different session formats.
# Should I normalize to format A or format B?'"
# 4. Unblock with the decision
maestro_task_unblock --task 01-fix-auth --decision "Normalize to format A -- it's the newer format"
Do NOT guess the answer. Present to the operator. Wait.
The worker's claim has expired -- no active worker is running the task.
Detection: maestro_status shows the task as claimed with an expired timestamp.
Recovery:
# maestro_task_next auto-resets expired claims to pending.
# Simply call task_next to find runnable tasks -- the stale task will be reset.
maestro_task_next
# Now claim it fresh for a new worker
maestro_task_claim --task 01-fix-auth
Diagnosis before retrying:
| Root Cause | Recovery |
|---|---|
| Spec was ambiguous | Update spec with maestro task-spec-write, then re-claim |
| Task was too broad | Split into subtasks, dispatch separately |
| Worker went out of scope | Add explicit constraints to spec, re-claim |
| External breakage (build, deps) | Fix environment first, then re-claim |
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_memory_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:
# Use maestro_task_next to find runnable tasks
# Claim each: maestro_task_claim
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:
maestro_task_done for Worker 1, merged, ran tests: greenmaestro_task_done for Worker 2, merged, ran tests: greenmaestro_task_done for Worker 3, merged, ran tests: greenTime 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 via maestro_status, present to operator, unblock with maestro_task_unblock. |
| Worker produces wrong output | Review spec -- was it clear? Update with maestro task-spec-write 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. |
| Stale claim -- worker disappeared | maestro_task_next auto-resets expired claims. Re-claim and dispatch a new worker. |
Parallel dispatch --> verified independent --> operator approved
Otherwise --> sequential
Worker done --> review report --> maestro_task_done --> run tests --> merge
Otherwise --> not done
No exceptions without operator approval.