/dispatch) for Claude Code that decomposes large coding tasks into subtasks, dispatches them to background AI worker agents, and tracks progress via checklist-based plan files.
Components
Dispatch consists of several key components that work together to enable background task execution:Dispatcher Session
The dispatcher runs in your active Claude Code session. It handles:- Creating task plans with checklists
- Spawning background worker agents
- Monitoring task progress
- Managing bidirectional communication with workers
- Reporting results back to you
Worker Agents
Workers are background AI agents that execute the actual work. They can run using different CLIs:- Claude Code (
claude) - Native Claude models (opus, sonnet, haiku) - Cursor (
agent) - Multi-model support (Claude, GPT, Gemini, etc.) - Codex (
codex) - OpenAI models (GPT-5.3, o1, etc.)
- Reads its assigned plan file
- Works through checklist items sequentially
- Updates the plan file as it progresses (
[ ]→[x]) - Can ask questions via IPC without losing context
- Writes completion markers when done
Plan Files
Plan files (.dispatch/tasks/<task-id>/plan.md) are the single source of truth for task state:
[x]- Completed[ ]- Pending or in progress[?]- Blocked (needs user input)[!]- Error encountered
Monitor Process
A lightweight bash script monitors each task’s IPC directory:- Polls for unanswered questions from the worker
- Exits when a question is detected, triggering a notification
- Exits cleanly when the task completes (
.donemarker found) - Times out after 30 minutes of inactivity
IPC Directory
The.dispatch/tasks/<task-id>/ipc/ directory enables bidirectional communication:
- Workers write questions (
001.question,002.question, …) - Dispatcher writes answers (
001.answer,002.answer, …) - Workers acknowledge answers (
001.done,002.done, …) - Completion marker (
.done) signals all work is finished
IPC is worker-initiated only. The dispatcher cannot send unsolicited messages to workers. To add context to a running worker, append notes to the plan file instead.
System Flow
Here’s how a typical dispatch flows from command to completion:Directory Structure
All dispatch state lives in the.dispatch/ directory:
Worker and Dispatcher Interaction
Dispatching a Task
- Dispatcher reads config to determine which model/backend to use
- Dispatcher writes a plan file with concrete, verifiable checklist items
- Dispatcher creates scaffolding (IPC dir, prompt file, wrapper scripts) in a single bash call
- Dispatcher spawns worker and monitor as background processes
- Dispatcher returns control to user immediately
During Execution
- Worker reads the plan file and works through items sequentially
- Worker updates plan file after completing each item (
[ ]→[x]) - Monitor polls the IPC directory for questions or completion markers
- Dispatcher can check progress anytime by reading the plan file
When Worker Needs Help
- Worker writes a question file (e.g.,
001.question) using atomic write pattern - Monitor detects unanswered question and exits, triggering notification
- Dispatcher reads question and surfaces it to user
- User provides answer
- Dispatcher writes answer file (
001.answer) atomically - Dispatcher respawns monitor
- Worker detects answer, writes acknowledgment (
001.done), continues working
This flow preserves the worker’s full context - no need to spawn a new agent or re-explain the task.
On Completion
- Worker writes
.donemarker to IPC directory - Monitor detects
.doneand exits cleanly - Notification triggers dispatcher to read final plan state
- Dispatcher reports results to user
Key Design Patterns
Checklist-as-State
Checklist-as-State
The plan file IS the progress tracker. No separate status files or polling needed. The dispatcher simply reads the plan to see what’s done, pending, blocked, or errored.
Fresh Context Per Subtask
Fresh Context Per Subtask
Each worker gets its own instance with a clean prompt. No context bleeding between tasks. This enables true parallel execution.
Non-Blocking Dispatch
Non-Blocking Dispatch
The dispatcher returns control immediately after spawning workers. You can continue working while tasks run in the background. Progress arrives via
<task-notification> events.Atomic Writes
Atomic Writes
All IPC file writes use a two-step pattern (
write .tmp → mv) to prevent reading partial data. This ensures reliability even with concurrent access.Host vs Worker Distinction
Host vs Worker Distinction
The host session (where you type
/dispatch) must be Claude Code - it’s the only environment that runs the dispatcher skill. Workers can be any CLI that accepts a prompt (Claude Code, Cursor, Codex).Readable Status Bar
Readable Status Bar
Workers launch through wrapper scripts (
/tmp/worker--<task-id>.sh) so Claude Code’s status bar shows human-readable labels instead of raw CLI commands.Proactive Recovery
Proactive Recovery
When a worker fails to start (auth error, quota exceeded, CLI unavailable), the dispatcher checks which CLIs are available and offers alternatives from your config, updating the default if needed.
Configuration System
Dispatch uses~/.dispatch/config.yaml to manage models and backends:
On first run, Dispatch auto-detects available CLIs and models, then generates this config file for you.
Next Steps
How It Works
Dive deeper into the step-by-step execution flow
IPC Protocol
Learn about the communication protocol between dispatcher and workers