claude-pool
Slot pool orchestration library for Claude CLI
Overview
claude-pool manages N Claude CLI slots behind a unified interface. A coordinator (typically an interactive Claude session) submits work, and the pool routes tasks by availability, tracks budgets, and handles slot lifecycle and session management.
Architecture
Coordinator (your app or interactive session)
|
+-- pool.run("task") -> synchronous
+-- pool.submit("task") -> async, returns task ID
+-- pool.fan_out([tasks]) -> parallel execution
+-- pool.auto("task") -> LLM picks single/parallel/chain
+-- pool.submit_chain(steps) -> sequential pipeline
|
+-- Pool (task queue, context, budget)
|
+-- Slot-0 (Claude instance)
+-- Slot-1 (Claude instance)
+-- Slot-N (Claude instance)
Installation
Quick Start
use Pool;
use Claude;
async
Execution Patterns
Single Task
// Synchronous (blocking)
let result = pool.run.await?;
// Asynchronous (non-blocking)
let task_id = pool.submit.await?;
// ... do other work ...
if let Some = pool.result.await?
Parallel Fan-Out
let results = pool.fan_out.await?;
Sequential Chains
use ;
let steps = vec!;
let task_id = pool.submit_chain.await?;
Auto-Routing
Let an LLM classify the task as single, parallel, or chain:
let result = pool.auto.await?;
// Router decides this is parallel and fans out automatically.
Configuration
use ;
let pool = builder
.slots
.config
.build
.await?;
Features
- Task execution: synchronous (
run), async (submit/result), parallel (fan_out) - Chains: sequential pipelines with
{previous_output}threading, failure policies, retries - Auto-routing: LLM classifies tasks as single/parallel/chain with structured hints
- Budget control: pool-level and per-task spending caps
- Shared context: inject key-value pairs into all slot system prompts
- Review gates:
submit_with_review/approve_result/reject_result - Worktree isolation: optional git worktree per slot or per chain
- Messaging: inter-slot messaging with broadcast support
- Scaling: dynamic slot scaling (
scale_up,scale_down,set_target_slots) - Supervisor: background health monitoring with automatic slot restarts
- Storage:
InMemoryStore(default) orJsonFileStorefor persistence
Examples
License
MIT OR Apache-2.0