File Location
Each dispatched task gets a directory under.dispatch/tasks/:
security-review, add-auth, fix-login-bug.
The
.dispatch/ directory is ephemeral. Delete it to clean up task files.Plan File Structure
Plan files use Markdown checklist format:Checklist Markers
Workers update checklist items using these markers:Not yet started, or currently in progress (if it’s the first unchecked item).
Completed successfully. Workers can optionally add a note after the
— separator:Worker is blocked and needs user input. The question should appear on the line(s) below:
Worker encountered an unresolvable error. The error description should appear below:
Plan Writing Guidelines
The dispatcher creates plan files before spawning workers. Follow these rules:Match plan size to task complexity
Match plan size to task complexity
- Simple tasks (edits, quick fixes): 1-3 items
- Medium tasks (refactoring, testing): 4-6 items
- Complex tasks (architecture changes, multi-file refactors): 6-10 items
Use concrete, verifiable actions
Use concrete, verifiable actions
Each item should be a specific action the worker can complete and verify.Good:
Scan for hardcoded API keys in src/Add unit tests for auth.ts with 80%+ coverageRefactor UserService to use dependency injection
Review codeMake it betterFix issues
Include output artifact when needed
Include output artifact when needed
The last item should produce an output artifact for tasks that warrant it:For simple tasks (edits, fixes, small PRs), this isn’t needed.
Output Artifacts
output.md
Workers write final results tooutput.md when the task warrants a deliverable:
context.md
Workers write context dumps tocontext.md when IPC times out (no answer to a question after ~3 minutes):
- Read the plan file
- Read
context.mdfor the previous worker’s context - Use the user’s answer to unblock
- Continue from the blocked item onward
IPC Directory Structure
Theipc/ subdirectory enables bidirectional communication between workers and the dispatcher:
File Naming Convention
Worker’s question, written atomically via temp file +
mv. Sequence numbers are zero-padded to 3 digits (001, 002, 003).Dispatcher’s answer to the question, written atomically.
Worker’s acknowledgment that it received the answer. Written after the worker reads the
.answer file.Completion marker written by the worker when all checklist items are finished. Signals the monitor to exit cleanly.
Atomic Write Pattern
All IPC files use a two-step atomic write pattern to prevent reading partial content:IPC Protocol Flow
The IPC system allows workers to ask questions without losing context:Monitor detects question
A lightweight monitor script polls the IPC directory. When it finds an unanswered question, it exits → triggers
<task-notification>Dispatcher respawns monitor
The old monitor exited in step 2. Dispatcher spawns a new monitor to continue polling
Timeout fallback: If no answer arrives within ~3 minutes, the worker dumps context to
context.md, marks the item [?] in the plan file, and exits.IPC Directionality
To provide additional context to a running worker, append notes to the plan file instead:Sequence Numbering
The next sequence number is derived from the count of existing*.question files, plus one:
Monitor Script
A lightweight bash script polls the IPC directory and exits when it detects:- An unanswered question (
.questionfile without matching.answer) - The completion marker (
.done)
<task-notification> that alerts the dispatcher.
Startup Reconciliation
If the dispatcher restarts mid-conversation (e.g., user closes and reopens the session), it should scan for unanswered questions:Check for unanswered questions
For each task, check
ipc/ for *.question files without matching *.answer filesExample: Full Task Lifecycle
1. Dispatch
1. Dispatch
2. Worker Progress
2. Worker Progress
Worker updates
plan.md as it works:3. Worker Blocked
3. Worker Blocked
Worker discovers Content:Monitor detects the question and exits → notification sent.
requirements.txt doesn’t exist. Writes question:4. User Answers
4. User Answers
Dispatcher reads the question, surfaces it:User responds:Dispatcher writes:Content:Dispatcher respawns monitor.
5. Worker Continues
5. Worker Continues
Worker detects
001.answer, reads it, writes 001.done, continues working:6. Worker Completes
6. Worker Completes
All items checked:Worker writes:Monitor detects
.done and exits cleanly → notification sent.Dispatcher reads plan.md and reports:Plan File Best Practices
Keep items concrete
Each item should be a specific, verifiable action. Avoid vague items like “review code” or “make it better.”
Match complexity
Simple tasks get 1-3 items. Complex tasks get 6-10. Don’t over-decompose simple work.
Include output when needed
Tasks that produce findings, summaries, or reports should write to
output.md as the last item.Use notes for context
Append notes to the plan file (via
> **Note:**) to provide additional context to running workers.Related
/dispatch Command
Command syntax and task delegation
Config File
Backend and model configuration