mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-24 06:06:02 +09:00
5.5 KiB
5.5 KiB
Claude Flow Swarm Mode Documentation
Overview
The Claude Flow Swarm Mode enables self-orchestrating agent swarms that can work collaboratively on complex tasks. When activated, a master orchestrator spawns specialized agents in separate terminal windows/sessions to work on different aspects of your objective.
How It Works
- Master Orchestrator: The main Claude instance that analyzes your objective and coordinates the swarm
- Specialized Agents: Individual Claude instances spawned in separate terminals for specific tasks
- Shared Memory: Agents communicate through a shared memory namespace for coordination
- Real Terminal Spawning: Each agent runs in its own terminal window/tab for visibility
Current Implementation Status
Working Features
- ✅ Swarm initialization and configuration
- ✅ Dry-run mode to preview configuration
- ✅ Native terminal spawning (single orchestrator)
- ✅ Command-line argument parsing
- ✅ VS Code detection and script generation
In Progress
- 🚧 VS Code terminal API integration (macOS only currently)
- 🚧 Multi-agent spawning in separate terminals
- 🚧 Real-time swarm monitoring
- 🚧 Agent communication through shared memory
Known Limitations
- VS Code terminal spawning requires macOS (AppleScript)
- Linux/Windows users get manual instructions instead
- Agent spawning tools (dispatch_agent) need MCP integration
- Terminal output capture requires VS Code extension
Usage
Basic Usage
claude-flow swarm "Your objective here"
With Options
Due to CLI parsing limitations, flags must come AFTER the objective:
claude-flow swarm "Research cloud architectures" --strategy research --max-agents 5 --monitor
Dry Run
claude-flow swarm "Test objective" --dry-run
VS Code Integration
# Automatically detects VS Code environment
claude-flow swarm "Build a feature" --vscode
# Force VS Code mode
claude-flow swarm "Create API" --vscode
Options
--dry-run: Show configuration without executing--strategy <type>: Strategy type (auto, research, development, analysis)--max-agents <n>: Maximum number of agents (default: 5)--max-depth <n>: Maximum delegation depth (default: 3)--timeout <minutes>: Timeout in minutes (default: 60)--research: Enable research capabilities--parallel: Enable parallel execution--review: Enable peer review mode--coordinator: Spawn dedicated coordinators--memory-namespace <name>: Memory namespace (default: swarm)--vscode: Use VS Code terminal integration--monitor: Enable real-time monitoring--verbose: Verbose output
Terminal Integration
Native Terminal Mode
- Works on macOS, Linux, and Windows
- Spawns new terminal windows using system commands
- Each agent runs in its own terminal window
VS Code Integration
- Automatically detected when running in VS Code terminal
- Spawns new terminal tabs within VS Code
- Better integration with VS Code workspace
Agent Types
- Researcher: Information gathering and analysis
- Developer: Code implementation and testing
- Analyst: Data analysis and insights
- Reviewer: Quality assurance and validation
- Coordinator: Sub-task coordination
Example Scenarios
Research Task
claude-flow swarm --strategy research --research "Research best practices for microservices"
Development Task
claude-flow swarm --strategy development --max-agents 3 "Build a REST API with authentication"
Complex Project
claude-flow swarm --parallel --review --coordinator "Design and implement a real-time chat system"
Monitoring
Use the --monitor flag to enable real-time monitoring of swarm progress:
claude-flow swarm --monitor "Your task"
This displays:
- Active agents and their status
- Task progress
- Runtime statistics
- Agent coordination events
Requirements
- Claude desktop app installed
claudecommand available in PATH- Terminal access (for native mode)
- VS Code (for VS Code integration)
Troubleshooting
Claude CLI Not Found
Make sure Claude desktop app is installed and the claude command is in your PATH:
which claude
Terminal Spawning Issues
- macOS: Requires Terminal app access permissions
- Linux: Requires gnome-terminal or compatible terminal
- Windows: Requires cmd.exe access
- VS Code: Must be running inside VS Code terminal
Agent Communication
Agents communicate through shared memory. If agents aren't coordinating:
- Check memory namespace is consistent
- Verify agents have started successfully
- Monitor agent output in their terminals
Best Practices
- Clear Objectives: Provide specific, well-defined objectives
- Appropriate Strategy: Choose the right strategy for your task
- Resource Limits: Set reasonable agent limits to avoid overwhelming the system
- Monitoring: Use monitoring for long-running tasks
- Timeout: Set appropriate timeouts for your tasks
Architecture
The swarm system consists of:
- CLI Command (
swarm.ts): Handles command parsing and initialization - Swarm Spawner (
swarm-spawn.ts): Manages agent lifecycle and terminal spawning - Terminal Manager: Handles terminal creation and management
- MCP Tools (
swarm-tools.ts): Provides tools for agent coordination - Memory System: Shared state and communication
Future Enhancements
- Web UI for swarm monitoring
- Agent performance metrics
- Automatic agent scaling
- Cloud deployment support
- Integration with CI/CD pipelines