claude_swarm 1.0.6 → 1.0.8
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/.ruby-version +1 -1
- data/CHANGELOG.md +27 -0
- data/README.md +336 -1037
- data/docs/V1_TO_V2_MIGRATION_GUIDE.md +1120 -0
- data/docs/v1/README.md +1197 -0
- data/docs/v2/CHANGELOG.swarm_cli.md +22 -0
- data/docs/v2/CHANGELOG.swarm_memory.md +20 -0
- data/docs/v2/CHANGELOG.swarm_sdk.md +287 -10
- data/docs/v2/README.md +32 -6
- data/docs/v2/guides/complete-tutorial.md +133 -37
- data/docs/v2/guides/composable-swarms.md +1178 -0
- data/docs/v2/guides/getting-started.md +42 -1
- data/docs/v2/guides/snapshots.md +1498 -0
- data/docs/v2/reference/architecture-flow.md +5 -3
- data/docs/v2/reference/event_payload_structures.md +249 -12
- data/docs/v2/reference/execution-flow.md +1 -1
- data/docs/v2/reference/ruby-dsl.md +368 -22
- data/docs/v2/reference/yaml.md +314 -63
- data/examples/snapshot_demo.rb +119 -0
- data/examples/v2/dsl/01_basic.rb +0 -2
- data/examples/v2/dsl/02_core_parameters.rb +0 -2
- data/examples/v2/dsl/03_capabilities.rb +0 -2
- data/examples/v2/dsl/04_llm_parameters.rb +0 -2
- data/examples/v2/dsl/05_advanced_flags.rb +0 -3
- data/examples/v2/dsl/06_permissions.rb +0 -4
- data/examples/v2/dsl/07_mcp_server.rb +0 -2
- data/examples/v2/dsl/08_swarm_hooks.rb +0 -2
- data/examples/v2/dsl/09_agent_hooks.rb +0 -2
- data/examples/v2/dsl/10_all_agents_hooks.rb +0 -3
- data/examples/v2/dsl/11_delegation.rb +0 -2
- data/examples/v2/dsl/12_complete_integration.rb +2 -6
- data/examples/v2/node_context_demo.rb +1 -1
- data/examples/v2/node_workflow.rb +2 -4
- data/examples/v2/plan_and_execute.rb +157 -0
- data/lib/claude_swarm/cli.rb +0 -18
- data/lib/claude_swarm/configuration.rb +28 -18
- data/lib/claude_swarm/openai/chat_completion.rb +2 -11
- data/lib/claude_swarm/openai/responses.rb +2 -11
- data/lib/claude_swarm/version.rb +1 -1
- data/lib/swarm_cli/formatters/human_formatter.rb +103 -0
- data/lib/swarm_cli/interactive_repl.rb +9 -3
- data/lib/swarm_cli/version.rb +1 -1
- data/lib/swarm_memory/core/storage_read_tracker.rb +51 -14
- data/lib/swarm_memory/integration/cli_registration.rb +3 -2
- data/lib/swarm_memory/integration/sdk_plugin.rb +11 -5
- data/lib/swarm_memory/tools/memory_edit.rb +2 -2
- data/lib/swarm_memory/tools/memory_multi_edit.rb +2 -2
- data/lib/swarm_memory/tools/memory_read.rb +3 -3
- data/lib/swarm_memory/version.rb +1 -1
- data/lib/swarm_memory.rb +5 -0
- data/lib/swarm_sdk/agent/builder.rb +33 -0
- data/lib/swarm_sdk/agent/chat/context_tracker.rb +33 -0
- data/lib/swarm_sdk/agent/chat/hook_integration.rb +49 -3
- data/lib/swarm_sdk/agent/chat/system_reminder_injector.rb +11 -27
- data/lib/swarm_sdk/agent/chat.rb +200 -51
- data/lib/swarm_sdk/agent/context.rb +6 -2
- data/lib/swarm_sdk/agent/context_manager.rb +6 -0
- data/lib/swarm_sdk/agent/definition.rb +14 -2
- data/lib/swarm_sdk/agent/llm_instrumentation_middleware.rb +180 -0
- data/lib/swarm_sdk/configuration.rb +387 -94
- data/lib/swarm_sdk/events_to_messages.rb +181 -0
- data/lib/swarm_sdk/log_collector.rb +31 -5
- data/lib/swarm_sdk/log_stream.rb +37 -8
- data/lib/swarm_sdk/model_aliases.json +4 -1
- data/lib/swarm_sdk/node/agent_config.rb +33 -8
- data/lib/swarm_sdk/node/builder.rb +39 -18
- data/lib/swarm_sdk/node_orchestrator.rb +293 -26
- data/lib/swarm_sdk/proc_helpers.rb +53 -0
- data/lib/swarm_sdk/providers/openai_with_responses.rb +22 -15
- data/lib/swarm_sdk/restore_result.rb +65 -0
- data/lib/swarm_sdk/snapshot.rb +156 -0
- data/lib/swarm_sdk/snapshot_from_events.rb +386 -0
- data/lib/swarm_sdk/state_restorer.rb +491 -0
- data/lib/swarm_sdk/state_snapshot.rb +369 -0
- data/lib/swarm_sdk/swarm/agent_initializer.rb +360 -55
- data/lib/swarm_sdk/swarm/all_agents_builder.rb +28 -1
- data/lib/swarm_sdk/swarm/builder.rb +208 -12
- data/lib/swarm_sdk/swarm/swarm_registry_builder.rb +67 -0
- data/lib/swarm_sdk/swarm/tool_configurator.rb +46 -11
- data/lib/swarm_sdk/swarm.rb +338 -42
- data/lib/swarm_sdk/swarm_loader.rb +145 -0
- data/lib/swarm_sdk/swarm_registry.rb +136 -0
- data/lib/swarm_sdk/tools/delegate.rb +92 -7
- data/lib/swarm_sdk/tools/read.rb +17 -5
- data/lib/swarm_sdk/tools/stores/read_tracker.rb +47 -12
- data/lib/swarm_sdk/tools/stores/scratchpad_storage.rb +45 -0
- data/lib/swarm_sdk/utils.rb +18 -0
- data/lib/swarm_sdk/validation_result.rb +33 -0
- data/lib/swarm_sdk/version.rb +1 -1
- data/lib/swarm_sdk.rb +40 -8
- data/swarm_cli.gemspec +1 -1
- data/swarm_memory.gemspec +2 -2
- data/swarm_sdk.gemspec +2 -2
- metadata +21 -13
- data/examples/learning-assistant/assistant.md +0 -7
- data/examples/learning-assistant/example-memories/concept-example.md +0 -90
- data/examples/learning-assistant/example-memories/experience-example.md +0 -66
- data/examples/learning-assistant/example-memories/fact-example.md +0 -76
- data/examples/learning-assistant/example-memories/memory-index.md +0 -78
- data/examples/learning-assistant/example-memories/skill-example.md +0 -168
- data/examples/learning-assistant/learning_assistant.rb +0 -34
- data/examples/learning-assistant/learning_assistant.yml +0 -20
- data/lib/swarm_sdk/mcp.rb +0 -16
- data/llm.v2.txt +0 -13407
- /data/docs/v2/guides/{MEMORY_DEFRAG_GUIDE.md → memory-defrag-guide.md} +0 -0
- /data/{llms.txt → llms.claude-swarm.txt} +0 -0
data/README.md
CHANGED
|
@@ -1,1181 +1,480 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SwarmSDK, SwarmCLI & SwarmMemory
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
- **Single Process Architecture**: All agents run in one Ruby process using [RubyLLM](https://github.com/parruda/ruby_llm) - no more managing multiple Claude Code instances
|
|
7
|
-
- **More Efficient**: Direct method calls instead of MCP inter-process communication
|
|
8
|
-
- **Richer Features**: Node workflows, hooks system, scratchpad/memory tools, and more
|
|
9
|
-
- **Better Control**: Fine-grained permissions, cost tracking, structured logging
|
|
10
|
-
- **REPL**: Built with TTY toolkit for a nice command-line experience
|
|
11
|
-
- **Multiple LLM Providers**: Supports all LLM providers supported by RubyLLM
|
|
12
|
-
|
|
13
|
-
## Getting Started with v2
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
gem install swarm_cli # Includes swarm_sdk
|
|
17
|
-
swarm --help # Explore the modern CLI
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
**📚 Complete Documentation**: Check out the [SwarmSDK guides](docs/v2/README.md) including the comprehensive [complete tutorial](docs/v2/guides/complete-tutorial.md) covering all features.
|
|
21
|
-
|
|
22
|
-
**Note**: Claude Swarm (v1, documented below) will continue to be maintained and is still a great choice if you prefer the multi-process architecture with Claude Code instances.
|
|
23
|
-
|
|
24
|
-
# Claude Swarm
|
|
25
|
-
|
|
26
|
-
[](https://badge.fury.io/rb/claude_swarm)
|
|
3
|
+
[](https://badge.fury.io/rb/swarm_sdk)
|
|
4
|
+
[](https://badge.fury.io/rb/swarm_cli)
|
|
5
|
+
[](https://badge.fury.io/rb/swarm_memory)
|
|
27
6
|
[](https://github.com/parruda/claude-swarm/actions/workflows/ci.yml)
|
|
28
7
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
---
|
|
8
|
+
**A Ruby framework for orchestrating multiple AI agents as a collaborative team with persistent memory.**
|
|
32
9
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
- [Installation](#installation)
|
|
36
|
-
- [Prerequisites](#prerequisites)
|
|
37
|
-
- [Usage](#usage)
|
|
38
|
-
- [Quick Start](#quick-start)
|
|
39
|
-
- [Configuration Format](#configuration-format)
|
|
40
|
-
- [MCP Server Types](#mcp-server-types)
|
|
41
|
-
- [Tools](#tools)
|
|
42
|
-
- [Examples](#examples)
|
|
43
|
-
- [Command Line Options](#command-line-options)
|
|
44
|
-
- [Session Monitoring](#session-monitoring)
|
|
45
|
-
- [Session Management and Restoration](#session-management-and-restoration-experimental)
|
|
46
|
-
- [How It Works](#how-it-works)
|
|
47
|
-
- [Troubleshooting](#troubleshooting)
|
|
48
|
-
- [Architecture](#architecture)
|
|
49
|
-
- [Development](#development)
|
|
50
|
-
- [Contributing](#contributing)
|
|
51
|
-
- [License](#license)
|
|
52
|
-
|
|
53
|
-
## Installation
|
|
54
|
-
|
|
55
|
-
Install [Claude CLI](https://docs.anthropic.com/en/docs/claude-code/overview) if you haven't already:
|
|
10
|
+
SwarmSDK is a complete redesign of Claude Swarm that provides a better developer experience and is geared towards general-purpose agentic systems.
|
|
56
11
|
|
|
57
|
-
|
|
58
|
-
npm install -g @anthropic-ai/claude-code
|
|
59
|
-
```
|
|
12
|
+
## ✨ Key Features
|
|
60
13
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
14
|
+
- **🚀 Decoupled from Claude Code**: No more dependency on Claude Code
|
|
15
|
+
- **⚡ Single Process Architecture**: All agents run in one Ruby process using [RubyLLM](https://github.com/parruda/ruby_llm) - no more managing multiple processes
|
|
16
|
+
- **🎯 More Efficient**: Direct method calls instead of MCP inter-process communication
|
|
17
|
+
- **🔧 Richer Features**: Node workflows, hooks system, scratchpad/memory tools, and more
|
|
18
|
+
- **🎮 Better Control**: Fine-grained permissions, cost tracking, structured logging
|
|
19
|
+
- **💻 Interactive REPL**: Built with TTY toolkit for a nice command-line experience
|
|
20
|
+
- **🌐 Multiple LLM Providers**: Supports all LLM providers supported by RubyLLM (Claude, OpenAI, Gemini, etc.)
|
|
21
|
+
- **🧠 SwarmMemory**: Persistent agent knowledge storage with semantic search and FAISS indexing
|
|
22
|
+
- **🔌 Plugin System**: Extensible architecture for custom integrations
|
|
66
23
|
|
|
67
|
-
|
|
24
|
+
---
|
|
68
25
|
|
|
69
|
-
|
|
70
|
-
gem 'claude_swarm', "~> 1.0"
|
|
71
|
-
```
|
|
26
|
+
## 🚀 Quick Start
|
|
72
27
|
|
|
73
|
-
|
|
28
|
+
### Installation
|
|
74
29
|
|
|
75
30
|
```bash
|
|
76
|
-
|
|
31
|
+
gem install swarm_cli # Includes swarm_sdk
|
|
32
|
+
swarm --help # Explore the modern CLI
|
|
77
33
|
```
|
|
78
34
|
|
|
79
|
-
|
|
35
|
+
### Your First Swarm
|
|
80
36
|
|
|
81
|
-
|
|
82
|
-
- Claude CLI installed and configured
|
|
83
|
-
- Any MCP servers you plan to use (optional)
|
|
84
|
-
|
|
85
|
-
## Usage
|
|
86
|
-
|
|
87
|
-
### Quick Start
|
|
88
|
-
|
|
89
|
-
1. Run `claude-swarm init` to create a basic template, or use `claude-swarm generate` for an interactive configuration experience with Claude's help. You can also manually create a `claude-swarm.yml` file in your project:
|
|
37
|
+
Create a simple swarm configuration file `my_swarm.yml`:
|
|
90
38
|
|
|
91
39
|
```yaml
|
|
92
|
-
version:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
directory: ./frontend
|
|
106
|
-
model: opus
|
|
107
|
-
allowed_tools: # Tools aren't required if you run it with `--vibe`
|
|
108
|
-
- Edit
|
|
109
|
-
- Write
|
|
110
|
-
- Bash
|
|
111
|
-
backend:
|
|
112
|
-
description: "Backend developer managing APIs and data layer"
|
|
113
|
-
directory: ./backend
|
|
114
|
-
model: opus
|
|
115
|
-
allowed_tools:
|
|
116
|
-
- Edit
|
|
117
|
-
- Write
|
|
118
|
-
- Bash
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
2. Start the swarm:
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
claude-swarm
|
|
125
|
-
```
|
|
126
|
-
or if you are feeling the vibes...
|
|
127
|
-
```bash
|
|
128
|
-
claude-swarm --vibe # That will allow ALL tools for all instances! Be Careful!
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
This will:
|
|
132
|
-
- Launch the main instance (lead) with connections to other instances
|
|
133
|
-
- The lead instance can communicate with the other instances via MCP
|
|
134
|
-
- All session files are stored in `~/.claude-swarm/sessions/{project}/{timestamp}/` (customizable via `CLAUDE_SWARM_HOME`)
|
|
135
|
-
|
|
136
|
-
#### Multi-Level Swarm Example
|
|
137
|
-
|
|
138
|
-
Here's a more complex example showing specialized teams working on different parts of a project:
|
|
139
|
-
|
|
140
|
-
```yaml
|
|
141
|
-
version: 1
|
|
142
|
-
swarm:
|
|
143
|
-
name: "Multi-Service Development Team"
|
|
144
|
-
main: architect
|
|
145
|
-
instances:
|
|
146
|
-
architect:
|
|
147
|
-
description: "System architect coordinating between service teams"
|
|
148
|
-
directory: .
|
|
149
|
-
model: opus
|
|
150
|
-
connections: [frontend_lead, backend_lead, mobile_lead, devops]
|
|
151
|
-
prompt: "You are the system architect coordinating between different service teams"
|
|
152
|
-
allowed_tools: [Read, Edit, WebSearch]
|
|
153
|
-
|
|
154
|
-
frontend_lead:
|
|
155
|
-
description: "Frontend team lead overseeing React development"
|
|
156
|
-
directory: ./web-frontend
|
|
157
|
-
model: opus
|
|
158
|
-
connections: [react_dev, css_expert]
|
|
159
|
-
prompt: "You lead the web frontend team working with React"
|
|
160
|
-
allowed_tools: [Read, Edit, Bash]
|
|
161
|
-
|
|
162
|
-
react_dev:
|
|
163
|
-
description: "React developer specializing in components and state management"
|
|
164
|
-
directory: ./web-frontend/src
|
|
165
|
-
model: opus
|
|
166
|
-
prompt: "You specialize in React components and state management"
|
|
167
|
-
allowed_tools: [Edit, Write, Bash]
|
|
168
|
-
|
|
169
|
-
css_expert:
|
|
170
|
-
description: "CSS specialist handling styling and responsive design"
|
|
171
|
-
directory: ./web-frontend/styles
|
|
172
|
-
model: opus
|
|
173
|
-
prompt: "You handle all CSS and styling concerns"
|
|
174
|
-
allowed_tools: [Edit, Write, Read]
|
|
175
|
-
|
|
176
|
-
backend_lead:
|
|
177
|
-
description: "Backend team lead managing API development"
|
|
178
|
-
directory: ./api-server
|
|
179
|
-
model: opus
|
|
180
|
-
connections: [api_dev, database_expert]
|
|
181
|
-
prompt: "You lead the API backend team"
|
|
182
|
-
allowed_tools: [Read, Edit, Bash]
|
|
183
|
-
|
|
184
|
-
api_dev:
|
|
185
|
-
description: "API developer building REST endpoints"
|
|
186
|
-
directory: ./api-server/src
|
|
187
|
-
model: opus
|
|
188
|
-
prompt: "You develop REST API endpoints"
|
|
189
|
-
allowed_tools: [Edit, Write, Bash]
|
|
190
|
-
|
|
191
|
-
database_expert:
|
|
192
|
-
description: "Database specialist managing schemas and migrations"
|
|
193
|
-
directory: ./api-server/db
|
|
194
|
-
model: opus
|
|
195
|
-
prompt: "You handle database schema and migrations"
|
|
196
|
-
allowed_tools: [Edit, Write, Bash]
|
|
197
|
-
|
|
198
|
-
mobile_lead:
|
|
199
|
-
description: "Mobile team lead coordinating cross-platform development"
|
|
200
|
-
directory: ./mobile-app
|
|
201
|
-
model: opus
|
|
202
|
-
connections: [ios_dev, android_dev]
|
|
203
|
-
prompt: "You coordinate mobile development across platforms"
|
|
204
|
-
allowed_tools: [Read, Edit]
|
|
205
|
-
|
|
206
|
-
ios_dev:
|
|
207
|
-
description: "iOS developer building native Apple applications"
|
|
208
|
-
directory: ./mobile-app/ios
|
|
209
|
-
model: opus
|
|
210
|
-
prompt: "You develop the iOS application"
|
|
211
|
-
allowed_tools: [Edit, Write, Bash]
|
|
212
|
-
|
|
213
|
-
android_dev:
|
|
214
|
-
description: "Android developer creating native Android apps"
|
|
215
|
-
directory: ./mobile-app/android
|
|
216
|
-
model: opus
|
|
217
|
-
prompt: "You develop the Android application"
|
|
218
|
-
allowed_tools: [Edit, Write, Bash]
|
|
219
|
-
|
|
220
|
-
devops:
|
|
221
|
-
description: "DevOps engineer managing CI/CD and infrastructure"
|
|
222
|
-
directory: ./infrastructure
|
|
223
|
-
model: opus
|
|
224
|
-
prompt: "You handle CI/CD and infrastructure"
|
|
225
|
-
allowed_tools: [Read, Edit, Bash]
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
In this setup:
|
|
229
|
-
- The architect (main instance) can delegate tasks to team leads
|
|
230
|
-
- Each team lead can work with their specialized developers
|
|
231
|
-
- Each instance is independent - connections create separate MCP server instances
|
|
232
|
-
- Teams work in isolated directories with role-appropriate tools
|
|
233
|
-
- Connected instances are accessible via MCP tools like `mcp__frontend_lead__task`, `mcp__backend_lead__task`, etc.
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
### Configuration Format
|
|
40
|
+
version: 2
|
|
41
|
+
agents:
|
|
42
|
+
lead:
|
|
43
|
+
model: claude-3-5-sonnet-20241022
|
|
44
|
+
role: "Lead developer coordinating development efforts"
|
|
45
|
+
tools:
|
|
46
|
+
- Read
|
|
47
|
+
- Write
|
|
48
|
+
- Edit
|
|
49
|
+
- Bash
|
|
50
|
+
delegates_to:
|
|
51
|
+
- frontend
|
|
52
|
+
- backend
|
|
237
53
|
|
|
238
|
-
|
|
54
|
+
frontend:
|
|
55
|
+
model: claude-3-5-sonnet-20241022
|
|
56
|
+
role: "Frontend specialist handling UI and user experience"
|
|
57
|
+
tools: [Read, Write, Edit]
|
|
239
58
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
main: instance_key # Which instance to launch as the main interface
|
|
245
|
-
before: # Optional: commands to run before launching the swarm
|
|
246
|
-
- "echo 'Setting up environment...'"
|
|
247
|
-
- "npm install"
|
|
248
|
-
- "docker-compose up -d"
|
|
249
|
-
after: # Optional: commands to run after exiting the swarm
|
|
250
|
-
- "echo 'Cleaning up environment...'"
|
|
251
|
-
- "docker-compose down"
|
|
252
|
-
instances:
|
|
253
|
-
# Instance definitions...
|
|
59
|
+
backend:
|
|
60
|
+
model: claude-3-5-sonnet-20241022
|
|
61
|
+
role: "Backend developer managing APIs and data layer"
|
|
62
|
+
tools: [Read, Write, Edit, Bash]
|
|
254
63
|
```
|
|
255
64
|
|
|
256
|
-
|
|
65
|
+
Run it:
|
|
257
66
|
|
|
258
|
-
|
|
67
|
+
```bash
|
|
68
|
+
# Interactive REPL mode
|
|
69
|
+
swarm run my_swarm.yml
|
|
259
70
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
swarm:
|
|
263
|
-
name: "Development Team"
|
|
264
|
-
main: lead
|
|
265
|
-
instances:
|
|
266
|
-
lead:
|
|
267
|
-
description: "Lead developer"
|
|
268
|
-
prompt: &shared_prompt "You are an expert developer following best practices"
|
|
269
|
-
allowed_tools: &standard_tools
|
|
270
|
-
- Read
|
|
271
|
-
- Edit
|
|
272
|
-
- Bash
|
|
273
|
-
- WebSearch
|
|
274
|
-
mcps: &common_mcps
|
|
275
|
-
- name: github
|
|
276
|
-
type: stdio
|
|
277
|
-
command: gh
|
|
278
|
-
args: ["mcp"]
|
|
279
|
-
|
|
280
|
-
frontend:
|
|
281
|
-
description: "Frontend developer"
|
|
282
|
-
prompt: *shared_prompt # Reuses the same prompt
|
|
283
|
-
allowed_tools: *standard_tools # Reuses the same tool list
|
|
284
|
-
mcps: *common_mcps # Reuses the same MCP servers
|
|
285
|
-
directory: ./frontend
|
|
286
|
-
|
|
287
|
-
backend:
|
|
288
|
-
description: "Backend developer"
|
|
289
|
-
prompt: *shared_prompt # Reuses the same prompt
|
|
290
|
-
allowed_tools: *standard_tools # Reuses the same tool list
|
|
291
|
-
mcps: *common_mcps # Reuses the same MCP servers
|
|
292
|
-
directory: ./backend
|
|
71
|
+
# Or with a specific prompt
|
|
72
|
+
swarm run my_swarm.yml -p "Build a simple TODO app with React and Node.js"
|
|
293
73
|
```
|
|
294
74
|
|
|
295
|
-
|
|
296
|
-
- `&shared_prompt` defines an anchor for the prompt string
|
|
297
|
-
- `&standard_tools` defines an anchor for the tool array
|
|
298
|
-
- `&common_mcps` defines an anchor for the MCP configuration
|
|
299
|
-
- `*shared_prompt`, `*standard_tools`, and `*common_mcps` reference those anchors
|
|
75
|
+
---
|
|
300
76
|
|
|
301
|
-
|
|
77
|
+
## 📚 Documentation
|
|
302
78
|
|
|
303
|
-
|
|
79
|
+
**Complete documentation is available in the [docs/v2](docs/v2/README.md) directory.**
|
|
304
80
|
|
|
305
|
-
|
|
81
|
+
### Getting Started
|
|
306
82
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
swarm:
|
|
310
|
-
name: "${APP_NAME} Development Team"
|
|
311
|
-
main: lead
|
|
312
|
-
instances:
|
|
313
|
-
lead:
|
|
314
|
-
description: "Lead developer for ${APP_NAME}"
|
|
315
|
-
directory: "${PROJECT_ROOT}"
|
|
316
|
-
model: "${CLAUDE_MODEL}"
|
|
317
|
-
prompt: "You are developing ${APP_NAME} version ${APP_VERSION}"
|
|
318
|
-
allowed_tools: ["${TOOL_1}", "${TOOL_2}", "Bash"]
|
|
319
|
-
mcps:
|
|
320
|
-
- name: github
|
|
321
|
-
type: stdio
|
|
322
|
-
command: "${MCP_GITHUB_PATH}"
|
|
323
|
-
env:
|
|
324
|
-
GITHUB_TOKEN: "${GITHUB_TOKEN}"
|
|
325
|
-
```
|
|
83
|
+
- **[Getting Started with SwarmSDK](docs/v2/guides/getting-started.md)** ⭐
|
|
84
|
+
Learn the basics: installation, core concepts, your first swarm (YAML & Ruby DSL)
|
|
326
85
|
|
|
327
|
-
|
|
328
|
-
-
|
|
329
|
-
- Multiple variables can be used in the same string
|
|
330
|
-
- Partial string interpolation is supported (e.g., `"prefix-${VAR}-suffix"`)
|
|
331
|
-
- If a referenced environment variable is not set, Claude Swarm will exit with a clear error message
|
|
332
|
-
- Non-matching patterns like `$VAR` or `{VAR}` are preserved as-is
|
|
86
|
+
- **[Getting Started with SwarmCLI](docs/v2/guides/quick-start-cli.md)** ⭐
|
|
87
|
+
Command-line interface: interactive REPL and automation modes
|
|
333
88
|
|
|
334
|
-
|
|
89
|
+
### Comprehensive Tutorial
|
|
335
90
|
|
|
336
|
-
|
|
91
|
+
- **[SwarmSDK Complete Tutorial](docs/v2/guides/complete-tutorial.md)**
|
|
92
|
+
In-depth guide covering every feature:
|
|
93
|
+
- Part 1: Fundamentals (agents, models, tools)
|
|
94
|
+
- Part 2: Tools & Permissions (all 11 tools, path/command permissions)
|
|
95
|
+
- Part 3: Agent Collaboration (delegation patterns)
|
|
96
|
+
- Part 4: Hooks System (all 12 events, 6 actions)
|
|
97
|
+
- Part 5: Node Workflows (multi-stage pipelines, transformers)
|
|
98
|
+
- Part 6: Advanced Configuration (MCP, providers, context management)
|
|
99
|
+
- Part 7: Production Features (logging, cost tracking, error handling)
|
|
100
|
+
- Part 8: Best Practices (architecture, testing, optimization)
|
|
337
101
|
|
|
338
|
-
|
|
339
|
-
version: 1
|
|
340
|
-
swarm:
|
|
341
|
-
name: "Dev Team"
|
|
342
|
-
main: lead
|
|
343
|
-
instances:
|
|
344
|
-
lead:
|
|
345
|
-
description: "Lead developer"
|
|
346
|
-
directory: "${PROJECT_DIR:=.}"
|
|
347
|
-
model: "${CLAUDE_MODEL:=sonnet}"
|
|
348
|
-
mcps:
|
|
349
|
-
- name: api-server
|
|
350
|
-
type: sse
|
|
351
|
-
url: "${API_URL:=http://localhost:8080}"
|
|
352
|
-
worktree: "${BRANCH_NAME:=feature-branch}"
|
|
353
|
-
```
|
|
102
|
+
### Reference Documentation
|
|
354
103
|
|
|
355
|
-
-
|
|
356
|
-
-
|
|
357
|
-
-
|
|
358
|
-
-
|
|
104
|
+
- **[Architecture Flow Diagram](docs/v2/reference/architecture-flow.md)** - Complete system architecture
|
|
105
|
+
- **[Execution Flow Diagram](docs/v2/reference/execution-flow.md)** - Runtime execution journey (21 detailed steps)
|
|
106
|
+
- **[CLI Reference](docs/v2/reference/cli.md)** - Complete command-line reference
|
|
107
|
+
- **[Ruby DSL Reference](docs/v2/reference/ruby-dsl.md)** - Complete programmatic API
|
|
108
|
+
- **[YAML Configuration Reference](docs/v2/reference/yaml.md)** - Complete YAML structure
|
|
359
109
|
|
|
360
|
-
|
|
110
|
+
### Integration Guides
|
|
361
111
|
|
|
362
|
-
|
|
112
|
+
- **[SwarmMemory Guide](docs/v2/guides/swarm-memory.md)** - Persistent agent knowledge with semantic search
|
|
113
|
+
- **[Plugin System Guide](docs/v2/guides/plugins.md)** - Build extensions for SwarmSDK
|
|
114
|
+
- **[Memory Adapter Development](docs/v2/guides/memory-adapters.md)** - Custom storage backends
|
|
115
|
+
- **[Rails Integration Guide](docs/v2/guides/rails-integration.md)** - Integrate with Ruby on Rails
|
|
363
116
|
|
|
364
|
-
|
|
117
|
+
---
|
|
365
118
|
|
|
366
|
-
|
|
119
|
+
## 💡 Core Concepts
|
|
367
120
|
|
|
368
|
-
|
|
369
|
-
- **model**: Claude model to use (opus, sonnet)
|
|
370
|
-
- **connections**: Array of other instances this one can communicate with
|
|
371
|
-
- **allowed_tools**: Array of tools this instance can use (backward compatible with `tools`)
|
|
372
|
-
- **disallowed_tools**: Array of tools to explicitly deny (takes precedence over allowed_tools)
|
|
373
|
-
- **mcps**: Array of additional MCP servers to connect
|
|
374
|
-
- **prompt**: Custom system prompt to append to the instance
|
|
375
|
-
- **vibe**: Enable vibe mode (--dangerously-skip-permissions) for this instance (default: false)
|
|
376
|
-
- **worktree**: Configure Git worktree usage for this instance (true/false/string)
|
|
377
|
-
- **provider**: AI provider to use - "claude" (default) or "openai"
|
|
378
|
-
- **hooks**: Configure Claude Code hooks for this instance (see Hooks Configuration section below)
|
|
121
|
+
### SwarmSDK
|
|
379
122
|
|
|
380
|
-
|
|
123
|
+
A Ruby framework for orchestrating multiple AI agents that work together as a team. Each agent has:
|
|
381
124
|
|
|
382
|
-
|
|
125
|
+
- **Role**: Specialized expertise (backend developer, code reviewer, etc.)
|
|
126
|
+
- **Tools**: Capabilities (Read files, Write files, Run bash commands, etc.)
|
|
127
|
+
- **Delegation**: Ability to delegate subtasks to other agents
|
|
128
|
+
- **Hooks**: Custom logic that runs at key points in execution
|
|
383
129
|
|
|
384
|
-
|
|
385
|
-
- **api_version**: API version to use - "chat_completion" (default) or "responses"
|
|
386
|
-
- **openai_token_env**: Environment variable name for OpenAI API key (default: "OPENAI_API_KEY")
|
|
387
|
-
- **base_url**: Custom base URL for OpenAI API (optional)
|
|
388
|
-
- **reasoning_effort**: Reasoning effort for O-series models only - "low", "medium", or "high"
|
|
130
|
+
### SwarmCLI
|
|
389
131
|
|
|
390
|
-
|
|
391
|
-
- O-series models (o1, o1-preview, o1-mini, o3, etc.) use deterministic reasoning and do not support the `temperature` parameter
|
|
392
|
-
- The `reasoning_effort` parameter is only supported by O-series models
|
|
393
|
-
- GPT models support `temperature` but not `reasoning_effort`
|
|
394
|
-
- OpenAI instances default to and ONLY operate as `vibe: true` and use MCP for tool access
|
|
395
|
-
- By default it comes with Claude Code tools, connected with MCP to `claude mcp serve`
|
|
396
|
-
- **Using the responses API requires ruby-openai >= 8.0** - the gem will validate this requirement at runtime
|
|
132
|
+
A command-line interface for running SwarmSDK swarms with two modes:
|
|
397
133
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
description: "Specialized agent focused on specific tasks"
|
|
401
|
-
directory: ~/project/path
|
|
402
|
-
model: opus
|
|
403
|
-
connections: [other_instance1, other_instance2]
|
|
404
|
-
prompt: "You are a specialized agent focused on..."
|
|
405
|
-
vibe: false # Set to true to skip all permission checks for this instance
|
|
406
|
-
allowed_tools:
|
|
407
|
-
- Read
|
|
408
|
-
- Edit
|
|
409
|
-
- Write
|
|
410
|
-
- Bash
|
|
411
|
-
- WebFetch
|
|
412
|
-
- WebSearch
|
|
413
|
-
disallowed_tools: # Optional: explicitly deny specific tools
|
|
414
|
-
- "Write(*.log)"
|
|
415
|
-
- "Bash(rm:*)"
|
|
416
|
-
mcps:
|
|
417
|
-
- name: server_name
|
|
418
|
-
type: stdio
|
|
419
|
-
command: command_to_run
|
|
420
|
-
args: ["arg1", "arg2"]
|
|
421
|
-
env:
|
|
422
|
-
VAR1: value1
|
|
423
|
-
|
|
424
|
-
# OpenAI instance examples
|
|
425
|
-
|
|
426
|
-
# GPT model with temperature
|
|
427
|
-
gpt_instance:
|
|
428
|
-
description: "OpenAI GPT-powered creative assistant"
|
|
429
|
-
provider: openai
|
|
430
|
-
model: gpt-4o
|
|
431
|
-
temperature: 0.7 # Supported for GPT models
|
|
432
|
-
api_version: chat_completion
|
|
433
|
-
openai_token_env: OPENAI_API_KEY
|
|
434
|
-
prompt: "You are a creative assistant specializing in content generation"
|
|
435
|
-
|
|
436
|
-
# O-series reasoning model with reasoning_effort
|
|
437
|
-
reasoning_instance:
|
|
438
|
-
description: "OpenAI O-series reasoning assistant"
|
|
439
|
-
provider: openai
|
|
440
|
-
model: o1-mini
|
|
441
|
-
reasoning_effort: medium # Only for O-series models
|
|
442
|
-
api_version: responses # Can use either API version
|
|
443
|
-
prompt: "You are a reasoning assistant for complex problem solving"
|
|
444
|
-
```
|
|
134
|
+
- **Interactive (REPL)**: Conversational interface for exploration and iteration
|
|
135
|
+
- **Non-Interactive**: One-shot execution perfect for automation and scripting
|
|
445
136
|
|
|
446
|
-
###
|
|
137
|
+
### SwarmMemory
|
|
447
138
|
|
|
448
|
-
|
|
449
|
-
```yaml
|
|
450
|
-
mcps:
|
|
451
|
-
- name: my_tool
|
|
452
|
-
type: stdio
|
|
453
|
-
command: /path/to/executable
|
|
454
|
-
args: ["--flag", "value"]
|
|
455
|
-
env:
|
|
456
|
-
API_KEY: "secret"
|
|
457
|
-
```
|
|
139
|
+
A persistent memory system for agents with semantic search capabilities:
|
|
458
140
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
url: "https://api.example.com/mcp"
|
|
465
|
-
headers: # Optional: custom headers for authentication
|
|
466
|
-
Authorization: "Bearer ${API_TOKEN}"
|
|
467
|
-
X-Custom-Header: "value"
|
|
468
|
-
```
|
|
141
|
+
- **Storage**: Hierarchical knowledge organization (concept, fact, skill, experience)
|
|
142
|
+
- **Semantic Search**: FAISS-based vector similarity with local ONNX embeddings
|
|
143
|
+
- **Memory Tools**: 9 tools for writing, reading, editing, and searching knowledge
|
|
144
|
+
- **LoadSkill**: Dynamic tool swapping based on semantic skill discovery
|
|
145
|
+
- **Plugin Architecture**: Integrates seamlessly via SwarmSDK plugin system
|
|
469
146
|
|
|
470
|
-
|
|
471
|
-
```yaml
|
|
472
|
-
mcps:
|
|
473
|
-
- name: http_service
|
|
474
|
-
type: http
|
|
475
|
-
url: "https://api.example.com/mcp-endpoint"
|
|
476
|
-
headers: # Optional: custom headers for authentication
|
|
477
|
-
Authorization: "Bearer ${API_TOKEN}"
|
|
478
|
-
X-API-Key: "${API_KEY}"
|
|
479
|
-
```
|
|
147
|
+
### Configuration Formats
|
|
480
148
|
|
|
481
|
-
|
|
149
|
+
- **YAML**: Declarative, easy to read, great for shell-based hooks
|
|
150
|
+
- **Ruby DSL**: Programmatic, dynamic, full Ruby power, IDE support
|
|
482
151
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
#### Supported Hook Events
|
|
486
|
-
|
|
487
|
-
- **PreToolUse**: Run before a tool is executed
|
|
488
|
-
- **PostToolUse**: Run after a tool completes
|
|
489
|
-
- **UserPromptSubmit**: Run when a user prompt is submitted
|
|
490
|
-
- **Stop**: Run when the Claude instance stops
|
|
491
|
-
- **SessionStart**: Run when a session starts
|
|
492
|
-
- **And more...** (see Claude Code hooks documentation)
|
|
152
|
+
---
|
|
493
153
|
|
|
494
|
-
|
|
154
|
+
## 🎯 Example: Code Review Team
|
|
495
155
|
|
|
496
156
|
```yaml
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
157
|
+
version: 2
|
|
158
|
+
agents:
|
|
159
|
+
lead_reviewer:
|
|
160
|
+
model: claude-3-5-sonnet-20241022
|
|
161
|
+
role: "Lead code reviewer ensuring quality and best practices"
|
|
162
|
+
tools: [Read, Write]
|
|
163
|
+
delegates_to: [security_expert, performance_analyst]
|
|
502
164
|
hooks:
|
|
503
|
-
|
|
504
|
-
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
hooks:
|
|
512
|
-
- type: "command"
|
|
513
|
-
command: "echo 'Bash executed by ${INSTANCE_NAME}' >> ${LOG_DIR}/commands.log"
|
|
514
|
-
UserPromptSubmit:
|
|
515
|
-
- hooks:
|
|
516
|
-
- type: "command"
|
|
517
|
-
command: "${HOOKS_DIR:=$CLAUDE_PROJECT_DIR/.claude/hooks}/add-context.py"
|
|
518
|
-
frontend:
|
|
519
|
-
description: "Frontend developer"
|
|
520
|
-
directory: ./frontend
|
|
165
|
+
on_user_message:
|
|
166
|
+
- run: "git diff main..HEAD > /tmp/changes.diff"
|
|
167
|
+
append_output_to_context: true
|
|
168
|
+
|
|
169
|
+
security_expert:
|
|
170
|
+
model: claude-3-5-sonnet-20241022
|
|
171
|
+
role: "Security specialist checking for vulnerabilities"
|
|
172
|
+
tools: [Read]
|
|
521
173
|
hooks:
|
|
522
|
-
|
|
523
|
-
-
|
|
524
|
-
|
|
525
|
-
- type: "command"
|
|
526
|
-
command: "npm run lint"
|
|
527
|
-
timeout: 5
|
|
528
|
-
```
|
|
529
|
-
|
|
530
|
-
#### How It Works
|
|
531
|
-
|
|
532
|
-
1. Define hooks in your instance configuration using the exact format expected by Claude Code
|
|
533
|
-
2. Claude Swarm generates a `settings.json` file for each instance with hooks
|
|
534
|
-
3. The settings file is passed to Claude Code SDK via the `--settings` parameter
|
|
535
|
-
4. Each instance runs with its own hooks configuration
|
|
536
|
-
|
|
537
|
-
#### Environment Variables in Hooks
|
|
174
|
+
on_user_message:
|
|
175
|
+
- run: "semgrep --config=auto --json"
|
|
176
|
+
append_output_to_context: true
|
|
538
177
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
### Tools
|
|
545
|
-
|
|
546
|
-
Specify which tools each instance can use:
|
|
547
|
-
|
|
548
|
-
```yaml
|
|
549
|
-
allowed_tools:
|
|
550
|
-
- Bash # Command execution
|
|
551
|
-
- Edit # File editing
|
|
552
|
-
- Write # File creation
|
|
553
|
-
- Read # File reading
|
|
554
|
-
- WebFetch # Fetch web content
|
|
555
|
-
- WebSearch # Search the web
|
|
556
|
-
|
|
557
|
-
# Note: Pattern-based tool restrictions have been deprecated.
|
|
558
|
-
# Use allowed_tools and disallowed_tools with tool names only.
|
|
178
|
+
performance_analyst:
|
|
179
|
+
model: claude-3-5-sonnet-20241022
|
|
180
|
+
role: "Performance analyst identifying bottlenecks"
|
|
181
|
+
tools: [Read, Bash]
|
|
559
182
|
```
|
|
560
183
|
|
|
561
|
-
|
|
184
|
+
Run the code review:
|
|
562
185
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
```yaml
|
|
566
|
-
allowed_tools:
|
|
567
|
-
- Read # File reading
|
|
568
|
-
- Edit # File editing
|
|
569
|
-
- Write # File creation
|
|
570
|
-
- Bash # Command execution
|
|
571
|
-
- WebFetch # Fetch web content
|
|
572
|
-
- WebSearch # Search the web
|
|
186
|
+
```bash
|
|
187
|
+
swarm run code_review.yml -p "Review the recent changes in the authentication module"
|
|
573
188
|
```
|
|
574
189
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
#### Full Stack Development Team
|
|
190
|
+
---
|
|
578
191
|
|
|
579
|
-
|
|
580
|
-
version: 1
|
|
581
|
-
swarm:
|
|
582
|
-
name: "Full Stack Team"
|
|
583
|
-
main: architect
|
|
584
|
-
instances:
|
|
585
|
-
architect:
|
|
586
|
-
description: "Lead architect responsible for system design and code quality"
|
|
587
|
-
directory: .
|
|
588
|
-
model: opus
|
|
589
|
-
connections: [frontend, backend, devops]
|
|
590
|
-
prompt: "You are the lead architect responsible for system design and code quality"
|
|
591
|
-
allowed_tools:
|
|
592
|
-
- Read
|
|
593
|
-
- Edit
|
|
594
|
-
- WebSearch
|
|
595
|
-
|
|
596
|
-
frontend:
|
|
597
|
-
description: "Frontend developer specializing in React and TypeScript"
|
|
598
|
-
directory: ./frontend
|
|
599
|
-
model: opus
|
|
600
|
-
connections: [architect]
|
|
601
|
-
prompt: "You specialize in React, TypeScript, and modern frontend development"
|
|
602
|
-
allowed_tools:
|
|
603
|
-
- Edit
|
|
604
|
-
- Write
|
|
605
|
-
- Bash
|
|
606
|
-
|
|
607
|
-
backend:
|
|
608
|
-
description: "Backend developer building APIs and services"
|
|
609
|
-
directory: ./backend
|
|
610
|
-
model: opus
|
|
611
|
-
connections: [database]
|
|
612
|
-
allowed_tools:
|
|
613
|
-
- Edit
|
|
614
|
-
- Write
|
|
615
|
-
- Bash
|
|
616
|
-
|
|
617
|
-
database:
|
|
618
|
-
description: "Database administrator managing data persistence"
|
|
619
|
-
directory: ./db
|
|
620
|
-
model: sonnet
|
|
621
|
-
allowed_tools:
|
|
622
|
-
- Read
|
|
623
|
-
- Bash
|
|
624
|
-
|
|
625
|
-
devops:
|
|
626
|
-
description: "DevOps engineer handling deployment and infrastructure"
|
|
627
|
-
directory: .
|
|
628
|
-
model: opus
|
|
629
|
-
connections: [architect]
|
|
630
|
-
allowed_tools:
|
|
631
|
-
- Read
|
|
632
|
-
- Edit
|
|
633
|
-
- Bash
|
|
634
|
-
```
|
|
192
|
+
## 🧠 SwarmMemory Example
|
|
635
193
|
|
|
636
|
-
|
|
194
|
+
Enable persistent memory for your agents:
|
|
637
195
|
|
|
638
|
-
```
|
|
639
|
-
|
|
640
|
-
swarm:
|
|
641
|
-
name: "Research Team"
|
|
642
|
-
main: lead_researcher
|
|
643
|
-
instances:
|
|
644
|
-
lead_researcher:
|
|
645
|
-
description: "Lead researcher coordinating analysis and documentation"
|
|
646
|
-
directory: ~/research
|
|
647
|
-
model: opus
|
|
648
|
-
connections: [data_analyst, writer]
|
|
649
|
-
allowed_tools:
|
|
650
|
-
- Read
|
|
651
|
-
- WebSearch
|
|
652
|
-
- WebFetch
|
|
653
|
-
mcps:
|
|
654
|
-
- name: arxiv
|
|
655
|
-
type: sse
|
|
656
|
-
url: "https://arxiv-mcp.example.com"
|
|
657
|
-
|
|
658
|
-
data_analyst:
|
|
659
|
-
description: "Data analyst processing research data and statistics"
|
|
660
|
-
directory: ~/research/data
|
|
661
|
-
model: opus
|
|
662
|
-
allowed_tools:
|
|
663
|
-
- Read
|
|
664
|
-
- Write
|
|
665
|
-
- Bash
|
|
666
|
-
mcps:
|
|
667
|
-
- name: jupyter
|
|
668
|
-
type: stdio
|
|
669
|
-
command: jupyter-mcp
|
|
670
|
-
args: ["--notebook-dir", "."]
|
|
671
|
-
|
|
672
|
-
writer:
|
|
673
|
-
description: "Technical writer preparing research documentation"
|
|
674
|
-
directory: ~/research/papers
|
|
675
|
-
model: opus
|
|
676
|
-
allowed_tools:
|
|
677
|
-
- Edit
|
|
678
|
-
- Write
|
|
679
|
-
- Read
|
|
196
|
+
```bash
|
|
197
|
+
gem install swarm_memory
|
|
680
198
|
```
|
|
681
199
|
|
|
682
|
-
#### Multi-Directory Support
|
|
683
|
-
|
|
684
|
-
Instances can have access to multiple directories using an array (uses `claude --add-dir`):
|
|
685
|
-
|
|
686
200
|
```yaml
|
|
687
|
-
version:
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
allowed_tools: [Read, Edit, Write, Bash]
|
|
697
|
-
prompt: "You work across frontend, backend, and shared code modules"
|
|
698
|
-
|
|
699
|
-
documentation_writer:
|
|
700
|
-
description: "Documentation specialist with access to code and docs"
|
|
701
|
-
directory: ["./docs", "./src", "./examples"] # Multiple directories as array
|
|
702
|
-
model: sonnet
|
|
703
|
-
allowed_tools: [Read, Write, Edit]
|
|
704
|
-
prompt: "You maintain documentation based on code and examples"
|
|
201
|
+
version: 2
|
|
202
|
+
agents:
|
|
203
|
+
research_assistant:
|
|
204
|
+
model: claude-3-5-sonnet-20241022
|
|
205
|
+
role: "Research assistant with long-term memory"
|
|
206
|
+
tools: [Read, Write]
|
|
207
|
+
plugins:
|
|
208
|
+
- swarm_memory:
|
|
209
|
+
storage_dir: ./memories
|
|
705
210
|
```
|
|
706
211
|
|
|
707
|
-
|
|
708
|
-
- The first directory in the array is the primary working directory
|
|
709
|
-
- Additional directories are accessible via the `--add-dir` flag in Claude
|
|
710
|
-
- All directories must exist or the configuration will fail validation
|
|
711
|
-
|
|
712
|
-
#### Mixed AI Provider Team
|
|
713
|
-
|
|
714
|
-
Combine Claude and OpenAI instances in a single swarm:
|
|
212
|
+
The agent now has access to memory tools:
|
|
715
213
|
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
instances:
|
|
722
|
-
lead_developer:
|
|
723
|
-
description: "Claude lead developer coordinating the team"
|
|
724
|
-
directory: .
|
|
725
|
-
model: opus
|
|
726
|
-
connections: [creative_assistant, reasoning_expert, backend_dev]
|
|
727
|
-
prompt: "You are the lead developer coordinating a mixed AI team"
|
|
728
|
-
allowed_tools: [Read, Edit, Bash, Write]
|
|
729
|
-
|
|
730
|
-
creative_assistant:
|
|
731
|
-
description: "OpenAI-powered assistant for creative and UI/UX tasks"
|
|
732
|
-
provider: openai
|
|
733
|
-
model: gpt-4o
|
|
734
|
-
temperature: 0.7 # Supported for GPT models
|
|
735
|
-
directory: ./frontend
|
|
736
|
-
prompt: "You are a creative frontend developer specializing in UI/UX design"
|
|
737
|
-
# OpenAI instances default to vibe: true
|
|
738
|
-
|
|
739
|
-
reasoning_expert:
|
|
740
|
-
description: "OpenAI O-series model for complex problem solving"
|
|
741
|
-
provider: openai
|
|
742
|
-
model: o1-mini
|
|
743
|
-
reasoning_effort: high # For O-series models only
|
|
744
|
-
directory: ./architecture
|
|
745
|
-
prompt: "You solve complex architectural and algorithmic problems"
|
|
746
|
-
|
|
747
|
-
backend_dev:
|
|
748
|
-
description: "Claude backend developer for system architecture"
|
|
749
|
-
directory: ./backend
|
|
750
|
-
model: sonnet
|
|
751
|
-
prompt: "You specialize in backend development and system architecture"
|
|
752
|
-
allowed_tools: [Read, Edit, Write, Bash]
|
|
753
|
-
```
|
|
214
|
+
- `MemoryWrite` - Store new knowledge
|
|
215
|
+
- `MemoryRead` - Retrieve specific memories
|
|
216
|
+
- `MemorySearch` - Semantic search across all knowledge
|
|
217
|
+
- `LoadSkill` - Dynamically load specialized skills
|
|
218
|
+
- And more...
|
|
754
219
|
|
|
755
|
-
|
|
220
|
+
[Learn more about SwarmMemory →](docs/v2/guides/swarm-memory.md)
|
|
756
221
|
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
You can specify commands to run before launching and after exiting the swarm using the `before` and `after` fields:
|
|
222
|
+
---
|
|
760
223
|
|
|
761
|
-
|
|
762
|
-
version: 1
|
|
763
|
-
swarm:
|
|
764
|
-
name: "Development Environment"
|
|
765
|
-
main: lead_developer
|
|
766
|
-
before:
|
|
767
|
-
- "echo '🚀 Setting up development environment...'"
|
|
768
|
-
- "npm install"
|
|
769
|
-
- "docker-compose up -d"
|
|
770
|
-
- "bundle install"
|
|
771
|
-
after:
|
|
772
|
-
- "echo '🛑 Cleaning up development environment...'"
|
|
773
|
-
- "docker-compose down"
|
|
774
|
-
- "rm -rf temp/*"
|
|
775
|
-
instances:
|
|
776
|
-
lead_developer:
|
|
777
|
-
description: "Lead developer coordinating the team"
|
|
778
|
-
directory: .
|
|
779
|
-
model: opus
|
|
780
|
-
allowed_tools: [Read, Edit, Write, Bash]
|
|
781
|
-
```
|
|
224
|
+
## 🔧 Ruby DSL Example
|
|
782
225
|
|
|
783
|
-
|
|
784
|
-
- Are executed in sequence before launching any Claude instances
|
|
785
|
-
- Execute in the main instance's directory (including worktree if enabled)
|
|
786
|
-
- Must all succeed for the swarm to launch (exit code 0)
|
|
787
|
-
- Are only executed on initial swarm launch, not when restoring sessions
|
|
788
|
-
- Have their output logged to the session log file
|
|
789
|
-
- Will abort the swarm launch if any command fails
|
|
226
|
+
For programmatic control, use the Ruby DSL:
|
|
790
227
|
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
- Execute in the main instance's directory (including worktree if enabled)
|
|
794
|
-
- Run even when the swarm is interrupted by signals (Ctrl+C)
|
|
795
|
-
- Failures do not prevent cleanup from proceeding
|
|
796
|
-
- Are only executed on initial swarm runs, not when restoring sessions
|
|
797
|
-
- Have their output logged to the session log file
|
|
228
|
+
```ruby
|
|
229
|
+
require 'swarm_sdk'
|
|
798
230
|
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
231
|
+
swarm = SwarmSDK.build do
|
|
232
|
+
agent :lead do
|
|
233
|
+
model "claude-3-5-sonnet-20241022"
|
|
234
|
+
role "Lead developer"
|
|
235
|
+
tools :Read, :Write, :Edit, :Bash
|
|
236
|
+
delegates_to :frontend, :backend
|
|
237
|
+
end
|
|
805
238
|
|
|
239
|
+
agent :frontend do
|
|
240
|
+
model "claude-3-5-sonnet-20241022"
|
|
241
|
+
role "Frontend specialist"
|
|
242
|
+
tools :Read, :Write, :Edit
|
|
243
|
+
end
|
|
806
244
|
|
|
807
|
-
|
|
245
|
+
agent :backend do
|
|
246
|
+
model "claude-3-5-sonnet-20241022"
|
|
247
|
+
role "Backend specialist"
|
|
248
|
+
tools :Read, :Write, :Edit, :Bash
|
|
249
|
+
end
|
|
250
|
+
end
|
|
808
251
|
|
|
809
|
-
|
|
252
|
+
# Execute with the lead agent
|
|
253
|
+
result = swarm.execute(
|
|
254
|
+
agent: :lead,
|
|
255
|
+
prompt: "Build a simple TODO app"
|
|
256
|
+
)
|
|
810
257
|
|
|
811
|
-
|
|
812
|
-
version: 1
|
|
813
|
-
swarm:
|
|
814
|
-
name: "Mixed Mode Team"
|
|
815
|
-
main: lead
|
|
816
|
-
instances:
|
|
817
|
-
lead:
|
|
818
|
-
description: "Lead with full permissions"
|
|
819
|
-
directory: .
|
|
820
|
-
model: opus
|
|
821
|
-
vibe: true # This instance runs with --dangerously-skip-permissions
|
|
822
|
-
connections: [restricted_worker, trusted_worker]
|
|
823
|
-
|
|
824
|
-
restricted_worker:
|
|
825
|
-
description: "Worker with restricted permissions"
|
|
826
|
-
directory: ./sensitive
|
|
827
|
-
model: sonnet
|
|
828
|
-
allowed_tools: [Read, Bash] # Allow read and bash commands
|
|
829
|
-
|
|
830
|
-
trusted_worker:
|
|
831
|
-
description: "Trusted worker with more permissions"
|
|
832
|
-
directory: ./workspace
|
|
833
|
-
model: sonnet
|
|
834
|
-
vibe: true # This instance also skips permissions
|
|
835
|
-
allowed_tools: [] # Tools list ignored when vibe: true
|
|
258
|
+
puts result.message
|
|
836
259
|
```
|
|
837
260
|
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
Claude Swarm supports running instances in Git worktrees, allowing isolated work without affecting your main repository state. Worktrees are created in an external directory (`~/.claude-swarm/worktrees/`) to ensure proper isolation from the main repository and avoid conflicts with bundler and other tools.
|
|
261
|
+
[Learn more about the Ruby DSL →](docs/v2/reference/ruby-dsl.md)
|
|
841
262
|
|
|
842
|
-
|
|
843
|
-
```
|
|
844
|
-
~/.claude-swarm/worktrees/
|
|
845
|
-
└── [session_id]/
|
|
846
|
-
├── my-repo-[hash]/
|
|
847
|
-
│ └── feature-x/ (worktree for feature-x branch)
|
|
848
|
-
└── other-repo-[hash]/
|
|
849
|
-
└── feature-x/ (worktree for feature-x branch)
|
|
850
|
-
```
|
|
263
|
+
---
|
|
851
264
|
|
|
852
|
-
|
|
853
|
-
```bash
|
|
854
|
-
# Create worktrees with auto-generated name (worktree-SESSION_ID)
|
|
855
|
-
claude-swarm --worktree
|
|
265
|
+
## 🛠️ Advanced Features
|
|
856
266
|
|
|
857
|
-
|
|
858
|
-
claude-swarm --worktree feature-branch
|
|
267
|
+
### Node Workflows
|
|
859
268
|
|
|
860
|
-
|
|
861
|
-
claude-swarm -w
|
|
862
|
-
```
|
|
269
|
+
Build multi-stage processing pipelines:
|
|
863
270
|
|
|
864
|
-
**Per-Instance Configuration:**
|
|
865
271
|
```yaml
|
|
866
|
-
version:
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
lead:
|
|
872
|
-
description: "Lead developer"
|
|
873
|
-
directory: .
|
|
874
|
-
worktree: true # Use shared worktree name from CLI (or auto-generate)
|
|
875
|
-
|
|
876
|
-
testing:
|
|
877
|
-
description: "Test developer"
|
|
878
|
-
directory: ./tests
|
|
879
|
-
worktree: false # Don't use worktree for this instance
|
|
880
|
-
|
|
881
|
-
feature_dev:
|
|
882
|
-
description: "Feature developer"
|
|
883
|
-
directory: ./features
|
|
884
|
-
worktree: "feature-x" # Use specific worktree name
|
|
885
|
-
```
|
|
886
|
-
|
|
887
|
-
**Worktree Behavior:**
|
|
888
|
-
- `worktree: true` - Uses the shared worktree name (from CLI or auto-generated)
|
|
889
|
-
- `worktree: false` - Disables worktree for this instance
|
|
890
|
-
- `worktree: "name"` - Uses a specific worktree name
|
|
891
|
-
- Omitted - Follows CLI behavior (use worktree if `--worktree` is specified)
|
|
892
|
-
|
|
893
|
-
**Notes:**
|
|
894
|
-
- Auto-generated worktree names use the session ID (e.g., `worktree-20241206_143022`)
|
|
895
|
-
- This makes it easy to correlate worktrees with their Claude Swarm sessions
|
|
896
|
-
- Worktrees are stored externally in `~/.claude-swarm/worktrees/[session_id]/`
|
|
897
|
-
- All worktrees are automatically cleaned up when the swarm exits
|
|
898
|
-
- Worktrees with the same name across different repositories share that name
|
|
899
|
-
- Non-Git directories are unaffected by worktree settings
|
|
900
|
-
- Existing worktrees with the same name are reused
|
|
901
|
-
- The `claude-swarm clean` command also removes orphaned worktrees
|
|
902
|
-
|
|
903
|
-
### Command Line Options
|
|
904
|
-
|
|
905
|
-
```bash
|
|
906
|
-
# Use default claude-swarm.yml in current directory
|
|
907
|
-
claude-swarm
|
|
908
|
-
|
|
909
|
-
# Specify a different configuration file
|
|
910
|
-
claude-swarm start my-swarm.yml
|
|
911
|
-
claude-swarm start team-config.yml
|
|
912
|
-
|
|
913
|
-
# Run with --dangerously-skip-permissions for all instances
|
|
914
|
-
claude-swarm --vibe
|
|
915
|
-
|
|
916
|
-
# Run in non-interactive mode with a prompt
|
|
917
|
-
claude-swarm -p "Implement the new user authentication feature"
|
|
918
|
-
claude-swarm --prompt "Fix the bug in the payment module"
|
|
919
|
-
|
|
920
|
-
# Run in interactive mode with an initial prompt
|
|
921
|
-
claude-swarm -i "Review the codebase and suggest improvements"
|
|
922
|
-
claude-swarm --interactive "Help me debug this test failure"
|
|
923
|
-
|
|
924
|
-
# Use a custom session ID instead of auto-generated UUID
|
|
925
|
-
claude-swarm --session-id my-custom-session-123
|
|
272
|
+
version: 2
|
|
273
|
+
nodes:
|
|
274
|
+
analyzer:
|
|
275
|
+
agent: code_analyst
|
|
276
|
+
prompt: "Analyze the codebase and identify issues"
|
|
926
277
|
|
|
927
|
-
|
|
928
|
-
|
|
278
|
+
fixer:
|
|
279
|
+
agent: code_fixer
|
|
280
|
+
prompt: "Fix the issues identified: {{ analyzer.output }}"
|
|
281
|
+
depends_on: [analyzer]
|
|
929
282
|
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
283
|
+
reviewer:
|
|
284
|
+
agent: code_reviewer
|
|
285
|
+
prompt: "Review the fixes: {{ fixer.output }}"
|
|
286
|
+
depends_on: [fixer]
|
|
934
287
|
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
claude-
|
|
288
|
+
agents:
|
|
289
|
+
code_analyst:
|
|
290
|
+
model: claude-3-5-sonnet-20241022
|
|
291
|
+
role: "Code analyst"
|
|
292
|
+
tools: [Read]
|
|
938
293
|
|
|
939
|
-
|
|
940
|
-
claude-
|
|
941
|
-
|
|
942
|
-
|
|
294
|
+
code_fixer:
|
|
295
|
+
model: claude-3-5-sonnet-20241022
|
|
296
|
+
role: "Code fixer"
|
|
297
|
+
tools: [Read, Write, Edit]
|
|
943
298
|
|
|
944
|
-
|
|
945
|
-
claude-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
# Tool permissions are now handled through allowed_tools and disallowed_tools in your configuration.
|
|
949
|
-
|
|
950
|
-
# Internal command for MCP server (used by connected instances)
|
|
951
|
-
claude-swarm mcp-serve INSTANCE_NAME --config CONFIG_FILE --session-timestamp TIMESTAMP
|
|
299
|
+
code_reviewer:
|
|
300
|
+
model: claude-3-5-sonnet-20241022
|
|
301
|
+
role: "Code reviewer"
|
|
302
|
+
tools: [Read]
|
|
952
303
|
```
|
|
953
304
|
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
Claude Swarm provides commands to monitor and inspect running sessions:
|
|
957
|
-
|
|
958
|
-
```bash
|
|
959
|
-
# List running swarm sessions with costs and uptime
|
|
960
|
-
claude-swarm ps
|
|
961
|
-
|
|
962
|
-
# Show detailed information about a session including instance hierarchy
|
|
963
|
-
claude-swarm show 20250617_235233
|
|
305
|
+
[Learn more about Node Workflows →](docs/v2/guides/complete-tutorial.md#part-5-node-workflows)
|
|
964
306
|
|
|
965
|
-
|
|
966
|
-
claude-swarm watch 20250617_235233
|
|
307
|
+
### Hooks System
|
|
967
308
|
|
|
968
|
-
|
|
969
|
-
claude-swarm watch 20250617_235233 -n 50
|
|
309
|
+
Run custom logic at key execution points:
|
|
970
310
|
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
311
|
+
```yaml
|
|
312
|
+
version: 2
|
|
313
|
+
agents:
|
|
314
|
+
developer:
|
|
315
|
+
model: claude-3-5-sonnet-20241022
|
|
316
|
+
role: "Full-stack developer"
|
|
317
|
+
tools: [Read, Write, Edit, Bash]
|
|
318
|
+
hooks:
|
|
319
|
+
# Run before each tool execution
|
|
320
|
+
on_pre_tool:
|
|
321
|
+
- run: "echo 'About to use {{ tool_name }}'"
|
|
974
322
|
|
|
975
|
-
#
|
|
976
|
-
|
|
323
|
+
# Run after successful tool execution
|
|
324
|
+
on_post_tool:
|
|
325
|
+
- run: "echo 'Tool {{ tool_name }} completed successfully'"
|
|
977
326
|
|
|
978
|
-
#
|
|
979
|
-
|
|
980
|
-
|
|
327
|
+
# Append git diff to every user message
|
|
328
|
+
on_user_message:
|
|
329
|
+
- run: "git diff"
|
|
330
|
+
append_output_to_context: true
|
|
981
331
|
|
|
982
|
-
|
|
332
|
+
# Run tests before the agent responds
|
|
333
|
+
on_pre_response:
|
|
334
|
+
- run: "npm test"
|
|
335
|
+
stop_on_error: true
|
|
983
336
|
```
|
|
984
|
-
⚠️ Total cost does not include the cost of the main instance
|
|
985
337
|
|
|
986
|
-
|
|
987
|
-
-------------------------------------------------------------------------------
|
|
988
|
-
20250617_235233 Feature Development $0.3847 15m .
|
|
989
|
-
20250617_143022 Bug Investigation $1.2156 1h .
|
|
990
|
-
20250617_091547 Multi-Module Dev $0.8932 30m ./frontend, ./backend, ./shared
|
|
991
|
-
```
|
|
338
|
+
[Learn more about Hooks →](docs/v2/guides/complete-tutorial.md#part-4-hooks-system)
|
|
992
339
|
|
|
993
|
-
|
|
340
|
+
---
|
|
994
341
|
|
|
995
|
-
|
|
996
|
-
```
|
|
997
|
-
Session: 20250617_235233
|
|
998
|
-
Swarm: Feature Development
|
|
999
|
-
Total Cost: $0.3847 (excluding main instance)
|
|
1000
|
-
Start Directory: /Users/paulo/project
|
|
1001
|
-
|
|
1002
|
-
Instance Hierarchy:
|
|
1003
|
-
--------------------------------------------------
|
|
1004
|
-
├─ orchestrator [main] (orchestrator_e85036fc)
|
|
1005
|
-
Cost: n/a (interactive) | Calls: 0
|
|
1006
|
-
└─ test_archaeologist (test_archaeologist_c504ca5f)
|
|
1007
|
-
Cost: $0.1925 | Calls: 1
|
|
1008
|
-
└─ pr_analyst (pr_analyst_bfbefe56)
|
|
1009
|
-
Cost: $0.1922 | Calls: 1
|
|
1010
|
-
|
|
1011
|
-
Note: Main instance (orchestrator) cost is not tracked in interactive mode.
|
|
1012
|
-
View costs directly in the Claude interface.
|
|
1013
|
-
```
|
|
342
|
+
## 📊 Cost Tracking & Logging
|
|
1014
343
|
|
|
1015
|
-
|
|
344
|
+
SwarmSDK provides built-in cost tracking and structured logging:
|
|
1016
345
|
|
|
1017
|
-
|
|
346
|
+
```ruby
|
|
347
|
+
require 'swarm_sdk'
|
|
1018
348
|
|
|
1019
|
-
|
|
1020
|
-
All session files are organized in `~/.claude-swarm/sessions/{project}/{timestamp}/`:
|
|
1021
|
-
- `config.yml`: Copy of the original swarm configuration
|
|
1022
|
-
- `state/`: Directory containing individual instance states
|
|
1023
|
-
- `{instance_id}.json`: Claude session ID and status for each instance (e.g., `lead_abc123.json`)
|
|
1024
|
-
- `{instance_name}.mcp.json`: MCP configuration files
|
|
1025
|
-
- `session.log`: Human-readable request/response tracking
|
|
1026
|
-
- `session.log.json`: All events in JSONL format (one JSON per line)
|
|
1027
|
-
# Note: permissions.log is no longer generated as the permission MCP server has been deprecated
|
|
349
|
+
swarm = SwarmSDK.load('my_swarm.yml')
|
|
1028
350
|
|
|
1029
|
-
|
|
1030
|
-
|
|
351
|
+
result = swarm.execute(
|
|
352
|
+
agent: :lead,
|
|
353
|
+
prompt: "Build a simple TODO app",
|
|
354
|
+
logger: Logger.new($stdout)
|
|
355
|
+
)
|
|
1031
356
|
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
# List more sessions
|
|
1037
|
-
claude-swarm list-sessions --limit 20
|
|
357
|
+
# Access cost information
|
|
358
|
+
puts "Total cost: $#{result.cost}"
|
|
359
|
+
puts "Tokens used: #{result.tokens}"
|
|
1038
360
|
```
|
|
1039
361
|
|
|
1040
|
-
|
|
1041
|
-
- Session ID (timestamp)
|
|
1042
|
-
- Creation time
|
|
1043
|
-
- Main instance name
|
|
1044
|
-
- Number of instances
|
|
1045
|
-
- Configuration file used
|
|
1046
|
-
- Full session path
|
|
1047
|
-
|
|
1048
|
-
#### Resuming Sessions
|
|
1049
|
-
Resume a previous session with all instances restored to their Claude session states:
|
|
362
|
+
[Learn more about Production Features →](docs/v2/guides/complete-tutorial.md#part-7-production-features)
|
|
1050
363
|
|
|
1051
|
-
|
|
1052
|
-
# Restore using the session's UUID
|
|
1053
|
-
claude-swarm restore 550e8400-e29b-41d4-a716-446655440000
|
|
1054
|
-
```
|
|
364
|
+
---
|
|
1055
365
|
|
|
1056
|
-
|
|
1057
|
-
1. Load the session manifest and instance states
|
|
1058
|
-
2. Restore the original swarm configuration
|
|
1059
|
-
3. Resume the main instance with its Claude session ID
|
|
1060
|
-
4. Restore all connected instances with their session IDs
|
|
1061
|
-
5. Maintain the same working directories and tool permissions
|
|
366
|
+
## 🔗 Integration Examples
|
|
1062
367
|
|
|
1063
|
-
|
|
1064
|
-
- Each instance's Claude session ID is automatically captured and persisted
|
|
1065
|
-
- Instance states are stored in separate files named by instance ID to prevent concurrency issues
|
|
1066
|
-
- MCP configurations are regenerated with the saved session IDs
|
|
1067
|
-
- The main instance uses Claude's `--resume` flag (limited effectiveness)
|
|
1068
|
-
- Connected instances receive their session IDs via `--claude-session-id`
|
|
368
|
+
### Rails Integration
|
|
1069
369
|
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
370
|
+
```ruby
|
|
371
|
+
# app/jobs/code_review_job.rb
|
|
372
|
+
class CodeReviewJob < ApplicationJob
|
|
373
|
+
def perform(pull_request_id)
|
|
374
|
+
swarm = SwarmSDK.load(Rails.root.join('config', 'code_review_swarm.yml'))
|
|
1075
375
|
|
|
1076
|
-
|
|
376
|
+
result = swarm.execute(
|
|
377
|
+
agent: :lead_reviewer,
|
|
378
|
+
prompt: "Review PR ##{pull_request_id}"
|
|
379
|
+
)
|
|
1077
380
|
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
- Disallowed tools take precedence over allowed tools for fine-grained control
|
|
1086
|
-
- Per-instance `vibe: true` skips all permission checks for that specific instance
|
|
1087
|
-
4. **Session Persistence**: Claude Swarm automatically tracks session state:
|
|
1088
|
-
- Generates a shared session path for all instances
|
|
1089
|
-
- Each instance's Claude session ID is captured and saved
|
|
1090
|
-
- Instance states are stored using instance IDs as filenames to avoid conflicts
|
|
1091
|
-
- Sessions can be fully restored with all instances reconnected
|
|
1092
|
-
5. **Main Instance Launch**: The main instance is launched with its MCP configuration, giving it access to all connected instances
|
|
1093
|
-
6. **Inter-Instance Communication**: Connected instances expose themselves as MCP servers with these tools:
|
|
1094
|
-
- **task**: Execute tasks using Claude Code with configurable tools and return results. The tool description includes the instance name and description (e.g., "Execute a task using Agent frontend_dev. Frontend developer specializing in React and TypeScript")
|
|
1095
|
-
- **session_info**: Get current Claude session information including ID and working directory
|
|
1096
|
-
- **reset_session**: Reset the Claude session for a fresh start
|
|
381
|
+
PullRequest.find(pull_request_id).update(
|
|
382
|
+
review_status: 'completed',
|
|
383
|
+
review_comments: result.message
|
|
384
|
+
)
|
|
385
|
+
end
|
|
386
|
+
end
|
|
387
|
+
```
|
|
1097
388
|
|
|
1098
|
-
|
|
389
|
+
[Learn more about Rails Integration →](docs/v2/guides/rails-integration.md)
|
|
1099
390
|
|
|
1100
|
-
###
|
|
391
|
+
### Custom Plugins
|
|
1101
392
|
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
393
|
+
```ruby
|
|
394
|
+
# lib/my_plugin.rb
|
|
395
|
+
class MyPlugin < SwarmSDK::Plugin
|
|
396
|
+
def on_agent_init(agent)
|
|
397
|
+
# Add custom behavior when agent initializes
|
|
398
|
+
end
|
|
1105
399
|
|
|
1106
|
-
|
|
1107
|
-
|
|
400
|
+
def on_user_message(message, agent)
|
|
401
|
+
# Process user messages
|
|
402
|
+
end
|
|
1108
403
|
|
|
1109
|
-
|
|
1110
|
-
|
|
404
|
+
def provide_tools
|
|
405
|
+
[MyCustomTool.new]
|
|
406
|
+
end
|
|
407
|
+
end
|
|
1111
408
|
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
409
|
+
# Register the plugin
|
|
410
|
+
SwarmSDK.register_plugin(:my_plugin, MyPlugin)
|
|
411
|
+
```
|
|
1115
412
|
|
|
1116
|
-
|
|
413
|
+
[Learn more about Plugins →](docs/v2/guides/plugins.md)
|
|
1117
414
|
|
|
1118
|
-
|
|
1119
|
-
- Session directory location (`~/.claude-swarm/sessions/{project}/{timestamp}/`)
|
|
1120
|
-
- Main instance details (model, directory, tools, connections)
|
|
1121
|
-
- The exact command being run
|
|
415
|
+
---
|
|
1122
416
|
|
|
1123
|
-
|
|
417
|
+
## 🆚 SwarmSDK (v2) vs Claude Swarm (v1)
|
|
418
|
+
|
|
419
|
+
| Feature | SwarmSDK v2 | Claude Swarm v1 |
|
|
420
|
+
| ---------------------- | ---------------------- | ------------------------------- |
|
|
421
|
+
| **Architecture** | Single Ruby process | Multiple Claude Code processes |
|
|
422
|
+
| **Dependencies** | RubyLLM (Ruby-only) | Requires Claude CLI (Node.js) |
|
|
423
|
+
| **Performance** | Direct method calls | MCP inter-process communication |
|
|
424
|
+
| **LLM Support** | All RubyLLM providers | Claude + OpenAI (via MCP) |
|
|
425
|
+
| **Memory System** | Built-in SwarmMemory | Not available |
|
|
426
|
+
| **Plugin System** | Yes | No |
|
|
427
|
+
| **Node Workflows** | Yes | No |
|
|
428
|
+
| **Hooks** | 12 events, 6 actions | Claude Code hooks only |
|
|
429
|
+
| **Context Management** | Fine-grained control | Limited |
|
|
430
|
+
| **Cost Tracking** | Built-in | Limited to MCP calls |
|
|
431
|
+
| **Interactive REPL** | TTY-based with history | Not available |
|
|
432
|
+
| **Ruby DSL** | Full support | Not available |
|
|
1124
433
|
|
|
1125
|
-
|
|
1126
|
-
- `session.log`: Human-readable logs with request/response tracking
|
|
1127
|
-
- `session.log.json`: All events in JSONL format (one JSON object per line)
|
|
1128
|
-
- `{instance}.mcp.json`: MCP configuration for each instance
|
|
1129
|
-
- All files for a session are kept together for easy review
|
|
434
|
+
---
|
|
1130
435
|
|
|
436
|
+
## 📖 Looking for v1 Documentation?
|
|
1131
437
|
|
|
1132
|
-
|
|
438
|
+
**Claude Swarm (v1)** continues to be maintained and is still a great choice if you prefer the multi-process architecture with Claude Code instances.
|
|
1133
439
|
|
|
1134
|
-
Claude Swarm
|
|
440
|
+
[View Claude Swarm v1 Documentation →](docs/v1/README.md)
|
|
1135
441
|
|
|
1136
|
-
|
|
1137
|
-
- **ClaudeSwarm::Configuration** (`configuration.rb`): YAML parser and validator with path expansion
|
|
1138
|
-
- **ClaudeSwarm::McpGenerator** (`mcp_generator.rb`): Generates MCP JSON configs for each instance
|
|
1139
|
-
- **ClaudeSwarm::Orchestrator** (`orchestrator.rb`): Launches the main Claude instance with shared session management
|
|
1140
|
-
- **ClaudeSwarm::ClaudeCodeExecutor** (`claude_code_executor.rb`): Executor for Claude Code with session persistence
|
|
1141
|
-
- **ClaudeSwarm::ClaudeMcpServer** (`claude_mcp_server.rb`): FastMCP-based server providing task execution, session info, and reset capabilities
|
|
442
|
+
To install Claude Swarm v1:
|
|
1142
443
|
|
|
1143
|
-
|
|
444
|
+
```bash
|
|
445
|
+
gem install claude_swarm
|
|
446
|
+
```
|
|
1144
447
|
|
|
1145
|
-
|
|
448
|
+
---
|
|
1146
449
|
|
|
1147
|
-
|
|
450
|
+
## 🤝 Contributing
|
|
1148
451
|
|
|
1149
|
-
|
|
452
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/parruda/claude-swarm.
|
|
1150
453
|
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
bundle exec rake install # Install gem locally
|
|
1157
|
-
bundle exec rake release # Release gem to RubyGems.org
|
|
1158
|
-
rake # Default: runs both tests and RuboCop
|
|
1159
|
-
```
|
|
454
|
+
1. Fork the repository
|
|
455
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
456
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
457
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
458
|
+
5. Create a new Pull Request
|
|
1160
459
|
|
|
1161
|
-
|
|
460
|
+
---
|
|
1162
461
|
|
|
1163
|
-
|
|
462
|
+
## 📄 License
|
|
1164
463
|
|
|
1165
|
-
|
|
1166
|
-
2. Update `CHANGELOG.md` with the new version's changes
|
|
1167
|
-
3. Commit the changes: `git commit -am "Bump version to x.y.z"`
|
|
1168
|
-
4. Create a version tag: `git tag -a vx.y.z -m "Release version x.y.z"`
|
|
1169
|
-
5. Push the changes and tag: `git push && git push --tags`
|
|
1170
|
-
6. The GitHub workflow will create a draft release - review and publish it
|
|
1171
|
-
7. Once published, the gem will be automatically built and pushed to RubyGems
|
|
464
|
+
The gems are available as open source under the terms of the [MIT License](LICENSE).
|
|
1172
465
|
|
|
1173
|
-
|
|
466
|
+
---
|
|
1174
467
|
|
|
1175
|
-
##
|
|
468
|
+
## 🔗 Links
|
|
1176
469
|
|
|
1177
|
-
|
|
470
|
+
- **Documentation**: [docs/v2/README.md](docs/v2/README.md)
|
|
471
|
+
- **GitHub Repository**: [parruda/claude-swarm](https://github.com/parruda/claude-swarm)
|
|
472
|
+
- **RubyGems**:
|
|
473
|
+
- [swarm_sdk](https://rubygems.org/gems/swarm_sdk)
|
|
474
|
+
- [swarm_cli](https://rubygems.org/gems/swarm_cli)
|
|
475
|
+
- [swarm_memory](https://rubygems.org/gems/swarm_memory)
|
|
476
|
+
- **Issues & Support**: [GitHub Issues](https://github.com/parruda/claude-swarm/issues)
|
|
1178
477
|
|
|
1179
|
-
|
|
478
|
+
---
|
|
1180
479
|
|
|
1181
|
-
|
|
480
|
+
**Ready to get started?** → [Getting Started with SwarmSDK](docs/v2/guides/getting-started.md) or [Getting Started with SwarmCLI](docs/v2/guides/quick-start-cli.md)
|