Multi-agent thread orchestration and coordination
This skill provides orchestration capabilities for managing multiple Claude agent threads with git worktree isolation.
Activate this skill when the user wants to:
# Initialize claude-threads in project
ct init
# Create a thread
ct thread create <name> --mode <mode> --template <template>
# Create thread with isolated worktree
ct thread create <name> --mode automatic --worktree
ct thread create <name> --worktree --worktree-base develop
# List threads
ct thread list [status]
# Start/stop/resume threads
ct thread start <id>
ct thread stop <id>
ct thread resume <id>
# View thread status and logs
ct thread status <id>
ct thread logs <id>
# List all active worktrees
ct worktree list
# Show worktree details
ct worktree status <id>
# Cleanup orphaned worktrees
ct worktree cleanup
# Start/stop orchestrator daemon
ct orchestrator start
ct orchestrator stop
ct orchestrator status
ct orchestrator restart
# Watch PR with worktree isolation
ct pr watch <pr_number>
# Check status
ct pr status [pr_number]
ct pr list
# Stop watching
ct pr stop <pr_number>
# Run as daemon
ct pr daemon
# List recent events
ct event list
# Publish event
ct event publish <type> '<json>'
| Mode | Use Case |
|---|---|
automatic |
Fully autonomous background tasks |
semi-auto |
Autonomous with user approval for critical steps |
interactive |
Step-by-step user confirmation |
sleeping |
Scheduled or event-triggered tasks |
# Create threads with isolated worktrees
ct thread create epic-7a --mode automatic --template bmad-developer.md --worktree --context '{"epic_id": "7A"}'
ct thread create epic-8a --mode automatic --template bmad-developer.md --worktree --context '{"epic_id": "8A"}'
# Start orchestrator
ct orchestrator start
# Monitor
ct thread list running
ct worktree list
# Watch PR - creates isolated worktree
ct pr watch 123
# Shepherd automatically:
# - Creates worktree for PR branch
# - Spawns fix threads when CI fails
# - Pushes fixes from worktree
# - Cleans up when PR merges
ct pr status 123
# Create reviewer thread that triggers on development completion
ct thread create reviewer --mode semi-auto --template reviewer.md --trigger DEVELOPMENT_COMPLETED
# Events flow: STORY_COMPLETED -> DEVELOPMENT_COMPLETED -> reviewer wakes
| Event | Description |
|---|---|
THREAD_STARTED |
Thread began execution |
THREAD_COMPLETED |
Thread finished |
THREAD_BLOCKED |
Thread encountered a blocker |
WORKTREE_CREATED |
Isolated worktree created |
WORKTREE_PUSHED |
Changes pushed from worktree |
WORKTREE_DELETED |
Worktree cleaned up |
STORY_STARTED |
Developer starting story |
STORY_COMPLETED |
Story implementation done |
DEVELOPMENT_COMPLETED |
All stories finished |
REVIEW_COMPLETED |
Code review done |
PR_CREATED |
Pull request opened |
CI_PASSED / CI_FAILED |
CI status update |
PR_APPROVED |
PR approved |
PR_MERGED |
PR merged successfully |
In .claude-threads/config.yaml:
threads:
max_concurrent: 5
default_max_turns: 80
orchestrator:
poll_interval: 1
idle_poll_interval: 10
idle_threshold: 30
worktrees:
enabled: true
max_age_days: 7
auto_cleanup: true
default_base_branch: main
auto_push: true
pr_shepherd:
max_fix_attempts: 5
ci_poll_interval: 30
auto_merge: false
.claude-threads/threads.db.claude-threads/logs/.claude-threads/config.yaml.claude-threads/templates/.claude-threads/worktrees/If a thread becomes blocked:
# Check status
ct thread status <id>
# View logs
ct thread logs <id>
# Resume manually
ct thread resume <id>
# Or restart
ct thread stop <id> && ct thread start <id>
For PR lifecycle management, use the base + fork pattern:
# Create base worktree when watching a PR (once)
ct worktree base-create 123 feature/my-pr main
# Fork from base for each sub-agent (shares git objects, ~1MB vs ~100MB)
ct worktree fork 123 conflict-fix fix/conflict conflict_resolution
# After sub-agent completes, merge fork back
ct worktree merge-back conflict-fix
# Cleanup fork
ct worktree remove-fork conflict-fix
# When PR is done, cleanup base
ct worktree base-remove 123
A āāŗ B āāŗ C āāŗ Done
Use: Tasks with dependencies
Orchestrator
āāā¬āā¬āā¬āā¬āā
ā¼ ā¼ ā¼ ā¼ ā¼ ā¼
1 2 3 4 5 6
Use: Independent parallel tasks (max 5)
PR Shepherd
āāā Fork ā Conflict Resolver ā Merge Back
āāā Fork ā Comment Handler 1 ā Merge Back
āāā Fork ā Comment Handler 2 ā Merge Back
Then: Push from base
Connect external Claude Code instances:
# On orchestrator machine
ct api start --token $TOKEN
# On worker machine
ct remote connect orchestrator:31337 --token $TOKEN
ct spawn epic-7a --template bmad-developer.md