diff --git a/.claude/checkpoints/1758908507.json b/.claude/checkpoints/1758908507.json new file mode 100644 index 0000000000..9cfbe0850d --- /dev/null +++ b/.claude/checkpoints/1758908507.json @@ -0,0 +1 @@ +{"branch": "checkpoint/pre-edit-20250926-174146", "file": "/workspaces/claude-code-flow/.claude/commands/hive-mind/hive-mind-spawn.md", "timestamp": "2025-09-26T17:41:47Z", "type": "pre-edit", "original_branch": "alpha-125"} diff --git a/.claude/checkpoints/1758908508.json b/.claude/checkpoints/1758908508.json new file mode 100644 index 0000000000..5bca5ca8a9 --- /dev/null +++ b/.claude/checkpoints/1758908508.json @@ -0,0 +1 @@ +{"tag": "checkpoint-20250926-174148", "file": "/workspaces/claude-code-flow/.claude/commands/hive-mind/hive-mind-spawn.md", "timestamp": "2025-09-26T17:41:48Z", "type": "post-edit", "branch": "alpha-125", "diff_summary": " .claude-flow/metrics/performance.json | 2 +- .claude-flow/metrics/system-metrics.json | 48 +++++++++++++++ .claude-flow/metrics/task-metrics.json | 6 +- .claude/checkpoints/task-1758908385.json | 1 + .claude/commands/hive-mind/hive-mind-spawn.md | 88 +++++++++++++++++++++++++-- claude-flow-wiki | 0 6 files changed, 137 insertions(+), 8 deletions(-) "} diff --git a/.claude/commands/agents/agent-spawning.md b/.claude/commands/agents/agent-spawning.md index 38c8581d4c..e47790dee7 100644 --- a/.claude/commands/agents/agent-spawning.md +++ b/.claude/commands/agents/agent-spawning.md @@ -1,28 +1,103 @@ # agent-spawning -Guide to spawning agents with Claude Code's Task tool. +Guide to spawning agents with Claude Code's Task tool and MCP coordination. ## Using Claude Code's Task Tool **CRITICAL**: Always use Claude Code's Task tool for actual agent execution: ```javascript -// Spawn ALL agents in ONE message -Task("Researcher", "Analyze requirements...", "researcher") -Task("Coder", "Implement features...", "coder") -Task("Tester", "Create tests...", "tester") +// Spawn ALL agents in ONE message for concurrent execution +Task("Researcher", "Analyze requirements and write findings to memory", "researcher") +Task("Coder", "Implement features with memory coordination", "coder") +Task("Tester", "Create tests and report results", "tester") +Task("Reviewer", "Review code quality and share feedback", "reviewer") ``` +## Available Agent Types + +### Swarm Agents +- **hierarchical-coordinator** - Tree-structure command coordination +- **mesh-coordinator** - Peer-to-peer collaboration +- **adaptive-coordinator** - Dynamic topology adjustment + +### Hive-Mind Agents (NEW) +- **queen-coordinator** - Sovereign orchestrator +- **collective-intelligence-coordinator** - Distributed cognition +- **swarm-memory-manager** - Memory coordination +- **worker-specialist** - Task execution +- **scout-explorer** - Reconnaissance + +### Core Development +- **coder**, **reviewer**, **tester**, **planner**, **researcher** + +### Specialized Agents +- **backend-dev**, **mobile-dev**, **ml-developer** +- **api-docs**, **system-architect**, **code-analyzer** +- **base-template-generator**, **cicd-engineer** + ## MCP Coordination Setup (Optional) -MCP tools are ONLY for coordination: +MCP tools are ONLY for coordination topology: ```javascript -mcp__claude-flow__swarm_init { topology: "mesh" } +// Step 1: Initialize swarm topology +mcp__claude-flow__swarm_init { + topology: "hierarchical", + maxAgents: 10 +} + +// Step 2: Define agent types for coordination mcp__claude-flow__agent_spawn { type: "researcher" } +mcp__claude-flow__agent_spawn { type: "coder" } +``` + +## Memory Coordination Protocol + +All spawned agents MUST write to memory: + +```javascript +// MANDATORY pattern for every agent +mcp__claude-flow__memory_usage { + action: "store", + key: "swarm/[agent-name]/status", + namespace: "coordination", + value: JSON.stringify({ + agent: "agent-name", + status: "active", + task: "current task", + timestamp: Date.now() + }) +} ``` ## Best Practices -1. Always spawn agents concurrently -2. Use Task tool for execution -3. MCP only for coordination -4. Batch all operations + +1. **Always spawn agents concurrently** - Use ONE message +2. **Use Task tool for execution** - Claude Code handles real work +3. **MCP only for coordination** - Setup topology, not execution +4. **Batch all operations** - 300% performance improvement +5. **Memory writes are MANDATORY** - Agents must coordinate + +## Example: Full Stack Development + +```javascript +// Single message with ALL agents +[Concurrent Execution]: + Task("Backend Developer", "Build REST API with memory coordination", "backend-dev") + Task("Frontend Developer", "Create React UI, check memory for API", "coder") + Task("Database Architect", "Design schema, store in memory", "code-analyzer") + Task("Test Engineer", "Write tests, check memory for contracts", "tester") + Task("DevOps Engineer", "Setup CI/CD, document in memory", "cicd-engineer") + + TodoWrite { todos: [...all todos...] } + + Write "backend/server.js" + Write "frontend/App.jsx" + Write "database/schema.sql" +``` + +## See Also +- `swarm-init` - Initialize swarm topology +- `hive-mind-spawn` - Spawn hive-mind agents +- `task-orchestrate` - Orchestrate complex tasks +- `agent-types` - List all available agents