The dispatcher reads ~/.dispatch/config.yaml to determine:
Which model to use (from explicit mention in prompt, or the default)
Which backend CLI to use (claude, cursor, or codex)
How to construct the worker command
First-run setup: If the config doesn’t exist, Dispatch auto-detects available CLIs, discovers models, asks you to choose a default, and generates the config file.
default: opus # Default model when none specifiedbackends: claude: command: > env -u CLAUDE_CODE_ENTRYPOINT -u CLAUDECODE claude -p --dangerously-skip-permissions cursor: command: > agent -p --force --workspace "$(pwd)"models: opus: { backend: claude } sonnet: { backend: claude } gpt-5.3-codex: { backend: cursor }
# Single atomic operation to set up everythingmkdir -p .dispatch/tasks/security-review/ipccat > /tmp/dispatch-security-review-prompt.txt << 'PROMPT'You have a plan file at .dispatch/tasks/security-review/plan.md containing a checklist.Work through it top to bottom. For each item, do the work, update the plan file ([ ] → [x]), and move to the next.If you need to ask the user a question, write it to .dispatch/tasks/security-review/ipc/<NNN>.question (atomic write via temp file + mv; sequence from 001). Poll for a matching .answer file. When you receive the answer, write a .done marker and continue.When all items are checked, write: touch .dispatch/tasks/security-review/ipc/.doneContext:- Review the authentication module in src/auth/- Focus on common vulnerabilities: hardcoded secrets, weak session management, injection risks- Write detailed findings with file:line referencesPROMPTcat > /tmp/worker--security-review.sh << 'WORKER'#!/bin/bashenv -u CLAUDE_CODE_ENTRYPOINT -u CLAUDECODE \ claude -p --dangerously-skip-permissions \ "$(cat /tmp/dispatch-security-review-prompt.txt)" 2>&1WORKERcat > /tmp/monitor--security-review.sh << 'MONITOR'#!/bin/bashIPC_DIR=".dispatch/tasks/security-review/ipc"TIMEOUT=1800 # 30 minutesSTART=$(date +%s)shopt -s nullglobwhile true; do # Exit if task is complete [ -f "$IPC_DIR/.done" ] && exit 0 # Exit if unanswered question found for q in "$IPC_DIR"/*.question; do seq=$(basename "$q" .question) [ ! -f "$IPC_DIR/${seq}.answer" ] && exit 0 done # Exit if timeout exceeded ELAPSED=$(( $(date +%s) - START )) [ "$ELAPSED" -ge "$TIMEOUT" ] && exit 1 sleep 3doneMONITORchmod +x /tmp/worker--security-review.sh /tmp/monitor--security-review.sh
The dispatcher launches both processes as background tasks:
# Worker process - does the actual workbash /tmp/worker--security-review.sh# description: "Run dispatch worker: security-review"# Monitor process - watches for questions and completionbash /tmp/monitor--security-review.sh# description: "Monitoring progress: security-review"
Both run in the background. The dispatcher records their task IDs internally but does not show them to the user (implementation detail).
The dispatcher immediately reports back and returns control:
Dispatched `security-review` using opus. Plan: 1. Scan for hardcoded secrets and credentials 2. Review authentication logic in auth.ts 3. Check session management and token handling 4. Audit authorization checks 5. Test for common vulnerabilities 6. Write findings reportWhat else?
You can continue working - the task runs in the background.
`security-review` complete. Found 3 issues: 1. Hardcoded API key in auth.ts:47 2. Weak session timeout (24 hours) 3. No rate limiting on /login endpointFull report at .dispatch/tasks/security-review/output.md
Worker writes 001.question file
Monitor detects unanswered question, exits
<task-notification> triggers
Dispatcher reads question, surfaces to user:
Worker is asking: "Found 2 different auth implementations - one in auth.ts and one in legacy-auth.ts. Which should I review?"
You answer: “Review auth.ts, the other is deprecated”
Dispatcher writes 001.answer, respawns monitor
Worker detects answer, writes 001.done, continues working
The worker never exits during this flow - context is preserved.
Without background execution, you’d be blocked waiting for potentially long-running tasks:
You: "Review security across the entire codebase"Claude: *spends 10 minutes reading files, analyzing code* *you can't do anything else during this time*Claude: "Found 12 issues..." ← finally
With Dispatch:
You: /dispatch "Review security across the entire codebase"Dispatch: Dispatched `security-review` using opus. [plan summary]You: *continue working on other things*[10 minutes later]<task-notification>Dispatch: `security-review` complete. Found 12 issues...