claude_swarm 0.1.16 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +46 -0
- data/CLAUDE.md +48 -0
- data/README.md +228 -9
- data/claude-swarm.yml +8 -36
- data/examples/monitoring-demo.yml +26 -0
- data/examples/multi-directory.yml +26 -0
- data/examples/with-before-commands.yml +30 -0
- data/lib/claude_swarm/claude_code_executor.rb +8 -1
- data/lib/claude_swarm/claude_mcp_server.rb +2 -1
- data/lib/claude_swarm/cli.rb +102 -3
- data/lib/claude_swarm/commands/ps.rb +148 -0
- data/lib/claude_swarm/commands/show.rb +158 -0
- data/lib/claude_swarm/configuration.rb +34 -4
- data/lib/claude_swarm/mcp_generator.rb +3 -0
- data/lib/claude_swarm/orchestrator.rb +222 -4
- data/lib/claude_swarm/version.rb +1 -1
- data/lib/claude_swarm/worktree_manager.rb +353 -0
- data/llms.txt +2 -2
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1aaf0eadabd67afb0bd79738de8c7fcbfb65887d477a2c0c002017cff9de15ec
|
4
|
+
data.tar.gz: 777f04c044a2204477d1328dc31b0b5361fa0007d0cf637254d3531260e3149d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb39225f7a1f4cfd7c0d7e0e3068ad5527473a04744ed0d18525b37452e7b7d4fe67c83f03fbb5c662591e51ed9c10a2360c5943676dc944ea83680652c977b7
|
7
|
+
data.tar.gz: 807b10f87678f4f49df363fbcc53bf3a71d14848adf2ebbad1d701737aad8f9ce6b894ebe7f6e84c45234a1f414ec1c1d171b79189090b6d6de2a71df00e05a7
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,49 @@
|
|
1
|
+
## [0.1.18]
|
2
|
+
|
3
|
+
### Added
|
4
|
+
- **Before commands**: Execute setup commands before launching the swarm
|
5
|
+
- New `before` field in swarm configuration accepts an array of commands
|
6
|
+
- Commands are executed in sequence before any Claude instances are launched
|
7
|
+
- All commands must succeed (exit code 0) for the swarm to launch
|
8
|
+
- Commands are only executed on initial launch, not when restoring sessions
|
9
|
+
- Output is logged to the session log file
|
10
|
+
- Useful for installing dependencies, starting services, or running setup scripts
|
11
|
+
- Example: `before: ["npm install", "docker-compose up -d"]`
|
12
|
+
|
13
|
+
- **Git worktree support**: Run instances in isolated Git worktrees
|
14
|
+
- New `--worktree [NAME]` CLI option creates worktrees for all instances
|
15
|
+
- Worktrees are created inside each repository at `.worktrees/NAME`
|
16
|
+
- Each worktree gets its own branch (not detached HEAD) for proper Git operations
|
17
|
+
- Auto-generated names use session ID: `worktree-SESSION_ID`
|
18
|
+
- Per-instance worktree configuration in YAML:
|
19
|
+
- `worktree: true` - Use shared worktree name
|
20
|
+
- `worktree: false` - Disable worktree for this instance
|
21
|
+
- `worktree: "branch-name"` - Use custom worktree name
|
22
|
+
- Session restoration automatically restores worktrees
|
23
|
+
- Cleanup preserves worktrees with uncommitted changes or unpushed commits
|
24
|
+
- Warnings displayed when worktrees are preserved: "⚠️ Warning: Worktree has uncommitted changes"
|
25
|
+
- Multiple directories per instance work seamlessly with worktrees
|
26
|
+
- `.gitignore` automatically created in `.worktrees/` directory
|
27
|
+
- Example: `claude-swarm --worktree feature-branch`
|
28
|
+
|
29
|
+
## [0.1.17]
|
30
|
+
|
31
|
+
### Added
|
32
|
+
- **Multi-directory support**: Instances can now access multiple directories
|
33
|
+
- The `directory` field in YAML configuration now accepts either a string (single directory) or an array of strings (multiple directories)
|
34
|
+
- Additional directories are passed to Claude using the `--add-dir` flag
|
35
|
+
- The first directory in the array serves as the primary working directory
|
36
|
+
- All specified directories must exist or validation will fail
|
37
|
+
- Example: `directory: [./frontend, ./backend, ./shared]`
|
38
|
+
- **Session monitoring commands**: New commands for monitoring and managing active Claude Swarm sessions
|
39
|
+
- `claude-swarm ps`: List all active sessions with properly aligned columns showing session ID, swarm name, total cost, uptime, and directories
|
40
|
+
- `claude-swarm show SESSION_ID`: Display detailed session information including instance hierarchy and individual costs
|
41
|
+
- `claude-swarm watch SESSION_ID`: Tail session logs in real-time (uses native `tail -f`)
|
42
|
+
- `claude-swarm clean`: Remove stale session symlinks with optional age filtering (`--days N`)
|
43
|
+
- Active sessions are tracked via symlinks in `~/.claude-swarm/run/` for efficient monitoring
|
44
|
+
- Cost tracking aggregates data from `session.log.json` for accurate reporting
|
45
|
+
- Interactive main instance shows "n/a (interactive)" for cost when not available
|
46
|
+
|
1
47
|
## [0.1.16]
|
2
48
|
|
3
49
|
### Changed
|
data/CLAUDE.md
CHANGED
@@ -39,6 +39,47 @@ bundle exec rake release # Release gem to RubyGems.org
|
|
39
39
|
rake # Runs both tests and RuboCop
|
40
40
|
```
|
41
41
|
|
42
|
+
## Git Worktree Support
|
43
|
+
|
44
|
+
Claude Swarm supports launching instances in Git worktrees to isolate changes:
|
45
|
+
|
46
|
+
### CLI Usage
|
47
|
+
```bash
|
48
|
+
# Create worktrees with custom name
|
49
|
+
claude-swarm --worktree feature-branch
|
50
|
+
|
51
|
+
# Create worktrees with auto-generated name (worktree-SESSION_ID)
|
52
|
+
claude-swarm --worktree
|
53
|
+
|
54
|
+
# Short form
|
55
|
+
claude-swarm -w feature-x
|
56
|
+
```
|
57
|
+
|
58
|
+
### Per-Instance Configuration
|
59
|
+
Instances can have individual worktree settings that override CLI behavior:
|
60
|
+
|
61
|
+
```yaml
|
62
|
+
instances:
|
63
|
+
main:
|
64
|
+
worktree: true # Use shared worktree name (from CLI or auto-generated)
|
65
|
+
testing:
|
66
|
+
worktree: false # Don't use worktree for this instance
|
67
|
+
feature:
|
68
|
+
worktree: "feature-x" # Use specific worktree name
|
69
|
+
default:
|
70
|
+
# No worktree field - follows CLI behavior
|
71
|
+
```
|
72
|
+
|
73
|
+
### Worktree Behavior
|
74
|
+
- Worktrees are created inside each repository in a `.worktrees/` directory
|
75
|
+
- A `.gitignore` file is automatically created inside `.worktrees/` to ignore all contents
|
76
|
+
- Each unique Git repository gets its own worktree with the same name
|
77
|
+
- All instance directories are mapped to their worktree equivalents
|
78
|
+
- Worktrees are automatically cleaned up when the swarm exits
|
79
|
+
- Session metadata tracks worktree information for restoration
|
80
|
+
- Non-Git directories are used as-is without creating worktrees
|
81
|
+
- Existing worktrees with the same name are reused
|
82
|
+
|
42
83
|
## Architecture
|
43
84
|
|
44
85
|
The gem is fully implemented with the following components:
|
@@ -49,6 +90,7 @@ The gem is fully implemented with the following components:
|
|
49
90
|
- **ClaudeSwarm::Configuration** (`lib/claude_swarm/configuration.rb`): YAML parser and validator for swarm configurations
|
50
91
|
- **ClaudeSwarm::McpGenerator** (`lib/claude_swarm/mcp_generator.rb`): Generates MCP JSON configurations for each instance
|
51
92
|
- **ClaudeSwarm::Orchestrator** (`lib/claude_swarm/orchestrator.rb`): Launches the main Claude instance with proper configuration
|
93
|
+
- **ClaudeSwarm::WorktreeManager** (`lib/claude_swarm/worktree_manager.rb`): Manages Git worktrees for isolated development
|
52
94
|
|
53
95
|
### Key Features
|
54
96
|
|
@@ -58,6 +100,7 @@ The gem is fully implemented with the following components:
|
|
58
100
|
4. **Multiple MCP Types**: Supports both stdio and SSE MCP server types
|
59
101
|
5. **Automatic MCP Generation**: Creates `.claude-swarm/` directory with MCP configs
|
60
102
|
6. **Custom System Prompts**: Each instance can have a custom prompt via `--append-system-prompt`
|
103
|
+
7. **Git Worktree Support**: Run instances in isolated Git worktrees with per-instance configuration
|
61
104
|
|
62
105
|
### How It Works
|
63
106
|
|
@@ -77,16 +120,20 @@ swarm:
|
|
77
120
|
main: lead
|
78
121
|
instances:
|
79
122
|
lead:
|
123
|
+
description: "Lead developer coordinating the team"
|
80
124
|
directory: .
|
81
125
|
model: opus
|
82
126
|
connections: [frontend, backend]
|
83
127
|
prompt: "You are the lead developer coordinating the team"
|
84
128
|
tools: [Read, Edit, Bash]
|
129
|
+
worktree: true # Optional: use worktree for this instance
|
85
130
|
frontend:
|
131
|
+
description: "Frontend developer specializing in React"
|
86
132
|
directory: ./frontend
|
87
133
|
model: sonnet
|
88
134
|
prompt: "You specialize in frontend development with React"
|
89
135
|
tools: [Edit, Write, Bash]
|
136
|
+
worktree: false # Optional: disable worktree for this instance
|
90
137
|
```
|
91
138
|
|
92
139
|
## Testing
|
@@ -98,6 +145,7 @@ The gem includes comprehensive tests covering:
|
|
98
145
|
- CLI command functionality
|
99
146
|
- Session restoration
|
100
147
|
- Vibe mode behavior
|
148
|
+
- Worktree management and per-instance configuration
|
101
149
|
|
102
150
|
## Dependencies
|
103
151
|
|
data/README.md
CHANGED
@@ -1,10 +1,30 @@
|
|
1
1
|
# Claude Swarm
|
2
2
|
|
3
|
-
[](https://badge.fury.io/rb/claude_swarm)
|
4
4
|
[](https://github.com/parruda/claude-swarm/actions/workflows/ci.yml)
|
5
5
|
|
6
6
|
Claude Swarm orchestrates multiple Claude Code instances as a collaborative AI development team. It enables running AI agents with specialized roles, tools, and directory contexts, communicating via MCP (Model Context Protocol) in a tree-like hierarchy. Define your swarm topology in simple YAML and let Claude instances delegate tasks through connected instances. Perfect for complex projects requiring specialized AI agents for frontend, backend, testing, DevOps, or research tasks.
|
7
7
|
|
8
|
+
## Table of Contents
|
9
|
+
|
10
|
+
- [Installation](#installation)
|
11
|
+
- [Prerequisites](#prerequisites)
|
12
|
+
- [Usage](#usage)
|
13
|
+
- [Quick Start](#quick-start)
|
14
|
+
- [Configuration Format](#configuration-format)
|
15
|
+
- [MCP Server Types](#mcp-server-types)
|
16
|
+
- [Tools](#tools)
|
17
|
+
- [Examples](#examples)
|
18
|
+
- [Command Line Options](#command-line-options)
|
19
|
+
- [Session Monitoring](#session-monitoring)
|
20
|
+
- [Session Management and Restoration](#session-management-and-restoration-experimental)
|
21
|
+
- [How It Works](#how-it-works)
|
22
|
+
- [Troubleshooting](#troubleshooting)
|
23
|
+
- [Architecture](#architecture)
|
24
|
+
- [Development](#development)
|
25
|
+
- [Contributing](#contributing)
|
26
|
+
- [License](#license)
|
27
|
+
|
8
28
|
## Installation
|
9
29
|
|
10
30
|
Install the gem by executing:
|
@@ -191,6 +211,10 @@ version: 1 # Required, currently only version 1 is supported
|
|
191
211
|
swarm:
|
192
212
|
name: "Swarm Name" # Display name for your swarm
|
193
213
|
main: instance_key # Which instance to launch as the main interface
|
214
|
+
before: # Optional: commands to run before launching the swarm
|
215
|
+
- "echo 'Setting up environment...'"
|
216
|
+
- "npm install"
|
217
|
+
- "docker-compose up -d"
|
194
218
|
instances:
|
195
219
|
# Instance definitions...
|
196
220
|
```
|
@@ -203,14 +227,15 @@ Each instance must have:
|
|
203
227
|
|
204
228
|
Each instance can have:
|
205
229
|
|
206
|
-
- **directory**: Working directory for this instance (can use ~ for home)
|
207
|
-
- **model**: Claude model to use (opus, sonnet
|
230
|
+
- **directory**: Working directory for this instance (can use ~ for home). Can be a string for a single directory or an array of strings for multiple directories
|
231
|
+
- **model**: Claude model to use (opus, sonnet)
|
208
232
|
- **connections**: Array of other instances this one can communicate with
|
209
233
|
- **allowed_tools**: Array of tools this instance can use (backward compatible with `tools`)
|
210
234
|
- **disallowed_tools**: Array of tools to explicitly deny (takes precedence over allowed_tools)
|
211
235
|
- **mcps**: Array of additional MCP servers to connect
|
212
236
|
- **prompt**: Custom system prompt to append to the instance
|
213
237
|
- **vibe**: Enable vibe mode (--dangerously-skip-permissions) for this instance (default: false)
|
238
|
+
- **worktree**: Configure Git worktree usage for this instance (true/false/string)
|
214
239
|
|
215
240
|
```yaml
|
216
241
|
instance_name:
|
@@ -336,7 +361,7 @@ swarm:
|
|
336
361
|
database:
|
337
362
|
description: "Database administrator managing data persistence"
|
338
363
|
directory: ./db
|
339
|
-
model:
|
364
|
+
model: sonnet
|
340
365
|
allowed_tools:
|
341
366
|
- Read
|
342
367
|
- Bash
|
@@ -398,6 +423,72 @@ swarm:
|
|
398
423
|
- Read
|
399
424
|
```
|
400
425
|
|
426
|
+
#### Multi-Directory Support
|
427
|
+
|
428
|
+
Instances can have access to multiple directories using an array (uses `claude --add-dir`):
|
429
|
+
|
430
|
+
```yaml
|
431
|
+
version: 1
|
432
|
+
swarm:
|
433
|
+
name: "Multi-Module Project"
|
434
|
+
main: fullstack_dev
|
435
|
+
instances:
|
436
|
+
fullstack_dev:
|
437
|
+
description: "Full-stack developer working across multiple modules"
|
438
|
+
directory: [./frontend, ./backend, ./shared] # Access to multiple directories
|
439
|
+
model: opus
|
440
|
+
allowed_tools: [Read, Edit, Write, Bash]
|
441
|
+
prompt: "You work across frontend, backend, and shared code modules"
|
442
|
+
|
443
|
+
documentation_writer:
|
444
|
+
description: "Documentation specialist with access to code and docs"
|
445
|
+
directory: ["./docs", "./src", "./examples"] # Multiple directories as array
|
446
|
+
model: sonnet
|
447
|
+
allowed_tools: [Read, Write, Edit]
|
448
|
+
prompt: "You maintain documentation based on code and examples"
|
449
|
+
```
|
450
|
+
|
451
|
+
When using multiple directories:
|
452
|
+
- The first directory in the array is the primary working directory
|
453
|
+
- Additional directories are accessible via the `--add-dir` flag in Claude
|
454
|
+
- All directories must exist or the configuration will fail validation
|
455
|
+
|
456
|
+
#### Before Commands
|
457
|
+
|
458
|
+
You can specify commands to run before launching the swarm using the `before` field:
|
459
|
+
|
460
|
+
```yaml
|
461
|
+
version: 1
|
462
|
+
swarm:
|
463
|
+
name: "Development Environment"
|
464
|
+
main: lead_developer
|
465
|
+
before:
|
466
|
+
- "echo '🚀 Setting up development environment...'"
|
467
|
+
- "npm install"
|
468
|
+
- "docker-compose up -d"
|
469
|
+
- "bundle install"
|
470
|
+
instances:
|
471
|
+
lead_developer:
|
472
|
+
description: "Lead developer coordinating the team"
|
473
|
+
directory: .
|
474
|
+
model: opus
|
475
|
+
allowed_tools: [Read, Edit, Write, Bash]
|
476
|
+
```
|
477
|
+
|
478
|
+
The `before` commands:
|
479
|
+
- Are executed in sequence before launching any Claude instances
|
480
|
+
- Must all succeed for the swarm to launch (exit code 0)
|
481
|
+
- Are only executed on initial swarm launch, not when restoring sessions
|
482
|
+
- Have their output logged to the session log file
|
483
|
+
- Will abort the swarm launch if any command fails
|
484
|
+
|
485
|
+
This is useful for:
|
486
|
+
- Installing dependencies
|
487
|
+
- Starting required services (databases, Docker containers, etc.)
|
488
|
+
- Setting up the development environment
|
489
|
+
- Running any prerequisite setup scripts
|
490
|
+
|
491
|
+
|
401
492
|
#### Mixed Permission Modes
|
402
493
|
|
403
494
|
You can have different permission modes for different instances:
|
@@ -429,6 +520,72 @@ swarm:
|
|
429
520
|
allowed_tools: [] # Tools list ignored when vibe: true
|
430
521
|
```
|
431
522
|
|
523
|
+
#### Git Worktrees
|
524
|
+
|
525
|
+
Claude Swarm supports running instances in Git worktrees, allowing isolated work without affecting your main repository state. Worktrees are created inside each repository in a `.worktrees/` directory following Git best practices.
|
526
|
+
|
527
|
+
**Example Structure:**
|
528
|
+
```
|
529
|
+
my-repo/
|
530
|
+
├── .git/
|
531
|
+
├── .worktrees/ (created by Claude Swarm)
|
532
|
+
│ ├── .gitignore (auto-created, contains "*")
|
533
|
+
│ └── feature-x/ (worktree for feature-x branch)
|
534
|
+
├── src/
|
535
|
+
└── tests/
|
536
|
+
```
|
537
|
+
|
538
|
+
**CLI Option:**
|
539
|
+
```bash
|
540
|
+
# Create worktrees with auto-generated name (worktree-SESSION_ID)
|
541
|
+
claude-swarm --worktree
|
542
|
+
|
543
|
+
# Create worktrees with custom name
|
544
|
+
claude-swarm --worktree feature-branch
|
545
|
+
|
546
|
+
# Short form
|
547
|
+
claude-swarm -w
|
548
|
+
```
|
549
|
+
|
550
|
+
**Per-Instance Configuration:**
|
551
|
+
```yaml
|
552
|
+
version: 1
|
553
|
+
swarm:
|
554
|
+
name: "Worktree Example"
|
555
|
+
main: lead
|
556
|
+
instances:
|
557
|
+
lead:
|
558
|
+
description: "Lead developer"
|
559
|
+
directory: .
|
560
|
+
worktree: true # Use shared worktree name from CLI (or auto-generate)
|
561
|
+
|
562
|
+
testing:
|
563
|
+
description: "Test developer"
|
564
|
+
directory: ./tests
|
565
|
+
worktree: false # Don't use worktree for this instance
|
566
|
+
|
567
|
+
feature_dev:
|
568
|
+
description: "Feature developer"
|
569
|
+
directory: ./features
|
570
|
+
worktree: "feature-x" # Use specific worktree name
|
571
|
+
```
|
572
|
+
|
573
|
+
**Worktree Behavior:**
|
574
|
+
- `worktree: true` - Uses the shared worktree name (from CLI or auto-generated)
|
575
|
+
- `worktree: false` - Disables worktree for this instance
|
576
|
+
- `worktree: "name"` - Uses a specific worktree name
|
577
|
+
- Omitted - Follows CLI behavior (use worktree if `--worktree` is specified)
|
578
|
+
|
579
|
+
**Notes:**
|
580
|
+
- Worktrees are created inside each repository in a `.worktrees/` directory
|
581
|
+
- Auto-generated worktree names use the session ID (e.g., `worktree-20241206_143022`)
|
582
|
+
- This makes it easy to correlate worktrees with their Claude Swarm sessions
|
583
|
+
- A `.gitignore` file is automatically created inside `.worktrees/` to ignore all worktree contents
|
584
|
+
- All worktrees are automatically cleaned up when the swarm exits
|
585
|
+
- Worktrees with the same name across different repositories share that name
|
586
|
+
- Non-Git directories are unaffected by worktree settings
|
587
|
+
- Existing worktrees with the same name are reused
|
588
|
+
|
432
589
|
### Command Line Options
|
433
590
|
|
434
591
|
```bash
|
@@ -450,9 +607,10 @@ claude-swarm --prompt "Fix the bug in the payment module"
|
|
450
607
|
claude-swarm --session-id 20241206_143022
|
451
608
|
claude-swarm --session-id ~/path/to/session
|
452
609
|
|
453
|
-
#
|
454
|
-
claude-swarm
|
455
|
-
claude-swarm
|
610
|
+
# Run all instances in Git worktrees
|
611
|
+
claude-swarm --worktree # Auto-generated name (worktree-SESSION_ID)
|
612
|
+
claude-swarm --worktree feature-branch # Custom worktree name
|
613
|
+
claude-swarm -w # Short form
|
456
614
|
|
457
615
|
# Show version
|
458
616
|
claude-swarm version
|
@@ -464,6 +622,67 @@ claude-swarm version
|
|
464
622
|
claude-swarm mcp-serve INSTANCE_NAME --config CONFIG_FILE --session-timestamp TIMESTAMP
|
465
623
|
```
|
466
624
|
|
625
|
+
### Session Monitoring
|
626
|
+
|
627
|
+
Claude Swarm provides commands to monitor and inspect running sessions:
|
628
|
+
|
629
|
+
```bash
|
630
|
+
# List running swarm sessions with costs and uptime
|
631
|
+
claude-swarm ps
|
632
|
+
|
633
|
+
# Show detailed information about a session including instance hierarchy
|
634
|
+
claude-swarm show 20250617_235233
|
635
|
+
|
636
|
+
# Watch live logs from a session
|
637
|
+
claude-swarm watch 20250617_235233
|
638
|
+
|
639
|
+
# Watch logs starting from the last 50 lines
|
640
|
+
claude-swarm watch 20250617_235233 -n 50
|
641
|
+
|
642
|
+
# List all available sessions (including completed ones)
|
643
|
+
claude-swarm list-sessions
|
644
|
+
claude-swarm list-sessions --limit 20
|
645
|
+
|
646
|
+
# Clean up stale session symlinks
|
647
|
+
claude-swarm clean
|
648
|
+
|
649
|
+
# Remove sessions older than 30 days
|
650
|
+
claude-swarm clean --days 30
|
651
|
+
```
|
652
|
+
|
653
|
+
Example output from `claude-swarm ps`:
|
654
|
+
```
|
655
|
+
⚠️ Total cost does not include the cost of the main instance
|
656
|
+
|
657
|
+
SESSION_ID SWARM_NAME TOTAL_COST UPTIME DIRECTORY
|
658
|
+
-------------------------------------------------------------------------------
|
659
|
+
20250617_235233 Feature Development $0.3847 15m .
|
660
|
+
20250617_143022 Bug Investigation $1.2156 1h ./shopify
|
661
|
+
20250617_091547 Multi-Module Dev $0.8932 30m ./frontend, ./backend, ./shared
|
662
|
+
```
|
663
|
+
|
664
|
+
Note: The total cost shown reflects only the costs of connected instances called via MCP. The main instance cost is not tracked when running interactively.
|
665
|
+
|
666
|
+
Example output from `claude-swarm show`:
|
667
|
+
```
|
668
|
+
Session: 20250617_235233
|
669
|
+
Swarm: Feature Development
|
670
|
+
Total Cost: $0.3847 (excluding main instance)
|
671
|
+
Start Directory: /Users/paulo/project
|
672
|
+
|
673
|
+
Instance Hierarchy:
|
674
|
+
--------------------------------------------------
|
675
|
+
├─ orchestrator [main] (orchestrator_e85036fc)
|
676
|
+
Cost: n/a (interactive) | Calls: 0
|
677
|
+
└─ test_archaeologist (test_archaeologist_c504ca5f)
|
678
|
+
Cost: $0.1925 | Calls: 1
|
679
|
+
└─ pr_analyst (pr_analyst_bfbefe56)
|
680
|
+
Cost: $0.1922 | Calls: 1
|
681
|
+
|
682
|
+
Note: Main instance (orchestrator) cost is not tracked in interactive mode.
|
683
|
+
View costs directly in the Claude interface.
|
684
|
+
```
|
685
|
+
|
467
686
|
### Session Management and Restoration (Experimental)
|
468
687
|
|
469
688
|
Claude Swarm provides experimental session management with restoration capabilities. **Note: This feature is experimental and has limitations - the main instance's conversation context is not fully restored.**
|
@@ -502,10 +721,10 @@ Resume a previous session with all instances restored to their Claude session st
|
|
502
721
|
|
503
722
|
```bash
|
504
723
|
# Resume by session ID
|
505
|
-
claude-swarm --session-id
|
724
|
+
claude-swarm --session-id 20250617_143022
|
506
725
|
|
507
726
|
# Resume by full path
|
508
|
-
claude-swarm --session-id ~/.claude-swarm/sessions/my-project/
|
727
|
+
claude-swarm --session-id ~/.claude-swarm/sessions/my-project/20250617_143022
|
509
728
|
```
|
510
729
|
|
511
730
|
This will:
|
data/claude-swarm.yml
CHANGED
@@ -1,42 +1,14 @@
|
|
1
1
|
version: 1
|
2
2
|
swarm:
|
3
3
|
name: "Swarm Name"
|
4
|
-
main:
|
4
|
+
main: claude_swarm_architect
|
5
5
|
instances:
|
6
|
-
|
7
|
-
description: "Lead
|
6
|
+
claude_swarm_architect:
|
7
|
+
description: "Lead architect"
|
8
8
|
directory: .
|
9
|
-
model:
|
10
|
-
prompt: "You are
|
11
|
-
|
12
|
-
connections: [
|
9
|
+
model: opus
|
10
|
+
prompt: "You are an expert in Claude swarm architecture"
|
11
|
+
vibe: true
|
12
|
+
connections: [claudeception_architect]
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
frontend_dev:
|
17
|
-
description: "Frontend developer specializing in React and modern web technologies"
|
18
|
-
directory: .
|
19
|
-
model: sonnet
|
20
|
-
prompt: "You specialize in frontend development with React, TypeScript, and modern web technologies"
|
21
|
-
allowed_tools: [Read, Edit, Write, Bash]
|
22
|
-
|
23
|
-
backend_dev:
|
24
|
-
description: "Backend developer focusing on APIs, databases, and server architecture"
|
25
|
-
directory: .
|
26
|
-
model: sonnet
|
27
|
-
prompt: "You specialize in backend development, APIs, databases, and server architecture"
|
28
|
-
allowed_tools: [Read, Edit, Write, Bash]
|
29
|
-
|
30
|
-
# devops_engineer:
|
31
|
-
# description: "DevOps engineer managing infrastructure, CI/CD, and deployments"
|
32
|
-
# directory: .
|
33
|
-
# model: sonnet
|
34
|
-
# prompt: "You specialize in infrastructure, CI/CD, containerization, and deployment"
|
35
|
-
# allowed_tools: [Read, Edit, Write, Bash]
|
36
|
-
|
37
|
-
# qa_engineer:
|
38
|
-
# description: "QA engineer ensuring quality through comprehensive testing"
|
39
|
-
# directory: ./tests
|
40
|
-
# model: sonnet
|
41
|
-
# prompt: "You specialize in testing, quality assurance, and test automation"
|
42
|
-
# allowed_tools: [Read, Edit, Write, Bash]
|
14
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
version: 1
|
2
|
+
swarm:
|
3
|
+
name: "Monitoring Demo"
|
4
|
+
main: coordinator
|
5
|
+
instances:
|
6
|
+
coordinator:
|
7
|
+
description: "Main coordinator managing the team"
|
8
|
+
directory: .
|
9
|
+
model: haiku
|
10
|
+
connections: [analyzer, reporter]
|
11
|
+
prompt: "You coordinate analysis and reporting tasks"
|
12
|
+
allowed_tools: [Read, Edit]
|
13
|
+
|
14
|
+
analyzer:
|
15
|
+
description: "Data analyzer processing information"
|
16
|
+
directory: ./data
|
17
|
+
model: haiku
|
18
|
+
prompt: "You analyze data and provide insights"
|
19
|
+
allowed_tools: [Read, Bash]
|
20
|
+
|
21
|
+
reporter:
|
22
|
+
description: "Report generator creating summaries"
|
23
|
+
directory: ./reports
|
24
|
+
model: haiku
|
25
|
+
prompt: "You generate reports from analysis"
|
26
|
+
allowed_tools: [Write, Edit]
|
@@ -0,0 +1,26 @@
|
|
1
|
+
version: 1
|
2
|
+
swarm:
|
3
|
+
name: "Multi-Directory Example"
|
4
|
+
main: fullstack_dev
|
5
|
+
instances:
|
6
|
+
fullstack_dev:
|
7
|
+
description: "Full-stack developer with access to multiple project directories"
|
8
|
+
directory: [./frontend, ./backend, ./shared, ./docs]
|
9
|
+
model: opus
|
10
|
+
connections: [frontend_specialist, backend_specialist]
|
11
|
+
allowed_tools: [Read, Edit, Write, Bash, WebSearch]
|
12
|
+
prompt: "You are a full-stack developer with access to frontend, backend, shared code, and documentation directories"
|
13
|
+
|
14
|
+
frontend_specialist:
|
15
|
+
description: "Frontend developer focused on React components"
|
16
|
+
directory: ./frontend
|
17
|
+
model: sonnet
|
18
|
+
allowed_tools: [Read, Edit, Write, Bash]
|
19
|
+
prompt: "You specialize in React and frontend development"
|
20
|
+
|
21
|
+
backend_specialist:
|
22
|
+
description: "Backend developer focused on API development"
|
23
|
+
directory: ./backend
|
24
|
+
model: sonnet
|
25
|
+
allowed_tools: [Read, Edit, Write, Bash]
|
26
|
+
prompt: "You specialize in backend API development"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
version: 1
|
2
|
+
swarm:
|
3
|
+
name: "Development Environment"
|
4
|
+
main: lead_developer
|
5
|
+
before:
|
6
|
+
- "echo '🚀 Setting up development environment...'"
|
7
|
+
- "echo '📦 Installing dependencies...'"
|
8
|
+
- "echo '🐳 Starting Docker containers...'"
|
9
|
+
instances:
|
10
|
+
lead_developer:
|
11
|
+
description: "Lead developer who coordinates the team"
|
12
|
+
directory: .
|
13
|
+
model: sonnet
|
14
|
+
prompt: "You are the lead developer coordinating the team"
|
15
|
+
allowed_tools: [Read, Edit, Bash, Write]
|
16
|
+
connections: [frontend_dev, backend_dev]
|
17
|
+
|
18
|
+
frontend_dev:
|
19
|
+
description: "Frontend developer specializing in React"
|
20
|
+
directory: ./frontend
|
21
|
+
model: sonnet
|
22
|
+
prompt: "You specialize in frontend development with React"
|
23
|
+
allowed_tools: [Read, Edit, Write]
|
24
|
+
|
25
|
+
backend_dev:
|
26
|
+
description: "Backend developer focusing on APIs"
|
27
|
+
directory: ./backend
|
28
|
+
model: sonnet
|
29
|
+
prompt: "You specialize in backend development and APIs"
|
30
|
+
allowed_tools: [Read, Edit, Write, Bash]
|
@@ -12,8 +12,9 @@ module ClaudeSwarm
|
|
12
12
|
|
13
13
|
def initialize(working_directory: Dir.pwd, model: nil, mcp_config: nil, vibe: false,
|
14
14
|
instance_name: nil, instance_id: nil, calling_instance: nil, calling_instance_id: nil,
|
15
|
-
claude_session_id: nil)
|
15
|
+
claude_session_id: nil, additional_directories: [])
|
16
16
|
@working_directory = working_directory
|
17
|
+
@additional_directories = additional_directories
|
17
18
|
@model = model
|
18
19
|
@mcp_config = mcp_config
|
19
20
|
@vibe = vibe
|
@@ -259,6 +260,12 @@ module ClaudeSwarm
|
|
259
260
|
|
260
261
|
cmd_array << "--verbose"
|
261
262
|
|
263
|
+
# Add additional directories with --add-dir
|
264
|
+
cmd_array << "--add-dir" if @additional_directories.any?
|
265
|
+
@additional_directories.each do |additional_dir|
|
266
|
+
cmd_array << additional_dir
|
267
|
+
end
|
268
|
+
|
262
269
|
# Add MCP config if specified
|
263
270
|
cmd_array += ["--mcp-config", @mcp_config] if @mcp_config
|
264
271
|
|
@@ -28,7 +28,8 @@ module ClaudeSwarm
|
|
28
28
|
instance_id: instance_config[:instance_id],
|
29
29
|
calling_instance: calling_instance,
|
30
30
|
calling_instance_id: calling_instance_id,
|
31
|
-
claude_session_id: instance_config[:claude_session_id]
|
31
|
+
claude_session_id: instance_config[:claude_session_id],
|
32
|
+
additional_directories: instance_config[:directories][1..] || []
|
32
33
|
)
|
33
34
|
|
34
35
|
# Set class variables so tools can access them
|