A distributed system for orchestrating multiple Claude Code instances
npm install @mohsen/claude-code-orchestratorcco Claude Code OrchestratorOrchestrate multiple Claude Code instances to work collaboratively on software projects using the Claude Agent SDK. This is intended for very long horizon tasks that require parallelization and coordination among AI agents. Tasks like building a full-stack application, refactoring a large codebase, or implementing complex features.
cco is designed to be completely hands-off once started, with automatic management of git branches, worktrees, and Claude sessions. The only requirement is to provide high-level project goals in PROJECT_DIRECTION.md.
- Session Continuity: Workers maintain context across tasks using the SDK's resume capability
- Real-time Streaming: Observe agent progress as it happens
- Built-in Subagents: Hierarchical delegation without custom protocols
- Git Safety: Serialized git operations prevent conflicts
Spawns parallel Claude sessions using a hierarchical coordination model:
- Director - Coordinates Engineering Managers and merges to main branch (Opus model)
- Engineering Managers (EMs) - Lead teams of workers, curate team branches (Sonnet model)
- Workers - Execute tasks in isolated git worktrees (Sonnet model)
For smaller projects (workerCount <= engineerManagerGroupSize), uses a flat Coordinator model where a single lead developer coordinates all workers.
Requirements: Node.js 22+, git, Claude Code CLI
``bash`
npm install -g @mohsen/claude-code-orchestrator
Start an orchestration session using the interactive CLI:
`bash`
cco start
Or with a configuration file:
`bash`
cco start --config ./my-config
1. Create a configuration directory (e.g., my-config/)orchestrator.json
2. Add (see below)api-keys.json
3. (Optional) Add for API key authentication
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| repositoryUrl | string | required | Git repository URL |branch
| | string | "main" | Base branch |gitCloneOptions
| | object | {} | Clone options: depth, singleBranch, noSubmodules |workerCount
| | number | required | Worker instances (1-20) |authMode
| | string | "oauth" | oauth, api-keys-first, or api-keys-only |logDirectory
| | string | config path | Log storage location |engineerManagerGroupSize
| | number | 4 | Max workers per EM (triggers hierarchy mode when exceeded) |maxRunDurationMinutes
| | number | 120 | Max run duration |taskTimeoutMs
| | number | 600000 | Timeout for individual tasks |pollIntervalMs
| | number | 5000 | Status check interval |
For rate limit rotation, cco offers two authentication modes: OAuth and API keys. By default, it uses OAuth (your regular Claude CLI auth). To use API keys, create an api-keys.json file:
`json`
[
{ "name": "key-1", "apiKey": "sk-ant-..." },
{ "name": "key-2", "apiKey": "sk-ant-..." }
]
Note: Include multiple keys for rotation - cco switches keys upon hitting rate limits.
| Mode | Description |
|------|-------------|
| oauth | Start with CLI auth, rotate to API keys if rate limited |api-keys-first
| | Start with API keys, fall back to OAuth |api-keys-only
| | Only use API keys |
Add these files to your target repository:
- PROJECT_DIRECTION.md - High-level goals for the Director/Coordinator.env
- / .env.local - Automatically copied to all worktrees
:
`
Coordinator (Lead Developer)
├── worker-1
├── worker-2
└── worker-N
`$3
Used when workerCount > engineerManagerGroupSize:
`
Director
├── em-1
│ ├── worker sessions...
│
└── em-N
└── worker sessions...
`Logs
Each run creates a timestamped folder with:
-
combined.log - Orchestrator events and agent outputs
- Session-specific logs for debuggingGraceful Shutdown
Send SIGINT (Ctrl+C) or SIGTERM to gracefully stop all sessions:
`bash
The orchestrator handles cleanup automatically
kill -SIGINT
``See docs/DEVELOPMENT.md for contributing and development setup.
MIT