claude-flow 2.7.13 → 2.7.15

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.
@@ -0,0 +1,302 @@
1
+ # Swarm Initialization Guide
2
+ **Date:** 2025-10-25
3
+ **Claude-Flow Version:** 2.7.14
4
+
5
+ ---
6
+
7
+ ## ❌ Common Mistake
8
+
9
+ ```bash
10
+ # THIS DOES NOT EXIST:
11
+ npx claude-flow@alpha hooks swarm-init --topology adaptive --max-agents 6
12
+ # Error: ❌ Unknown hooks command: swarm-init
13
+ ```
14
+
15
+ **Why?** Hooks are for **lifecycle events** (pre-task, post-task, etc.), NOT swarm initialization.
16
+
17
+ ---
18
+
19
+ ## ✅ Correct Methods
20
+
21
+ ### Method 1: MCP Tools (In Claude Code)
22
+
23
+ **For ruv-swarm (WASM-powered):**
24
+ ```javascript
25
+ // Call this from within Claude Code:
26
+ mcp__ruv-swarm__swarm_init({
27
+ topology: "mesh", // mesh, hierarchical, ring, star
28
+ maxAgents: 6,
29
+ strategy: "adaptive" // balanced, specialized, adaptive
30
+ })
31
+ ```
32
+
33
+ **For claude-flow MCP:**
34
+ ```javascript
35
+ // Call this from within Claude Code:
36
+ mcp__claude-flow__swarm_init({
37
+ topology: "hierarchical",
38
+ maxAgents: 8,
39
+ strategy: "balanced"
40
+ })
41
+ ```
42
+
43
+ **Example Result:**
44
+ ```json
45
+ {
46
+ "id": "swarm-1761410358918",
47
+ "message": "Successfully initialized mesh swarm with 6 max agents",
48
+ "topology": "mesh",
49
+ "strategy": "adaptive",
50
+ "maxAgents": 6,
51
+ "features": {
52
+ "cognitive_diversity": true,
53
+ "neural_networks": true,
54
+ "forecasting": false,
55
+ "simd_support": true
56
+ },
57
+ "performance": {
58
+ "initialization_time_ms": 1.28,
59
+ "memory_usage_mb": 48
60
+ }
61
+ }
62
+ ```
63
+
64
+ ---
65
+
66
+ ### Method 2: Claude-Flow CLI (High-Level)
67
+
68
+ **For task-based swarm deployment:**
69
+ ```bash
70
+ # Requires Claude Code CLI
71
+ npx claude-flow@alpha swarm "Build a REST API with authentication" --max-agents 6
72
+
73
+ # With options:
74
+ npx claude-flow@alpha swarm "Analyze codebase" \
75
+ --max-agents 6 \
76
+ --strategy research \
77
+ --mode mesh \
78
+ --read-only
79
+ ```
80
+
81
+ **CLI Options:**
82
+ - `--strategy` - research, development, analysis, testing, optimization
83
+ - `--mode` - centralized, distributed, hierarchical, mesh, hybrid
84
+ - `--max-agents` - Maximum number of agents (default: 5)
85
+ - `--parallel` - Enable parallel execution (2.8-4.4x speedup)
86
+ - `--monitor` - Real-time swarm monitoring
87
+ - `--background` - Run in background
88
+ - `--claude` - Open Claude Code CLI
89
+ - `--executor` - Use built-in executor
90
+ - `--read-only` - Analysis mode (no code changes)
91
+
92
+ ---
93
+
94
+ ### Method 3: Hive Mind System (Recommended for Complex Tasks)
95
+
96
+ **Interactive wizard:**
97
+ ```bash
98
+ npx claude-flow@alpha hive-mind wizard
99
+ ```
100
+
101
+ **Direct spawn:**
102
+ ```bash
103
+ npx claude-flow@alpha hive-mind spawn "Build REST API with auth"
104
+ npx claude-flow@alpha hive-mind spawn "Analyze security" --claude
105
+ ```
106
+
107
+ **Check status:**
108
+ ```bash
109
+ npx claude-flow@alpha hive-mind status
110
+ npx claude-flow@alpha hive-mind metrics
111
+ ```
112
+
113
+ ---
114
+
115
+ ## 🎯 When to Use Each Method
116
+
117
+ ### Use MCP Tools When:
118
+ - ✅ Working inside Claude Code
119
+ - ✅ Need low-level control over swarm topology
120
+ - ✅ Want to integrate with other MCP operations
121
+ - ✅ Building custom coordination workflows
122
+
123
+ ### Use CLI Commands When:
124
+ - ✅ Running from terminal/scripts
125
+ - ✅ Need quick swarm deployment
126
+ - ✅ Want high-level task orchestration
127
+ - ✅ Prefer command-line interface
128
+
129
+ ### Use Hive Mind When:
130
+ - ✅ Complex multi-objective tasks
131
+ - ✅ Need persistent swarm coordination
132
+ - ✅ Want intelligent agent self-organization
133
+ - ✅ Require SQLite-backed memory
134
+
135
+ ---
136
+
137
+ ## 🔧 Hooks System (Lifecycle Events)
138
+
139
+ **Hooks are for lifecycle management, NOT swarm creation:**
140
+
141
+ ### Available Hook Commands:
142
+ ```bash
143
+ # Before task starts
144
+ npx claude-flow@alpha hooks pre-task \
145
+ --description "Build API" \
146
+ --task-id "task-123"
147
+
148
+ # After task completes
149
+ npx claude-flow@alpha hooks post-task \
150
+ --task-id "task-123" \
151
+ --analyze-performance
152
+
153
+ # Before file edit
154
+ npx claude-flow@alpha hooks pre-edit \
155
+ --file "src/api.js" \
156
+ --operation edit
157
+
158
+ # After file edit
159
+ npx claude-flow@alpha hooks post-edit \
160
+ --file "src/api.js" \
161
+ --memory-key "swarm/123/edits/api"
162
+
163
+ # End of session
164
+ npx claude-flow@alpha hooks session-end \
165
+ --export-metrics \
166
+ --generate-summary
167
+ ```
168
+
169
+ ---
170
+
171
+ ## 🌐 Flow-Nexus Cloud Platform
172
+
173
+ **For cloud-based swarm orchestration:**
174
+
175
+ ```javascript
176
+ // 1. Register/Login
177
+ mcp__flow-nexus__user_register({ email, password })
178
+ mcp__flow-nexus__user_login({ email, password })
179
+
180
+ // 2. Initialize cloud swarm
181
+ mcp__flow-nexus__swarm_init({
182
+ topology: "hierarchical",
183
+ maxAgents: 8,
184
+ strategy: "balanced"
185
+ })
186
+
187
+ // 3. Spawn cloud agents
188
+ mcp__flow-nexus__agent_spawn({
189
+ type: "researcher",
190
+ name: "researcher-1",
191
+ capabilities: ["web-search", "data-analysis"]
192
+ })
193
+
194
+ // 4. Orchestrate tasks
195
+ mcp__flow-nexus__task_orchestrate({
196
+ task: "Build microservices architecture",
197
+ strategy: "parallel",
198
+ priority: "high"
199
+ })
200
+ ```
201
+
202
+ ---
203
+
204
+ ## 📊 Comparison Matrix
205
+
206
+ | Method | Speed | Control | Complexity | Best For |
207
+ |--------|-------|---------|------------|----------|
208
+ | **MCP Tools** | Fast (1-2ms) | High | Low | Claude Code integration |
209
+ | **CLI Swarm** | Medium | Medium | Medium | Terminal workflows |
210
+ | **Hive Mind** | Slower | High | High | Complex orchestration |
211
+ | **Flow-Nexus** | Variable | Highest | High | Cloud deployment |
212
+
213
+ ---
214
+
215
+ ## 🚀 Quick Start Examples
216
+
217
+ ### Example 1: Simple Research Swarm
218
+ ```bash
219
+ npx claude-flow@alpha swarm "Research GraphQL best practices" \
220
+ --strategy research \
221
+ --max-agents 3 \
222
+ --read-only
223
+ ```
224
+
225
+ ### Example 2: Development Swarm
226
+ ```bash
227
+ npx claude-flow@alpha swarm "Build authentication service" \
228
+ --strategy development \
229
+ --max-agents 5 \
230
+ --parallel \
231
+ --monitor
232
+ ```
233
+
234
+ ### Example 3: MCP-Based Swarm
235
+ ```javascript
236
+ // In Claude Code:
237
+ mcp__ruv-swarm__swarm_init({
238
+ topology: "mesh",
239
+ maxAgents: 4,
240
+ strategy: "adaptive"
241
+ })
242
+
243
+ mcp__ruv-swarm__agent_spawn({
244
+ type: "coder",
245
+ name: "backend-dev"
246
+ })
247
+
248
+ mcp__ruv-swarm__task_orchestrate({
249
+ task: "Implement user authentication",
250
+ strategy: "sequential",
251
+ priority: "high"
252
+ })
253
+ ```
254
+
255
+ ### Example 4: Hive Mind with Claude Code
256
+ ```bash
257
+ npx claude-flow@alpha hive-mind spawn \
258
+ "Build e-commerce platform" \
259
+ --claude
260
+ ```
261
+
262
+ ---
263
+
264
+ ## 🐞 Troubleshooting
265
+
266
+ ### Issue: "Unknown hooks command: swarm-init"
267
+ **Solution:** Use `npx claude-flow@alpha swarm` or MCP tools instead
268
+
269
+ ### Issue: "Compiled swarm module not found"
270
+ **Solution:** Either:
271
+ 1. Use MCP tools (recommended)
272
+ 2. Install Claude Code CLI
273
+ 3. Use `--executor` flag for built-in execution
274
+
275
+ ### Issue: Swarm initialization fails
276
+ **Check:**
277
+ 1. MCP servers running: `claude mcp list`
278
+ 2. Dependencies installed: `npm install`
279
+ 3. Memory available: Check `.swarm/memory.db`
280
+
281
+ ---
282
+
283
+ ## 📚 Additional Resources
284
+
285
+ **Documentation:**
286
+ - Main README: `/README.md`
287
+ - Tool Validation: `/docs/TOOL_VALIDATION_REPORT.md`
288
+ - Integration Review: `/docs/AGENTIC_FLOW_INTEGRATION_REVIEW.md`
289
+
290
+ **Skills:**
291
+ - Swarm Orchestration: `.claude/skills/swarm-orchestration/SKILL.md`
292
+ - Hive Mind Advanced: `.claude/skills/hive-mind-advanced/SKILL.md`
293
+
294
+ **Official Guides:**
295
+ - GitHub: https://github.com/ruvnet/claude-flow
296
+ - Hive Mind: https://github.com/ruvnet/claude-flow/tree/main/docs/hive-mind
297
+
298
+ ---
299
+
300
+ **Created:** 2025-10-25
301
+ **Updated:** 2025-10-25
302
+ **Author:** Claude Code (Claude Sonnet 4.5)