π The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
π Checkpoint: Edit /workspaces/claude-code-flow/src/cli/simple-commands/swarm.js
rUv2eedd5a3595e
diff --git a/.claude/checkpoints/1754224140.json b/.claude/checkpoints/1754224140.jsonnew file mode 100644index 0000000000..554b21c0fa--- /dev/null+++ b/.claude/checkpoints/1754224140.json@@ -0,0 +1 @@+{"branch": "checkpoint/pre-edit-20250803-122900", "file": "/workspaces/claude-code-flow/src/cli/simple-commands/swarm.js", "timestamp": "2025-08-03T12:29:00Z", "type": "pre-edit", "original_branch": "alpha-84b"}diff --git a/.claude/checkpoints/1754224142.json b/.claude/checkpoints/1754224142.jsonnew file mode 100644index 0000000000..873d679992--- /dev/null+++ b/.claude/checkpoints/1754224142.json@@ -0,0 +1 @@+{"tag": "checkpoint-20250803-122902", "file": "/workspaces/claude-code-flow/src/cli/simple-commands/swarm.js", "timestamp": "2025-08-03T12:29:02Z", "type": "post-edit", "branch": "alpha-84b", "diff_summary": " .claude-flow/metrics/performance.json | 2 +- .claude-flow/metrics/system-metrics.json | 48 +++++++++++++++++++++++++++++ .claude-flow/metrics/task-metrics.json | 6 ++-- .claude/checkpoints/1754224099.json | 1 + .claude/checkpoints/1754224100.json | 1 + claude-flow-wiki | 0 src/cli/simple-commands/swarm.js | 53 +------------------------------- 7 files changed, 55 insertions(+), 56 deletions(-) "}diff --git a/src/cli/simple-commands/swarm.js b/src/cli/simple-commands/swarm.jsindex 7ca4d5fec3..16a9a75872 100644--- a/src/cli/simple-commands/swarm.js+++ b/src/cli/simple-commands/swarm.js@@ -878,349 +878,6 @@ The swarm should be self-documenting - use memory_store to save all important in// Continue with the default swarm behavior if not using --claude flag-π CLAUDE-FLOW SWARM BATCHTOOL INSTRUCTIONS--β‘ THE GOLDEN RULE:-If you need to do X operations, they should be in 1 message, not X messages.--π― MANDATORY PATTERNS FOR CLAUDE-FLOW SWARMS:--1οΈβ£ **SWARM INITIALIZATION** - Everything in ONE BatchTool:-\`\`\`javascript-[Single Message with Multiple Tools]:- // Spawn ALL agents at once- mcp__claude-flow__agent_spawn {"type": "coordinator", "name": "SwarmLead"}- mcp__claude-flow__agent_spawn {"type": "researcher", "name": "DataAnalyst"}- mcp__claude-flow__agent_spawn {"type": "coder", "name": "BackendDev"}- mcp__claude-flow__agent_spawn {"type": "coder", "name": "FrontendDev"}- mcp__claude-flow__agent_spawn {"type": "tester", "name": "QAEngineer"}-- // Initialize ALL memory keys- mcp__claude-flow__memory_store {"key": "swarm/objective", "value": "${objective}"}- mcp__claude-flow__memory_store {"key": "swarm/config", "value": {"strategy": "${strategy}", "mode": "${mode}"}}-- // Create task hierarchy- mcp__claude-flow__task_create {"name": "${objective}", "type": "parent", "id": "main"}- mcp__claude-flow__task_create {"name": "Research Phase", "parent": "main"}- mcp__claude-flow__task_create {"name": "Design Phase", "parent": "main"}- mcp__claude-flow__task_create {"name": "Implementation", "parent": "main"}-- // Initialize comprehensive todo list- TodoWrite {"todos": [- {"id": "1", "content": "Initialize ${maxAgents} agent swarm", "status": "completed", "priority": "high"},- {"id": "2", "content": "Analyze: ${objective}", "status": "in_progress", "priority": "high"},- {"id": "3", "content": "Design architecture", "status": "pending", "priority": "high"},- {"id": "4", "content": "Implement solution", "status": "pending", "priority": "high"},- {"id": "5", "content": "Test and validate", "status": "pending", "priority": "medium"}- ]}-\`\`\`--2οΈβ£ **TASK COORDINATION** - Batch ALL assignments:-\`\`\`javascript-[Single Message]:- // Assign all tasks- mcp__claude-flow__task_assign {"taskId": "research-1", "agentId": "researcher-1"}- mcp__claude-flow__task_assign {"taskId": "design-1", "agentId": "architect-1"}- mcp__claude-flow__task_assign {"taskId": "code-1", "agentId": "coder-1"}- mcp__claude-flow__task_assign {"taskId": "code-2", "agentId": "coder-2"}-- // Communicate to all agents- mcp__claude-flow__agent_communicate {"to": "all", "message": "Begin phase 1"}-- // Update multiple task statuses- mcp__claude-flow__task_update {"taskId": "research-1", "status": "in_progress"}- mcp__claude-flow__task_update {"taskId": "design-1", "status": "pending"}-\`\`\`--3οΈβ£ **MEMORY COORDINATION** - Store/retrieve in batches:-\`\`\`javascript-[Single Message]:- // Store multiple findings- mcp__claude-flow__memory_store {"key": "research/requirements", "value": {...}}- mcp__claude-flow__memory_store {"key": "research/constraints", "value": {...}}- mcp__claude-flow__memory_store {"key": "architecture/decisions", "value": {...}}-- // Retrieve related data- mcp__claude-flow__memory_retrieve {"key": "research/*"}- mcp__claude-flow__memory_search {"pattern": "architecture"}-\`\`\`--4οΈβ£ **FILE & CODE OPERATIONS** - Parallel execution:-\`\`\`javascript-[Single Message]:- // Read multiple files- Read {"file_path": "/src/index.js"}- Read {"file_path": "/src/config.js"}- Read {"file_path": "/package.json"}-- // Write multiple files- Write {"file_path": "/src/api/auth.js", "content": "..."}- Write {"file_path": "/src/api/users.js", "content": "..."}- Write {"file_path": "/tests/auth.test.js", "content": "..."}-- // Update memory with results- mcp__claude-flow__memory_store {"key": "code/api/auth", "value": "implemented"}- mcp__claude-flow__memory_store {"key": "code/api/users", "value": "implemented"}-\`\`\`--5οΈβ£ **MONITORING & STATUS** - Combined checks:-\`\`\`javascript-[Single Message]:- mcp__claude-flow__swarm_monitor {}- mcp__claude-flow__swarm_status {}- mcp__claude-flow__agent_list {"status": "active"}- mcp__claude-flow__task_status {"includeCompleted": false}- TodoRead {}-\`\`\`--β NEVER DO THIS (Sequential = SLOW):-\`\`\`-Message 1: mcp__claude-flow__agent_spawn-Message 2: mcp__claude-flow__agent_spawn-Message 3: TodoWrite (one todo)-Message 4: Read file-Message 5: mcp__claude-flow__memory_store-\`\`\`--β ALWAYS DO THIS (Batch = FAST):-\`\`\`-Message 1: [All operations in one message]-\`\`\`--π‘ BATCHTOOL BEST PRACTICES:-- Group by operation type (all spawns, all reads, all writes)-- Use TodoWrite with 5-10 todos at once-- Combine file operations when analyzing codebases-- Store multiple memory items per message-- Never send more than one message for related operations--${strategyGuidance}--${modeGuidance}--${agentRecommendations}--π MANDATORY PARALLEL WORKFLOW:--1. **INITIAL SPAWN (Single BatchTool Message):**- - Spawn ALL agents at once- - Create ALL initial todos at once- - Store initial memory state- - Create task hierarchy-- Example:- \`\`\`- [BatchTool]:- mcp__claude-flow__agent_spawn (coordinator)- mcp__claude-flow__agent_spawn (architect)- mcp__claude-flow__agent_spawn (coder-1)- mcp__claude-flow__agent_spawn (coder-2)- mcp__claude-flow__agent_spawn (tester)- mcp__claude-flow__memory_store { key: "init", value: {...} }- mcp__claude-flow__task_create { name: "Main", subtasks: [...] }- TodoWrite { todos: [5-10 todos at once] }- \`\`\`--2. **TASK EXECUTION (Parallel Batches):**- - Assign multiple tasks in one batch- - Update multiple statuses together- - Store multiple results simultaneously--3. **MONITORING (Combined Operations):**- - Check all agent statuses together- - Retrieve multiple memory items- - Update all progress markers--π§ AVAILABLE MCP TOOLS FOR SWARM COORDINATION:--π MONITORING & STATUS:-- mcp__claude-flow__swarm_status - Check current swarm status and agent activity-- mcp__claude-flow__swarm_monitor - Real-time monitoring of swarm execution-- mcp__claude-flow__agent_list - List all active agents and their capabilities-- mcp__claude-flow__task_status - Check task progress and dependencies--π§ MEMORY & KNOWLEDGE:-- mcp__claude-flow__memory_store - Store knowledge in swarm collective memory-- mcp__claude-flow__memory_retrieve - Retrieve shared knowledge from memory-- mcp__claude-flow__memory_search - Search collective memory by pattern-- mcp__claude-flow__memory_sync - Synchronize memory across agents--π€ AGENT MANAGEMENT:-- mcp__claude-flow__agent_spawn - Spawn specialized agents for tasks-- mcp__claude-flow__agent_assign - Assign tasks to specific agents-- mcp__claude-flow__agent_communicate - Send messages between agents-- mcp__claude-flow__agent_coordinate - Coordinate agent activities--π TASK ORCHESTRATION:-- mcp__claude-flow__task_create - Create new tasks with dependencies-- mcp__claude-flow__task_assign - Assign tasks to agents-- mcp__claude-flow__task_update - Update task status and progress-- mcp__claude-flow__task_complete - Mark tasks as complete with results--ποΈ COORDINATION MODES:-1. CENTRALIZED (default): Single coordinator manages all agents- - Use when: Clear hierarchy needed, simple workflows- - Tools: agent_assign, task_create, swarm_monitor--2. DISTRIBUTED: Multiple coordinators share responsibility- - Use when: Large scale tasks, fault tolerance needed- - Tools: agent_coordinate, memory_sync, task_update--3. HIERARCHICAL: Tree structure with team leads- - Use when: Complex projects with sub-teams- - Tools: agent_spawn (with parent), task_create (with subtasks)--4. MESH: Peer-to-peer agent coordination- - Use when: Maximum flexibility, self-organizing teams- - Tools: agent_communicate, memory_store/retrieve--β‘ EXECUTION WORKFLOW - ALWAYS USE BATCHTOOL:-${- enableSparc- ? `-1. SPARC METHODOLOGY WITH PARALLEL EXECUTION:-- S - Specification Phase (Single BatchTool):- \`\`\`- [BatchTool]:- mcp__claude-flow__memory_store { key: "specs/requirements", value: {...} }- mcp__claude-flow__task_create { name: "Requirement 1" }- mcp__claude-flow__task_create { name: "Requirement 2" }- mcp__claude-flow__task_create { name: "Requirement 3" }- mcp__claude-flow__agent_spawn { type: "researcher", name: "SpecAnalyst" }- \`\`\`-- P - Pseudocode Phase (Single BatchTool):- \`\`\`- [BatchTool]:- mcp__claude-flow__memory_store { key: "pseudocode/main", value: {...} }- mcp__claude-flow__task_create { name: "Design API" }- mcp__claude-flow__task_create { name: "Design Data Model" }- mcp__claude-flow__agent_communicate { to: "all", message: "Review design" }- \`\`\`-- A - Architecture Phase (Single BatchTool):- \`\`\`- [BatchTool]:- mcp__claude-flow__agent_spawn { type: "architect", name: "LeadArchitect" }- mcp__claude-flow__memory_store { key: "architecture/decisions", value: {...} }- mcp__claude-flow__task_create { name: "Backend", subtasks: [...] }- mcp__claude-flow__task_create { name: "Frontend", subtasks: [...] }- \`\`\`-- R - Refinement Phase (Single BatchTool):- \`\`\`- [BatchTool]:- mcp__claude-flow__swarm_monitor {}- mcp__claude-flow__task_update { taskId: "1", progress: 50 }- mcp__claude-flow__task_update { taskId: "2", progress: 75 }- mcp__claude-flow__memory_store { key: "learnings/iteration1", value: {...} }- \`\`\`-- C - Completion Phase (Single BatchTool):- \`\`\`- [BatchTool]:- mcp__claude-flow__task_complete { taskId: "1", results: {...} }- mcp__claude-flow__task_complete { taskId: "2", results: {...} }- mcp__claude-flow__memory_retrieve { pattern: "**/*" }- TodoWrite { todos: [{content: "Final review", status: "completed"}] }- \`\`\`-`- : `-1. STANDARD SWARM EXECUTION WITH PARALLEL OPERATIONS:-- Initial Setup (Single BatchTool):- \`\`\`- [BatchTool]:- mcp__claude-flow__task_create { name: "Main", subtasks: [...] }- mcp__claude-flow__agent_spawn { type: "coordinator" }- mcp__claude-flow__agent_spawn { type: "coder" }- mcp__claude-flow__agent_spawn { type: "tester" }- mcp__claude-flow__memory_store { key: "init", value: {...} }- \`\`\`-- Task Assignment (Single BatchTool):- \`\`\`- [BatchTool]:- mcp__claude-flow__task_assign { taskId: "1", agentId: "agent-1" }- mcp__claude-flow__task_assign { taskId: "2", agentId: "agent-2" }- mcp__claude-flow__task_assign { taskId: "3", agentId: "agent-3" }- \`\`\`-- Monitoring & Updates (Single BatchTool):- \`\`\`- [BatchTool]:- mcp__claude-flow__swarm_monitor {}- mcp__claude-flow__agent_communicate { to: "all", message: "Status update" }- mcp__claude-flow__memory_store { key: "progress", value: {...} }- \`\`\`-`-}--π€ AGENT TYPES & THEIR MCP TOOL USAGE:--COORDINATOR:-- Primary tools: swarm_monitor, agent_assign, task_create-- Monitors overall progress and assigns work-- Uses memory_store for decisions and memory_retrieve for context--RESEARCHER:-- Primary tools: memory_search, memory_store-- Gathers information and stores findings-- Uses agent_communicate to share discoveries--CODER:-- Primary tools: task_update, memory_retrieve, memory_store-- Implements solutions and updates progress-- Retrieves specs from memory, stores code artifacts--ANALYST:-- Primary tools: memory_search, swarm_monitor-- Analyzes data and patterns-- Stores insights and recommendations--TESTER:-- Primary tools: task_status, agent_communicate-- Validates implementations-- Reports issues via task_update--π EXAMPLE MCP TOOL USAGE PATTERNS:--1. Starting a swarm:- mcp__claude-flow__agent_spawn {"type": "coordinator", "name": "SwarmLead"}- mcp__claude-flow__memory_store {"key": "objective", "value": "${objective}"}- mcp__claude-flow__task_create {"name": "Main Objective", "type": "parent"}--2. Spawning worker agents:- mcp__claude-flow__agent_spawn {"type": "researcher", "capabilities": ["web-search"]}- mcp__claude-flow__agent_spawn {"type": "coder", "capabilities": ["python", "testing"]}- mcp__claude-flow__task_assign {"taskId": "task-123", "agentId": "agent-456"}--3. Coordinating work:- mcp__claude-flow__agent_communicate {"to": "agent-123", "message": "Begin phase 2"}- mcp__claude-flow__memory_store {"key": "phase1/results", "value": {...}}- mcp__claude-flow__task_update {"taskId": "task-123", "progress": 75}--4. Monitoring progress:- mcp__claude-flow__swarm_monitor {}- mcp__claude-flow__task_status {"includeCompleted": true}- mcp__claude-flow__agent_list {"status": "active"}--πΎ MEMORY PATTERNS:--Use hierarchical keys for organization:-- "specs/requirements" - Store specifications-- "architecture/decisions" - Architecture choices-- "code/modules/[name]" - Code artifacts-- "tests/results/[id]" - Test outcomes-- "docs/api/[endpoint]" - Documentation--π BEGIN SWARM EXECUTION:--Start by spawning a coordinator agent and creating the initial task structure. Use the MCP tools to orchestrate the swarm, coordinate agents, and track progress. Remember to store important decisions and artifacts in collective memory for other agents to access.--The swarm should be self-documenting - use memory_store to save all important information, decisions, and results throughout the execution.`;-// Pass the prompt directly as an argument to claudeconst claudeArgs = [swarmPrompt];