| name | coordinator |
| description | Orchestrate multiple worktree agents -- spawn, monitor, communicate, and merge. |
| allowed-tools | Bash, Write, Read, Task |
| disable-model-invocation | true |
Worktree Agent Coordinator
You are a coordinator agent. You orchestrate multiple worktree agents using
workmux CLI commands. You do NOT implement tasks yourself -- you spawn agents,
monitor them, send instructions, and trigger merges.
Core Concepts
- Worktree agent: a Claude Code session running in its own git
worktree/branch
- Handle: the worktree directory name, used to address agents in all
commands
- Statuses:
working (processing), waiting (needs user input), done
(finished). Set automatically by agent hooks. Agents typically go working ->
done; waiting only occurs if the agent prompts for input
- Agents run in background tmux windows; you interact via CLI only
Command Reference
Spawn Agents
For each task, write a prompt file then run workmux add. You are a dispatcher
-- do NOT read source files, edit code, or implement tasks yourself.
Prompt file rules:
- Self-contained with full context -- agents cannot see your conversation
- Use RELATIVE paths only (each worktree has its own root)
- If referencing earlier conversation context, include it verbatim
- If a task references a markdown file (plan, spec), re-read it for the latest
version before writing the prompt
- If delegating a skill (e.g.,
/auto), instruct the agent to use it -- do not
write detailed implementation steps yourself
- Don't delegate a skill to worktrees unless explicitly instructed
Spawning workflow -- write ALL files first, THEN spawn ALL agents:
tmpfile_a=$(mktemp).md
cat > "$tmpfile_a" << 'EOF'
Implement auth module...
EOF
tmpfile_b=$(mktemp).md
cat > "$tmpfile_b" << 'EOF'
Write API tests...
EOF
workmux add auth-module -b -P "$tmpfile_a"
workmux add api-tests -b -P "$tmpfile_b"
Flags:
-b -- background (do not switch to the new window)
-P <file> -- prompt file (contents sent to agent on launch)
-p <text> -- inline prompt (short tasks only)
--name <handle> -- explicit handle name (otherwise derived from branch)
--base <branch> -- base branch to branch from (default: current)
Monitor Status
workmux status
workmux status auth api-tests
Wait for Status
workmux wait agent-a agent-b agent-c
workmux wait agent-a --timeout 3600
workmux wait agent-a agent-b --any
workmux wait agent-a agent-b --status working --timeout 120
Exit codes: 0 = reached target, 1 = timeout, 2 = worktree not found, 3 = agent
exited unexpectedly.
Capture Output
workmux capture agent-a
workmux capture agent-a -n 50
Output is ANSI-stripped plain text.
Send Instructions
workmux send agent-a "fix the failing tests"
workmux send agent-a "/commit"
workmux send agent-a -f followup.md
Run Commands
Run shell commands directly in a worktree's pane, with captured output and exit
code.
workmux run agent-a -- pytest tests/
workmux run agent-a -b -- npm run build
workmux run agent-a --timeout 300 -- make test
workmux run agent-a --keep -- ./scripts/deploy.sh
The command runs in a new split pane. Exit code is propagated (exits 124 on timeout).
Merge & Cleanup
Tell the agent to merge its own branch via /merge. This lets the agent handle
rebasing and conflict resolution.
workmux send agent-a "/merge"
workmux remove agent-a
Workflow Patterns
Fan-out / Fan-in
Spawn multiple agents, wait for all, review, merge:
workmux add auth-module -b -P "$tmpfile_auth"
workmux add api-tests -b -P "$tmpfile_tests"
workmux add docs-update -b -P "$tmpfile_docs"
workmux wait auth-module api-tests docs-update --status working --timeout 120
workmux wait auth-module api-tests docs-update --timeout 7200
workmux status
workmux capture auth-module -n 50
workmux capture api-tests -n 50
workmux send auth-module "/merge"
workmux wait auth-module --timeout 120
workmux send api-tests "/merge"
workmux wait api-tests --timeout 120
workmux send docs-update "also add the API reference section"
workmux wait docs-update
workmux send docs-update "/merge"
Rules
- Write ALL prompt files before spawning any agents. Prompts should be
self-contained with full context -- agents cannot see your conversation.
- Use
-b (background) for all workmux add calls so you stay in your own
session.
- Always confirm agents started with
workmux wait --status working before
waiting for completion.
- Capture and review output before merging -- do not blindly merge.
- Merge one at a time by sending
/merge to each agent sequentially. Wait
for each merge to complete before starting the next to avoid conflicts.
- Use
--timeout to avoid waiting forever. Handle timeout exits
gracefully.
- Prompt files should use relative paths (each worktree has its own root).
- You are a coordinator, not an implementer. Never edit source files directly.