claude_swarm 0.1.14 → 0.1.16
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 +32 -0
- data/CLAUDE.md +9 -5
- data/EXAMPLES.md +164 -0
- data/README.md +23 -28
- data/claude-swarm.yml +2 -2
- data/example/microservices-team.yml +17 -17
- data/example/test-generation.yml +7 -10
- data/lib/claude_swarm/claude_code_executor.rb +11 -6
- data/lib/claude_swarm/claude_mcp_server.rb +1 -1
- data/lib/claude_swarm/cli.rb +6 -20
- data/lib/claude_swarm/mcp_generator.rb +3 -22
- data/lib/claude_swarm/orchestrator.rb +11 -7
- data/lib/claude_swarm/task_tool.rb +6 -2
- data/lib/claude_swarm/version.rb +1 -1
- data/lib/claude_swarm.rb +0 -2
- data/llms.txt +383 -0
- metadata +5 -5
- data/lib/claude_swarm/permission_mcp_server.rb +0 -189
- data/lib/claude_swarm/permission_tool.rb +0 -201
- /data/{sdk-docs.md → claude-sdk-docs.md} +0 -0
data/lib/claude_swarm/cli.rb
CHANGED
@@ -6,7 +6,6 @@ require_relative "configuration"
|
|
6
6
|
require_relative "mcp_generator"
|
7
7
|
require_relative "orchestrator"
|
8
8
|
require_relative "claude_mcp_server"
|
9
|
-
require_relative "permission_mcp_server"
|
10
9
|
|
11
10
|
module ClaudeSwarm
|
12
11
|
class CLI < Thor
|
@@ -78,10 +77,12 @@ module ClaudeSwarm
|
|
78
77
|
desc: "System prompt for the instance"
|
79
78
|
method_option :description, type: :string,
|
80
79
|
desc: "Description of the instance's role"
|
81
|
-
method_option :
|
82
|
-
|
80
|
+
method_option :allowed_tools, aliases: "-t", type: :array,
|
81
|
+
desc: "Allowed tools for the instance"
|
83
82
|
method_option :disallowed_tools, type: :array,
|
84
83
|
desc: "Disallowed tools for the instance"
|
84
|
+
method_option :connections, type: :array,
|
85
|
+
desc: "Connections to other instances"
|
85
86
|
method_option :mcp_config_path, type: :string,
|
86
87
|
desc: "Path to MCP configuration file"
|
87
88
|
method_option :debug, type: :boolean, default: false,
|
@@ -103,8 +104,9 @@ module ClaudeSwarm
|
|
103
104
|
model: options[:model],
|
104
105
|
prompt: options[:prompt],
|
105
106
|
description: options[:description],
|
106
|
-
|
107
|
+
allowed_tools: options[:allowed_tools] || [],
|
107
108
|
disallowed_tools: options[:disallowed_tools] || [],
|
109
|
+
connections: options[:connections] || [],
|
108
110
|
mcp_config_path: options[:mcp_config_path],
|
109
111
|
vibe: options[:vibe],
|
110
112
|
instance_id: options[:instance_id],
|
@@ -265,22 +267,6 @@ module ClaudeSwarm
|
|
265
267
|
say " claude-swarm --session-id <session-id>", :cyan
|
266
268
|
end
|
267
269
|
|
268
|
-
desc "tools-mcp", "Start a permission management MCP server for tool access control"
|
269
|
-
method_option :allowed_tools, aliases: "-t", type: :string,
|
270
|
-
desc: "Comma-separated list of allowed tool patterns (supports wildcards)"
|
271
|
-
method_option :disallowed_tools, type: :string,
|
272
|
-
desc: "Comma-separated list of disallowed tool patterns (supports wildcards)"
|
273
|
-
method_option :debug, type: :boolean, default: false,
|
274
|
-
desc: "Enable debug output"
|
275
|
-
def tools_mcp
|
276
|
-
server = PermissionMcpServer.new(allowed_tools: options[:allowed_tools], disallowed_tools: options[:disallowed_tools])
|
277
|
-
server.start
|
278
|
-
rescue StandardError => e
|
279
|
-
error "Error starting permission MCP server: #{e.message}"
|
280
|
-
error e.backtrace.join("\n") if options[:debug]
|
281
|
-
exit 1
|
282
|
-
end
|
283
|
-
|
284
270
|
default_task :start
|
285
271
|
|
286
272
|
private
|
@@ -68,9 +68,6 @@ module ClaudeSwarm
|
|
68
68
|
)
|
69
69
|
end
|
70
70
|
|
71
|
-
# Add permission MCP server if not in vibe mode (global or instance-specific)
|
72
|
-
mcp_servers["permissions"] = build_permission_mcp_config(instance[:tools], instance[:disallowed_tools]) unless @vibe || instance[:vibe]
|
73
|
-
|
74
71
|
config = {
|
75
72
|
"instance_id" => @instance_ids[name],
|
76
73
|
"instance_name" => name,
|
@@ -115,10 +112,12 @@ module ClaudeSwarm
|
|
115
112
|
|
116
113
|
args.push("--description", instance[:description]) if instance[:description]
|
117
114
|
|
118
|
-
args.push("--tools", instance[:
|
115
|
+
args.push("--allowed-tools", instance[:allowed_tools].join(",")) if instance[:allowed_tools] && !instance[:allowed_tools].empty?
|
119
116
|
|
120
117
|
args.push("--disallowed-tools", instance[:disallowed_tools].join(",")) if instance[:disallowed_tools] && !instance[:disallowed_tools].empty?
|
121
118
|
|
119
|
+
args.push("--connections", instance[:connections].join(",")) if instance[:connections] && !instance[:connections].empty?
|
120
|
+
|
122
121
|
args.push("--mcp-config-path", mcp_config_path(name))
|
123
122
|
|
124
123
|
args.push("--calling-instance", calling_instance) if calling_instance
|
@@ -162,23 +161,5 @@ module ClaudeSwarm
|
|
162
161
|
# Skip invalid state files
|
163
162
|
end
|
164
163
|
end
|
165
|
-
|
166
|
-
def build_permission_mcp_config(allowed_tools, disallowed_tools)
|
167
|
-
exe_path = "claude-swarm"
|
168
|
-
|
169
|
-
args = ["tools-mcp"]
|
170
|
-
|
171
|
-
# Add allowed tools if specified
|
172
|
-
args.push("--allowed-tools", allowed_tools.join(",")) if allowed_tools && !allowed_tools.empty?
|
173
|
-
|
174
|
-
# Add disallowed tools if specified
|
175
|
-
args.push("--disallowed-tools", disallowed_tools.join(",")) if disallowed_tools && !disallowed_tools.empty?
|
176
|
-
|
177
|
-
{
|
178
|
-
"type" => "stdio",
|
179
|
-
"command" => exe_path,
|
180
|
-
"args" => args
|
181
|
-
}
|
182
|
-
end
|
183
164
|
end
|
184
165
|
end
|
@@ -91,7 +91,7 @@ module ClaudeSwarm
|
|
91
91
|
puts "🚀 Launching main instance: #{@config.main_instance}"
|
92
92
|
puts " Model: #{main_instance[:model]}"
|
93
93
|
puts " Directory: #{main_instance[:directory]}"
|
94
|
-
puts " Allowed tools: #{main_instance[:
|
94
|
+
puts " Allowed tools: #{main_instance[:allowed_tools].join(", ")}" if main_instance[:allowed_tools].any?
|
95
95
|
puts " Disallowed tools: #{main_instance[:disallowed_tools].join(", ")}" if main_instance[:disallowed_tools]&.any?
|
96
96
|
puts " Connections: #{main_instance[:connections].join(", ")}" if main_instance[:connections].any?
|
97
97
|
puts " 😎 Vibe mode ON for this instance" if main_instance[:vibe]
|
@@ -208,9 +208,17 @@ module ClaudeSwarm
|
|
208
208
|
if @vibe || instance[:vibe]
|
209
209
|
parts << "--dangerously-skip-permissions"
|
210
210
|
else
|
211
|
+
# Build allowed tools list including MCP connections
|
212
|
+
allowed_tools = instance[:allowed_tools].dup
|
213
|
+
|
214
|
+
# Add mcp__instance_name for each connection
|
215
|
+
instance[:connections].each do |connection_name|
|
216
|
+
allowed_tools << "mcp__#{connection_name}"
|
217
|
+
end
|
218
|
+
|
211
219
|
# Add allowed tools if any
|
212
|
-
if
|
213
|
-
tools_str =
|
220
|
+
if allowed_tools.any?
|
221
|
+
tools_str = allowed_tools.join(",")
|
214
222
|
parts << "--allowedTools"
|
215
223
|
parts << tools_str
|
216
224
|
end
|
@@ -221,10 +229,6 @@ module ClaudeSwarm
|
|
221
229
|
parts << "--disallowedTools"
|
222
230
|
parts << disallowed_tools_str
|
223
231
|
end
|
224
|
-
|
225
|
-
# Add permission prompt tool unless in vibe mode
|
226
|
-
parts << "--permission-prompt-tool"
|
227
|
-
parts << "mcp__permissions__check_permission"
|
228
232
|
end
|
229
233
|
|
230
234
|
if instance[:prompt]
|
@@ -3,7 +3,8 @@
|
|
3
3
|
module ClaudeSwarm
|
4
4
|
class TaskTool < FastMcp::Tool
|
5
5
|
tool_name "task"
|
6
|
-
description "Execute a task using Claude Code"
|
6
|
+
description "Execute a task using Claude Code. There is no description parameter."
|
7
|
+
annotations(read_only_hint: true, open_world_hint: false, destructive_hint: false)
|
7
8
|
|
8
9
|
arguments do
|
9
10
|
required(:prompt).filled(:string).description("The task or question for the agent")
|
@@ -21,11 +22,14 @@ module ClaudeSwarm
|
|
21
22
|
}
|
22
23
|
|
23
24
|
# Add allowed tools from instance config
|
24
|
-
options[:allowed_tools] = instance_config[:
|
25
|
+
options[:allowed_tools] = instance_config[:allowed_tools] if instance_config[:allowed_tools]&.any?
|
25
26
|
|
26
27
|
# Add disallowed tools from instance config
|
27
28
|
options[:disallowed_tools] = instance_config[:disallowed_tools] if instance_config[:disallowed_tools]&.any?
|
28
29
|
|
30
|
+
# Add connections from instance config
|
31
|
+
options[:connections] = instance_config[:connections] if instance_config[:connections]&.any?
|
32
|
+
|
29
33
|
response = executor.execute(prompt, options)
|
30
34
|
|
31
35
|
# Return just the result text as expected by MCP
|
data/lib/claude_swarm/version.rb
CHANGED
data/lib/claude_swarm.rb
CHANGED
@@ -7,8 +7,6 @@ require_relative "claude_swarm/mcp_generator"
|
|
7
7
|
require_relative "claude_swarm/orchestrator"
|
8
8
|
require_relative "claude_swarm/claude_code_executor"
|
9
9
|
require_relative "claude_swarm/claude_mcp_server"
|
10
|
-
require_relative "claude_swarm/permission_tool"
|
11
|
-
require_relative "claude_swarm/permission_mcp_server"
|
12
10
|
require_relative "claude_swarm/session_path"
|
13
11
|
require_relative "claude_swarm/session_info_tool"
|
14
12
|
require_relative "claude_swarm/reset_session_tool"
|
data/llms.txt
ADDED
@@ -0,0 +1,383 @@
|
|
1
|
+
# claude-swarm
|
2
|
+
claude-swarm is a Ruby gem that 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).
|
3
|
+
## Purpose
|
4
|
+
claude-swarm allows you to:
|
5
|
+
- Create teams of specialized AI agents working together
|
6
|
+
- Restrict tool access per agent for safety and focus
|
7
|
+
- Organize agents in tree-like hierarchies for delegation
|
8
|
+
- Maintain separate working directories per agent
|
9
|
+
- Enable inter-agent communication via MCP protocol
|
10
|
+
- Track sessions and restore previous swarm states
|
11
|
+
## Installation
|
12
|
+
```bash
|
13
|
+
# Install via RubyGems
|
14
|
+
gem install claude_swarm
|
15
|
+
# Or add to Gemfile
|
16
|
+
gem 'claude_swarm'
|
17
|
+
bundle install
|
18
|
+
```
|
19
|
+
### Prerequisites
|
20
|
+
- Ruby 3.2.0 or higher
|
21
|
+
- Claude CLI installed and configured (`claude` command available)
|
22
|
+
- Any MCP servers you plan to use (optional)
|
23
|
+
## Quick Start
|
24
|
+
1. Initialize a configuration:
|
25
|
+
```bash
|
26
|
+
claude-swarm init
|
27
|
+
```
|
28
|
+
2. Or create `claude-swarm.yml`:
|
29
|
+
```yaml
|
30
|
+
version: 1
|
31
|
+
swarm:
|
32
|
+
name: "My Dev Team"
|
33
|
+
main: lead
|
34
|
+
instances:
|
35
|
+
lead:
|
36
|
+
description: "Team lead coordinating development"
|
37
|
+
directory: .
|
38
|
+
model: opus
|
39
|
+
connections: [frontend, backend]
|
40
|
+
allowed_tools: [Read, Edit, Bash]
|
41
|
+
prompt: "You coordinate the team"
|
42
|
+
frontend:
|
43
|
+
description: "Frontend developer"
|
44
|
+
directory: ./frontend
|
45
|
+
model: sonnet
|
46
|
+
allowed_tools: [Read, Edit, Write, "Bash(npm:*)"]
|
47
|
+
```
|
48
|
+
3. Start the swarm:
|
49
|
+
```bash
|
50
|
+
claude-swarm
|
51
|
+
claude-swarm --vibe # Allow all tools (dangerous!)
|
52
|
+
```
|
53
|
+
## Key Concepts
|
54
|
+
### Swarm
|
55
|
+
A collection of Claude instances (agents) working together. One instance is designated as "main" - the entry point that coordinates others.
|
56
|
+
### Instance
|
57
|
+
An individual Claude Code agent with:
|
58
|
+
- **description** (required): Role and responsibilities
|
59
|
+
- **directory**: Working directory context
|
60
|
+
- **model**: Claude model (opus/sonnet/haiku)
|
61
|
+
- **connections**: Other instances it can delegate to
|
62
|
+
- **allowed_tools**: Tools this instance can use
|
63
|
+
- **disallowed_tools**: Explicitly denied tools (override allowed)
|
64
|
+
- **prompt**: Custom system prompt
|
65
|
+
- **vibe**: Skip permission checks for this instance
|
66
|
+
- **mcps**: Additional MCP servers
|
67
|
+
### MCP (Model Context Protocol)
|
68
|
+
Protocol enabling Claude to use external tools. claude-swarm uses MCP for:
|
69
|
+
- Inter-instance communication (task delegation)
|
70
|
+
- Permission management
|
71
|
+
- Additional tool integration
|
72
|
+
## Configuration Format
|
73
|
+
```yaml
|
74
|
+
version: 1
|
75
|
+
swarm:
|
76
|
+
name: "Swarm Name"
|
77
|
+
main: instance_key # Entry point instance
|
78
|
+
instances:
|
79
|
+
instance_name:
|
80
|
+
description: "Agent role description" # REQUIRED
|
81
|
+
directory: ~/path/to/dir # Working directory
|
82
|
+
model: opus # opus/sonnet/haiku
|
83
|
+
connections: [other1, other2] # Connected instances
|
84
|
+
prompt: "Custom system prompt" # Additional instructions
|
85
|
+
vibe: false # Skip permissions (default: false)
|
86
|
+
allowed_tools: # Tools this instance can use
|
87
|
+
- Read
|
88
|
+
- Edit
|
89
|
+
- Write
|
90
|
+
- Bash
|
91
|
+
- WebSearch
|
92
|
+
- WebFetch
|
93
|
+
disallowed_tools: # Explicitly deny patterns
|
94
|
+
- "Write(*.log)"
|
95
|
+
- "Bash(rm:*)"
|
96
|
+
mcps: # Additional MCP servers
|
97
|
+
- name: database
|
98
|
+
type: stdio
|
99
|
+
command: /path/to/mcp
|
100
|
+
args: ["--flag"]
|
101
|
+
env:
|
102
|
+
API_KEY: "value"
|
103
|
+
- name: api
|
104
|
+
type: sse
|
105
|
+
url: https://example.com/mcp
|
106
|
+
```
|
107
|
+
## Tool Patterns
|
108
|
+
Tools can be restricted using patterns:
|
109
|
+
- `Bash(npm:*)` - Only npm commands in Bash
|
110
|
+
- `Write(*.md)` - Only write markdown files
|
111
|
+
- `mcp__frontend__*` - All frontend MCP tools
|
112
|
+
- `Read` - Unrestricted Read tool
|
113
|
+
Disallowed tools always override allowed tools.
|
114
|
+
## Inter-Instance Communication
|
115
|
+
Instances communicate via the `task` tool exposed by connected instances:
|
116
|
+
### Task Tool
|
117
|
+
When instance A connects to instance B, A can use:
|
118
|
+
```
|
119
|
+
mcp__B__task
|
120
|
+
```
|
121
|
+
**Parameters:**
|
122
|
+
- `prompt` (required): The task or question for the agent
|
123
|
+
- `new_session` (optional): Start fresh session (default: false)
|
124
|
+
- `system_prompt` (optional): Override system prompt for this request
|
125
|
+
**Example Usage:**
|
126
|
+
```
|
127
|
+
Main instance: "Please analyze the frontend performance"
|
128
|
+
→ Uses mcp__frontend__task with prompt "Analyze performance bottlenecks"
|
129
|
+
→ Frontend instance executes with its tools and returns results
|
130
|
+
```
|
131
|
+
### Session Info Tool
|
132
|
+
```
|
133
|
+
mcp__B__session_info
|
134
|
+
```
|
135
|
+
Returns current Claude session ID and working directory.
|
136
|
+
### Reset Session Tool
|
137
|
+
```
|
138
|
+
mcp__B__reset_session
|
139
|
+
```
|
140
|
+
Resets the Claude session for a fresh start.
|
141
|
+
## Commands
|
142
|
+
### Start Swarm
|
143
|
+
```bash
|
144
|
+
# Default configuration
|
145
|
+
claude-swarm
|
146
|
+
# Custom configuration
|
147
|
+
claude-swarm --config team.yml
|
148
|
+
claude-swarm -c my-swarm.yml
|
149
|
+
# Skip all permissions (dangerous!)
|
150
|
+
claude-swarm --vibe
|
151
|
+
# Non-interactive mode with prompt
|
152
|
+
claude-swarm -p "Build a login feature"
|
153
|
+
claude-swarm --prompt "Fix the bug" --stream-logs
|
154
|
+
# Resume session
|
155
|
+
claude-swarm --session-id 20241225_120000
|
156
|
+
claude-swarm --session-id ~/.claude-swarm/sessions/project/20241225_120000
|
157
|
+
```
|
158
|
+
### List Sessions
|
159
|
+
```bash
|
160
|
+
# List recent sessions (default: 10)
|
161
|
+
claude-swarm list-sessions
|
162
|
+
# List more sessions
|
163
|
+
claude-swarm list-sessions --limit 20
|
164
|
+
# List for specific project
|
165
|
+
claude-swarm list-sessions --project myapp
|
166
|
+
```
|
167
|
+
### Other Commands
|
168
|
+
```bash
|
169
|
+
# Initialize starter config
|
170
|
+
claude-swarm init
|
171
|
+
# Show version
|
172
|
+
claude-swarm version
|
173
|
+
# Start permission MCP server (for testing)
|
174
|
+
claude-swarm tools-mcp --allowed-tools 'Read,Edit,mcp__*'
|
175
|
+
# Internal MCP serve command (used by swarm)
|
176
|
+
claude-swarm mcp-serve -n NAME -d DIR -m MODEL [options]
|
177
|
+
```
|
178
|
+
## Session Management
|
179
|
+
### Session Structure
|
180
|
+
Sessions are stored in `~/.claude-swarm/sessions/{project}/{timestamp}/`:
|
181
|
+
```
|
182
|
+
20241225_143022/
|
183
|
+
├── config.yml # Swarm configuration used
|
184
|
+
├── state/ # Instance states
|
185
|
+
│ ├── lead_abc123.json # Lead instance state
|
186
|
+
│ └── frontend_def456.json # Frontend instance state
|
187
|
+
├── lead.mcp.json # MCP configurations
|
188
|
+
├── frontend.mcp.json
|
189
|
+
├── session.log # Human-readable logs
|
190
|
+
├── session.log.json # JSONL format events
|
191
|
+
└── permissions.log # Permission decisions
|
192
|
+
```
|
193
|
+
### Session Files
|
194
|
+
- **config.yml**: Copy of swarm configuration
|
195
|
+
- **state/*.json**: Claude session IDs for each instance
|
196
|
+
- **session.log**: Request/response tracking
|
197
|
+
- **session.log.json**: All events in JSONL format
|
198
|
+
- **permissions.log**: Tool permission checks
|
199
|
+
### Restoring Sessions (Experimental)
|
200
|
+
```bash
|
201
|
+
claude-swarm --session-id 20241225_143022
|
202
|
+
```
|
203
|
+
**Limitations:**
|
204
|
+
- Main instance conversation context not fully restored
|
205
|
+
- Only session IDs preserved, not full state
|
206
|
+
- Connected instances restore more reliably
|
207
|
+
## Debugging
|
208
|
+
### Enable Debug Output
|
209
|
+
```bash
|
210
|
+
claude-swarm --debug
|
211
|
+
```
|
212
|
+
### Check Logs
|
213
|
+
```bash
|
214
|
+
# Session logs
|
215
|
+
cat ~/.claude-swarm/sessions/PROJECT/TIMESTAMP/session.log
|
216
|
+
cat ~/.claude-swarm/sessions/PROJECT/TIMESTAMP/permissions.log
|
217
|
+
# JSONL events
|
218
|
+
cat ~/.claude-swarm/sessions/PROJECT/TIMESTAMP/session.log.json
|
219
|
+
```
|
220
|
+
### Common Issues
|
221
|
+
**"Configuration file not found"**
|
222
|
+
- Ensure `claude-swarm.yml` exists
|
223
|
+
- Or use `--config path/to/config.yml`
|
224
|
+
**"Main instance not found"**
|
225
|
+
- Check `main:` references valid instance key
|
226
|
+
**"Circular dependency detected"**
|
227
|
+
- Remove circular connections between instances
|
228
|
+
**"Tool not allowed"**
|
229
|
+
- Check `allowed_tools` includes the tool
|
230
|
+
- Check `disallowed_tools` doesn't block it
|
231
|
+
- Use `vibe: true` to skip all checks (dangerous)
|
232
|
+
**"MCP server failed to start"**
|
233
|
+
- Check the command/URL is correct
|
234
|
+
- Verify MCP server is installed
|
235
|
+
- Check logs for error details
|
236
|
+
## Common Patterns
|
237
|
+
### Full-Stack Team
|
238
|
+
```yaml
|
239
|
+
instances:
|
240
|
+
architect:
|
241
|
+
description: "System architect"
|
242
|
+
connections: [frontend_lead, backend_lead, devops]
|
243
|
+
frontend_lead:
|
244
|
+
description: "Frontend team lead"
|
245
|
+
connections: [ui_dev, ux_designer]
|
246
|
+
backend_lead:
|
247
|
+
description: "Backend team lead"
|
248
|
+
connections: [api_dev, db_admin]
|
249
|
+
```
|
250
|
+
### Investigation Team
|
251
|
+
```yaml
|
252
|
+
instances:
|
253
|
+
investigator:
|
254
|
+
description: "Lead investigator"
|
255
|
+
connections: [data_analyst, code_expert, test_runner]
|
256
|
+
data_analyst:
|
257
|
+
description: "Analyzes metrics and logs"
|
258
|
+
allowed_tools: ["Bash(grep:*, awk:*)", Read]
|
259
|
+
code_expert:
|
260
|
+
description: "Reviews code changes"
|
261
|
+
allowed_tools: [Read, Grep, Glob]
|
262
|
+
```
|
263
|
+
### Mixed Permissions
|
264
|
+
```yaml
|
265
|
+
instances:
|
266
|
+
trusted_lead:
|
267
|
+
description: "Trusted lead with full access"
|
268
|
+
vibe: true # Skip all permission checks
|
269
|
+
restricted_worker:
|
270
|
+
description: "Limited access worker"
|
271
|
+
allowed_tools: [Read] # Read-only access
|
272
|
+
normal_worker:
|
273
|
+
description: "Standard developer"
|
274
|
+
allowed_tools: [Read, Edit, Write]
|
275
|
+
```
|
276
|
+
## Complete Example
|
277
|
+
### Performance Investigation Swarm
|
278
|
+
```yaml
|
279
|
+
version: 1
|
280
|
+
swarm:
|
281
|
+
name: "Performance Investigation"
|
282
|
+
main: coordinator
|
283
|
+
instances:
|
284
|
+
coordinator:
|
285
|
+
description: "Coordinates performance investigation"
|
286
|
+
directory: ~/projects/webapp
|
287
|
+
model: opus
|
288
|
+
connections: [metrics_analyst, code_reviewer, fix_implementer]
|
289
|
+
allowed_tools: [Read]
|
290
|
+
prompt: |
|
291
|
+
You coordinate a performance investigation team.
|
292
|
+
1. Use metrics_analyst to identify when/where issues occur
|
293
|
+
2. Use code_reviewer to find root causes
|
294
|
+
3. Use fix_implementer to create solutions
|
295
|
+
|
296
|
+
metrics_analyst:
|
297
|
+
description: "Analyzes performance metrics"
|
298
|
+
directory: ~/projects/webapp/logs
|
299
|
+
model: sonnet
|
300
|
+
allowed_tools: [Read, "Bash(grep:*, awk:*, sort:*)"]
|
301
|
+
prompt: |
|
302
|
+
You analyze logs and metrics for performance issues.
|
303
|
+
Focus on response times, error rates, and patterns.
|
304
|
+
|
305
|
+
code_reviewer:
|
306
|
+
description: "Reviews code for performance issues"
|
307
|
+
directory: ~/projects/webapp/src
|
308
|
+
model: opus
|
309
|
+
allowed_tools: [Read, Grep, Glob]
|
310
|
+
prompt: |
|
311
|
+
You review code for performance bottlenecks.
|
312
|
+
Look for N+1 queries, missing indexes, inefficient algorithms.
|
313
|
+
|
314
|
+
fix_implementer:
|
315
|
+
description: "Implements performance fixes"
|
316
|
+
directory: ~/projects/webapp
|
317
|
+
model: opus
|
318
|
+
allowed_tools: [Read, Edit, Write, Bash]
|
319
|
+
prompt: |
|
320
|
+
You implement optimizations and fixes.
|
321
|
+
Always add tests and measure improvements.
|
322
|
+
```
|
323
|
+
### Usage Flow
|
324
|
+
1. **User**: "The checkout page is slow"
|
325
|
+
2. **Coordinator** → **metrics_analyst**: "Find checkout performance metrics"
|
326
|
+
3. **Metrics analyst** returns: "Latency spike at 2pm, 3x increase"
|
327
|
+
4. **Coordinator** → **code_reviewer**: "What changed around 2pm?"
|
328
|
+
5. **Code reviewer** returns: "HTTP client gem updated, removed connection pooling"
|
329
|
+
6. **Coordinator** → **fix_implementer**: "Add connection pooling configuration"
|
330
|
+
7. **Fix implementer**: Creates fix and tests
|
331
|
+
## How It Works
|
332
|
+
1. **Configuration Parsing**: Validates YAML and expands paths
|
333
|
+
2. **MCP Generation**: Creates MCP configs in `.claude-swarm/`
|
334
|
+
3. **Permission Setup**: Adds permission MCP server (unless vibe mode)
|
335
|
+
4. **Instance Launch**: Starts main instance with connections
|
336
|
+
5. **Task Delegation**: Main instance uses mcp__instance__task tools
|
337
|
+
6. **Session Tracking**: All activity logged to session directory
|
338
|
+
## Development
|
339
|
+
```bash
|
340
|
+
# Setup
|
341
|
+
bin/setup
|
342
|
+
# Run tests
|
343
|
+
rake test
|
344
|
+
# Lint code
|
345
|
+
rake rubocop -A
|
346
|
+
# Console
|
347
|
+
bin/console
|
348
|
+
# Install locally
|
349
|
+
bundle exec rake install
|
350
|
+
# Release to RubyGems
|
351
|
+
bundle exec rake release
|
352
|
+
```
|
353
|
+
## Architecture
|
354
|
+
- **CLI** (`cli.rb`): Thor-based commands
|
355
|
+
- **Configuration** (`configuration.rb`): YAML parser/validator
|
356
|
+
- **McpGenerator** (`mcp_generator.rb`): Creates MCP JSON configs
|
357
|
+
- **Orchestrator** (`orchestrator.rb`): Launches main instance
|
358
|
+
- **ClaudeCodeExecutor** (`claude_code_executor.rb`): Executes Claude
|
359
|
+
- **ClaudeMcpServer** (`claude_mcp_server.rb`): Inter-instance MCP
|
360
|
+
- **PermissionMcpServer** (`permission_mcp_server.rb`): Tool permissions
|
361
|
+
## Environment Variables
|
362
|
+
- `CLAUDE_SWARM_HOME`: Override session storage location (default: ~/.claude-swarm)
|
363
|
+
- `ANTHROPIC_MODEL`: Default Claude model if not specified
|
364
|
+
## Security Considerations
|
365
|
+
- Tool restrictions enforced through configuration
|
366
|
+
- Vibe mode bypasses ALL restrictions - use carefully
|
367
|
+
- Session files may contain sensitive data
|
368
|
+
- Each instance runs with its directory context
|
369
|
+
- MCP servers inherit instance tool configurations
|
370
|
+
## Limitations
|
371
|
+
- Tree hierarchy only (no circular dependencies)
|
372
|
+
- Session restoration is experimental
|
373
|
+
- Main instance context not fully preserved
|
374
|
+
- All paths expand relative to execution directory
|
375
|
+
- MCP servers must support required protocol
|
376
|
+
## Best Practices
|
377
|
+
1. **Clear Descriptions**: Help agents understand their roles
|
378
|
+
2. **Focused Tools**: Give each instance only needed tools
|
379
|
+
3. **Directory Context**: Place instances in relevant directories
|
380
|
+
4. **Prompt Engineering**: Use prompts to guide behavior
|
381
|
+
5. **Test Configurations**: Start simple, add complexity gradually
|
382
|
+
6. **Monitor Logs**: Check session logs for issues
|
383
|
+
7. **Use Vibe Sparingly**: Only for trusted operations
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: claude_swarm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paulo Arruda
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- !ruby/object:Gem::Version
|
25
25
|
version: '1.3'
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
|
-
name: fast-mcp
|
27
|
+
name: fast-mcp-annotations
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
30
30
|
- - ">="
|
@@ -54,10 +54,12 @@ files:
|
|
54
54
|
- ".ruby-version"
|
55
55
|
- CHANGELOG.md
|
56
56
|
- CLAUDE.md
|
57
|
+
- EXAMPLES.md
|
57
58
|
- LICENSE
|
58
59
|
- README.md
|
59
60
|
- RELEASING.md
|
60
61
|
- Rakefile
|
62
|
+
- claude-sdk-docs.md
|
61
63
|
- claude-swarm.yml
|
62
64
|
- example/claude-swarm.yml
|
63
65
|
- example/microservices-team.yml
|
@@ -71,15 +73,13 @@ files:
|
|
71
73
|
- lib/claude_swarm/configuration.rb
|
72
74
|
- lib/claude_swarm/mcp_generator.rb
|
73
75
|
- lib/claude_swarm/orchestrator.rb
|
74
|
-
- lib/claude_swarm/permission_mcp_server.rb
|
75
|
-
- lib/claude_swarm/permission_tool.rb
|
76
76
|
- lib/claude_swarm/process_tracker.rb
|
77
77
|
- lib/claude_swarm/reset_session_tool.rb
|
78
78
|
- lib/claude_swarm/session_info_tool.rb
|
79
79
|
- lib/claude_swarm/session_path.rb
|
80
80
|
- lib/claude_swarm/task_tool.rb
|
81
81
|
- lib/claude_swarm/version.rb
|
82
|
-
-
|
82
|
+
- llms.txt
|
83
83
|
homepage: https://github.com/parruda/claude-swarm
|
84
84
|
licenses: []
|
85
85
|
metadata:
|