multiclaude orchestrates multiple Claude Code instances working autonomously on GitHub repositories. It uses tmux for session management, git worktrees for isolation, and a daemon for coordination.
An agent is a Claude Code instance with:
- A tmux window for visibility and interaction
- A git worktree for isolated file access
- A role defining its responsibilities (supervisor, worker, or merge-queue)
- A session ID (UUID) for context persistence
Agents run autonomously. Humans can attach via tmux to observe or intervene at any time.
Supervisor
- One per repository
- Monitors all other agents
- Answers status questions ("what's everyone up to?")
- Nudges stuck workers
- Makes high-level decisions about task coordination
- Keeps worktree synced with main branch
Worker
- Executes a specific task
- Creates a PR when work is complete
- Signals completion, then gets cleaned up
- Named with Docker-style names (e.g., "happy-platypus")
- Multiple workers can run concurrently
Merge Queue
- One per repository
- Monitors open PRs from workers
- Merges when CI passes
- Spawns fixup workers for CI failures
- Never weakens CI without human approval
A single daemon process coordinates everything:
- Manages state (repos, agents, messages)
- Routes messages between agents
- Periodically nudges agents
- Monitors agent health
- Handles CLI requests via Unix socket
┌──────────────────────────────────────────────────────────────────┐
│ multiclaude daemon │
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Health Loop │ │ Message Loop│ │ Nudge Loop │ │
│ │ (2 min) │ │ (2 min) │ │ (2 min) │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ State Manager │ │
│ │ repos, agents, messages, PIDs, worktrees │ │
│ └─────────────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ Unix Socket Server │ │
│ │ CLI commands: init, work, list, send-message, etc. │ │
│ └─────────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────────────────────────────────────────────────┐
│ tmux: mc-<repo> │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │supervisor│ │merge-queue│ │worker-1 │ │worker-2 │ │
│ │(Claude) │ │(Claude) │ │(Claude) │ │(Claude) │ │
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ └────┬─────┘ │
└───────┼─────────────┼────────────┼────────────┼─────────────┘
│ │ │ │
▼ ▼ ▼ ▼
┌─────────────────────────────────────────────────────────────┐
│ Git Worktrees │
│ ~/.multiclaude/wts/<repo>/ │
│ supervisor/ merge-queue/ worker-1/ worker-2/ │
└─────────────────────────────────────────────────────────────┘
~/.multiclaude/
├── daemon.pid # Daemon process ID
├── daemon.sock # Unix socket for CLI
├── daemon.log # Daemon activity log
├── state.json # Persisted state
├── prompts/ # Generated prompt files
│ └── <repo>-<agent>.md
├── repos/ # Cloned repositories
│ └── <repo>/ # Main clone (bare or regular)
├── wts/ # Git worktrees
│ └── <repo>/
│ ├── supervisor/
│ ├── merge-queue/
│ └── <worker-name>/
└── messages/ # Inter-agent messages
└── <repo>/
└── <agent>/
└── <msg-id>.json
State is stored in memory and persisted to state.json:
{
"repos": {
"my-repo": {
"github_url": "https://github.com/org/my-repo",
"local_path": "/Users/user/.multiclaude/repos/my-repo",
"tmux_session": "mc-my-repo",
"agents": {
"supervisor": {
"type": "supervisor",
"worktree_path": "...",
"tmux_window": "supervisor",
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"pid": 12345,
"created_at": "2026-01-18T10:00:00Z",
"last_nudge": "2026-01-18T10:30:00Z"
},
"happy-platypus": {
"type": "worker",
"task": "Add authentication tests",
"worktree_path": "...",
"tmux_window": "happy-platypus",
"session_id": "...",
"pid": 12347,
"created_at": "...",
"ready_for_cleanup": false
}
}
}
}
}Health Check Loop (every 2 minutes)
- Verify tmux windows exist
- Check Claude process PIDs are alive
- Mark dead agents for cleanup
- Remove orphaned resources
Message Router Loop (every 2 minutes)
- Scan
messages/for pending messages - Deliver via
tmux send-keys - Update message status
Nudge Loop (every 2 minutes)
- Send status check to agents that haven't been active
- Exponential backoff to avoid spam
- Wake supervisor and merge-queue periodically
Agents communicate via JSON files in ~/.multiclaude/messages/<repo>/<agent>/:
{
"id": "msg-abc123",
"from": "supervisor",
"to": "happy-platypus",
"timestamp": "2026-01-18T10:30:00Z",
"body": "How's the authentication work going?",
"status": "pending"
}Status progression: pending → delivered → read → acked → deleted
Delivery: Daemon uses tmux send-keys -t session:window "message" C-m to inject messages into the agent's stdin.
CLI communicates with daemon via Unix socket at ~/.multiclaude/daemon.sock.
Request format:
{
"command": "add_agent",
"args": {
"repo": "my-repo",
"name": "happy-platypus",
"type": "worker",
"task": "Add tests"
}
}Response format:
{
"success": true,
"data": { ... },
"error": ""
}multiclaude repo init <github-url>
- Clone repo to
~/.multiclaude/repos/<name> - Create tmux session
mc-<name> - Create supervisor worktree and window, start Claude
- Create merge-queue worktree and window, start Claude
- Register in daemon state
multiclaude worker create "task description"
- Generate Docker-style name
- Create worktree from main (or
--branch) - Create tmux window
- Start Claude with worker prompt and task
- Register in daemon state
- Worker creates PR via
gh pr create - Worker runs
multiclaude agent complete - Daemon marks
ready_for_cleanup: true - Daemon cleans up worktree and tmux window
multiclaude worker rm <name>
- Check for uncommitted changes (warn if found)
- Check for unpushed commits (warn if found)
- Remove tmux window
- Remove git worktree
- Update state
claude --session-id "<uuid>" \
--append-system-prompt-file "<prompt-file>" \
--dangerously-skip-permissions--session-idenables context persistence across restarts--append-system-prompt-fileloads role-specific instructions--dangerously-skip-permissionsenables autonomous operation
Default prompts are embedded in the binary. Repositories can customize agents with:
.multiclaude/agents/worker.md- Worker agent definition.multiclaude/agents/merge-queue.md- Merge-queue agent definition.multiclaude/agents/review.md- Review agent definition
Deprecated: The old files (SUPERVISOR.md, WORKER.md, REVIEWER.md directly in .multiclaude/) are deprecated.
If .multiclaude/hooks.json exists, it's copied to the worktree's .claude/settings.json for Claude Code hooks integration.
Daemon not running:
Error: multiclaude daemon is not running
Start it with: multiclaude start
Uncommitted work on cleanup:
Warning: Worker 'happy-platypus' has uncommitted changes:
M src/auth.ts
Continue with cleanup? [y/N]
Agent crash:
- Health loop detects dead PID
- Logs warning to daemon.log
- Marks agent for potential restart
- Transparency - All work visible via tmux
- Isolation - Each agent has its own worktree
- Recovery - State persists, daemon recovers from crashes
- Safety - CI is sacred, never weakened without human approval
- Simplicity - Filesystem for messages, tmux for visibility, git for isolation
These rules are embedded in agent prompts:
-
If CI passes, the code can go in. Never reduce or weaken CI without explicit human approval.
-
Forward progress trumps all. Any incremental progress is good. A reviewable PR is progress. The only failure is an agent that doesn't move forward at all.
cmd/multiclaude/ # CLI entry point
internal/
cli/ # Command routing
daemon/ # Daemon process and loops
logging/ # Structured logging
messages/ # Message filesystem operations
names/ # Docker-style name generation
prompts/ # Role-specific prompts
socket/ # Unix socket client/server
state/ # JSON state persistence
tmux/ # tmux session management
worktree/ # Git worktree operations
pkg/
config/ # Path configuration
- Phase 1: Core Infrastructure - Complete
- Phase 2: Daemon & Management - Complete
- Phase 3: Claude Integration - Complete
- Phase 4: Polish & Refinement - In Progress
Not in current scope:
- Web dashboard
- Cross-repo coordination
- Multi-user support
- Remote daemon
- Automatic agent respawning
Possible enhancements:
- Cost tracking
- Agent templates
- Issue tracker integration
- Budget controls