You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# 1. Initialize Claude Flow (creates .claude/, .hive-mind/, agents)
npx claude-flow@alpha init --sparc
# 2. Initialize AgentDB for persistent memory
npx agentdb init ./agent-memory.db --dimension 1536 --preset medium
# 3. Initialize Hive Mind coordination
npx claude-flow@alpha hive-mind init
Session Start (Every Session)
# Query existing knowledge before starting work
npx agentdb query --query "project context previous work" --k 5 --synthesize-context
# Check hive mind status
npx claude-flow@alpha hive-mind status
Session End (Every Session)
# Store session learnings
npx agentdb reflexion store "session-$(date +%s)""[task]" 0.85 true"[lessons]"# Train patterns from session
npx claude-flow@alpha training pattern-learn --operation "[operation]" --outcome "success"
π― DIRECTOR PATTERN (MANDATORY)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β YOU ARE THE CAPTAIN - NEVER THE IMPLEMENTER β
β β
β β Strategic planning β Writing code directly β
β β Synthesizing reports β Sequential agent deployment β
β β Coordinating workstreams β Holding raw data in context β
β β Stakeholder communication β Skipping AgentDB persistence β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β‘ AGENT DEPLOYMENT
GOLDEN RULE: One Message = All Operations
CLI (v2.0.69+) - TRUE PARALLEL, NO MCP REQUIRED:
# Deploy ALL agents in ONE message using Task tool directly
Task("security-audit", "Audit auth system for vulnerabilities...", "security")
Task("arch-review", "Review service architecture...", "architect")
Task("perf-analysis", "Analyze latency bottlenecks...", "analyzer")
Deployment Matrix
Environment
Method
Parallelism
MCP Required
CLI v2.1+
Task tool (direct)
β True
β No
CLI Async
Task + block=false
β True
β No
Hive Mind
--claude --auto-spawn
β True
β No
Swarm
--claude or --executor
β True
β No
Web v2.0.x
MCP tools
β οΈ Simulated
β Yes
tmux + CLI
Multiple instances
β True
β No
π ASYNC AGENT PATTERNS (CLI v2.0.69+)
Non-Blocking Agent Spawn
// Spawn agent without waiting for completionTask("researcher","Analyze Chrome MCP tools...","researcher")// Agent runs in background, returns immediately// Check status anytime (NON-BLOCKING)TaskOutput(agentId,block=false)// Wait for completion (BLOCKING)TaskOutput(agentId,block=true)
Real-Time Agent Communication
# Read agent output anytime (even while running)
cat /tmp/claude/-[project-path]/tasks/[agentId].output
# Check what agent is currently doing
TaskOutput(a4abf71, block=false)
# See progress updates via system reminders (automatic)
Mid-Flight Correction Pattern
// Agent starts workTask("designer","Audit UI at https://example.com","designer")// Returns agentId: a4abf71// Check progress (non-blocking)TaskOutput(a4abf71,block=false)// See they're on wrong URL!// Launch CORRECTION AGENT to redirectTask("corrector","URGENT: Tell agent a4abf71 to change from example.com to example.com/app","coordinator")// Correction agent communicates with running agent// Both coordinate in real-time
Direct Output File Communication
# Read what agent is doing right now
cat /tmp/claude/-home-user-projects/tasks/a4abf71.output
# Send message by writing to their streamecho"CORRECTION: Change to /app URL">> /tmp/claude/.../tasks/a4abf71.output
π’ RECURSIVE DIRECTOR SPAWNING (ADVANCED)
Promote Agents to Directors
// Spawn an agent and TELL THEM they are a DirectorTask("Chrome Research Director",`You are the DIRECTOR of Chrome Research & Development. Your mission: Comprehensively analyze Chrome MCP integration. AS A DIRECTOR, you must: 1. Spawn your own specialist team (3-4 agents) 2. Coordinate their work 3. Synthesize findings into executive report Spawn these specialists: - Chrome Tools Analyst: Map all chrome-* MCP tools - Native Integration Tester: Test claude --chrome vs MCP - Performance Benchmark Agent: Measure speed/memory/CPU - Documentation Specialist: Create integration guide Use Task() to spawn each specialist. Use TaskOutput(id, block=false) to monitor progress. Synthesize all findings when complete.`,"system-architect")
Corporate Hierarchy Pattern
CEO (You - Human)
βββ COO (Claude Director - This Context)
βββ Chrome Research Director (spawned agent)
β βββ Chrome Tools Analyst
β βββ Native Integration Tester
β βββ Performance Benchmark Agent
β βββ Documentation Specialist
βββ UI/UX Design Director (spawned agent)
βββ Visual Design Analyst
βββ UX Flow Specialist
βββ Accessibility Expert
βββ Responsive Design Tester
Multi-Level Director Spawn
// Spawn two Director-level agents simultaneouslyTask("researcher","You are DIRECTOR of Research Division. Spawn 3-4 specialists to analyze [topic]. Coordinate and synthesize.","system-architect")Task("designer","You are DIRECTOR of Design Division. Spawn 3-4 specialists to audit [target]. Coordinate and synthesize.","system-architect")// Directors will spawn their own teams// Monitor with TaskOutput(id, block=false)// Each Director manages 4-6 agents = 10-12 total agents running
Director Promotion Prompt Template
You are the DIRECTOR of [DIVISION NAME].
Your mission: [OBJECTIVE]
AS A DIRECTOR, you must:
1. Spawn your own specialist team using Task()
2. Monitor progress with TaskOutput(id, block=false)
3. Send corrections if agents go off-track
4. Synthesize all findings into executive report
5. Store lessons in AgentDB when complete
SPAWN THESE SPECIALISTS:
- [Specialist 1]: [Task description]
- [Specialist 2]: [Task description]
- [Specialist 3]: [Task description]
- [Specialist 4]: [Task description]
COORDINATION RULES:
- Check each agent status every few minutes
- Launch correction agents if needed
- Aggregate findings, don't duplicate work
- Report synthesized summary only (max 10 points)
# Development workflow with Claude Code
npx claude-flow@alpha swarm "Build REST API" --claude
# Use built-in executor
npx claude-flow@alpha swarm "Optimize queries" --executor --parallel
# Analysis mode (read-only, safe for audits)
npx claude-flow@alpha swarm "Security audit" --analysis --strategy research
# Full options
npx claude-flow@alpha swarm "[objective]" \
--strategy development \
--mode hierarchical \
--max-agents 8 \
--parallel \
--monitor
π§ NEURAL NETWORKING & LEARNING
Training Commands
# Train neural patterns from recent operations
npx claude-flow@alpha training neural-train --data recent --model task-predictor
# Train from specific swarm session
npx claude-flow@alpha training neural-train --data "swarm-123" --epochs 100
# Learn from operation outcomes
npx claude-flow@alpha training pattern-learn --operation "code-review" --outcome "success"# Update agent models with insights
npx claude-flow@alpha training model-update --agent-type coordinator --operation-result "efficient"
Model Types
Model
Purpose
task-predictor
Predict optimal task assignments
agent-selector
Select best agent for work type
performance-optimizer
Optimize execution patterns
coordinator-predictor
Improve coordination decisions
π€ AGENT TYPES
Core Agents (Use Task Tool Directly)
Agent
Model
Tools
Use Case
researcher
haiku/sonnet
Read, Grep, Web
Information gathering
coder
sonnet
All
Implementation
reviewer
sonnet
Read, Grep
Code quality
tester
sonnet
All
Test creation
architect
opus
All
System design
system-architect
opus
All
Director-level decisions
Explore
haiku
Read, Glob, Grep
Quick discovery
planner
opus
All
Strategic planning
debugger
sonnet
All
Bug investigation
analyzer
sonnet
Read, Grep, Bash
Performance analysis
coordinator
sonnet
All
Multi-agent orchestration
SPARC Specialized Agents (54 available)
# List all available agents
npx claude-flow@alpha agents list
# Spawn specific SPARC agent
npx claude-flow@alpha sparc run architect "Design microservices"
npx claude-flow@alpha sparc run tdd "Implement auth module"
npx claude-flow@alpha sparc run swarm-coordinator "Manage development swarm"
β WITH GOVERNANCE:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ARTIFACT CREATION AUTHORIZATION β
β β
β TIER 1 - DIRECTORS: Can create institutional documents β
β TIER 2 - DOCUMENT AGENTS: Authorized for specific outputs β
β TIER 3 - WORKERS: Store in AgentDB ONLY, no file creation β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Authorization Matrix
Agent Type
Create Files
AgentDB Storage
Use Case
Director
β Yes
β Yes
Synthesis reports, roadmaps
Document Agent
β Yes (authorized)
β Yes
SOPs, guides, specs
Worker/Specialist
β No
β Yes (required)
Findings, analysis, data
Explorer
β No
β οΈ Optional
Quick lookups
Worker Agent Prompt Pattern (No Artifacts)
Your task: [specific work]
WORKSPACE HYGIENE RULES:
- Do NOT create files or artifacts
- Store ALL findings in AgentDB:
npx agentdb reflexion store "[session]" "[task]" [score] [success] "[findings]"
- Return synthesized summary only (max 10 points)
- Raw data stays in AgentDB, insights flow up to Director
Director Agent Prompt Pattern (Authorized Artifacts)
You are DIRECTOR of [Division].
AUTHORIZATION: You ARE authorized to create institutional documents.
Create these artifacts:
- [Division]-synthesis-report.md (executive summary)
- [Division]-recommendations.md (actionable items)
Store detailed findings in AgentDB for future reference.
Coordinate workers - they store in AgentDB, YOU create documents.
You are a DOCUMENT AGENT authorized to create: [specific document type]
AUTHORIZATION SCOPE:
- Create: [authorized-doc].md
- Update: Existing [doc-type] files
- NOT authorized: Other file types
Store research/findings in AgentDB.
Only create the specifically authorized document.
AgentDB as Central Knowledge Store
# Workers store findings (not files)
npx agentdb reflexion store "worker-001""security scan" 0.9 true \
"Found 3 vulnerabilities: SQL injection in /api/users, XSS in comments, CSRF missing"# Directors query consolidated knowledge
npx agentdb query --query "security vulnerabilities" --k 20 --synthesize-context
# Directors THEN create institutional documents from synthesized knowledge# β security-audit-report.md (authorized artifact)
Cleanup Pattern
# Workers: Nothing to clean (stored in AgentDB)# Directors: Consolidate and archive
npx agentdb skill consolidate 3 0.7 7 true# Sync institutional knowledge across team
npx agentdb sync push --server [host:port] --incremental
πΎ AGENTDB PERSISTENCE
Core Commands
# Initialize database
npx agentdb init ./agent-memory.db --dimension 1536 --preset medium
# Store episode/finding after work
npx agentdb reflexion store "[session-id]""[task]" [reward] [success] "[critique]"# Example:
npx agentdb reflexion store "session-001""security audit" 0.9 true"Found 3 vulnerabilities"# Query knowledge base before work
npx agentdb query --query "[search terms]" --k 10 --synthesize-context
# Store discovered patterns
npx agentdb store-pattern --type "experience" --domain "[domain]" \
--pattern '{"pattern": "data"}' --confidence 0.9
# Weekly consolidation (CRITICAL)
npx agentdb skill consolidate 3 0.7 7 true
npx agentdb learner run 3 0.6 0.7
# Team sync (QUIC protocol)
npx agentdb sync push --server [host:port] --incremental
npx agentdb sync pull --server [host:port] --incremental
π CONTEXT CONSERVATION
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AGENTS SYNTHESIZE β DIRECTOR STRATEGIZES β
β β
β β’ Agents do heavy lifting AND distill findings β
β β’ Report back ONLY synthesized summary (max 10 points) β
β β’ Director context stays open for strategic planning β
β β’ Raw data stays with agents, insights flow up β
β β’ Store detailed findings in AgentDB for persistence β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Agent Synthesis Prompt Pattern
Your task: [specific work]
IMPORTANT - Before reporting back:
1. Complete your analysis
2. Synthesize findings into max 10 key points
3. Identify blockers, risks, and recommendations
4. Return ONLY the distilled summary, not raw data
5. Store detailed findings:
npx agentdb reflexion store "[session]" "[task]" [score] [success] "[notes]"
π οΈ COMMON DEPLOYMENTS
Full Codebase Audit (Recursive Directors)
// Spawn two Director-level agentsTask("Security Director","You are DIRECTOR of Security. Spawn specialists for: auth audit, vulnerability scan, compliance check, penetration test. Synthesize findings.","system-architect")Task("Architecture Director","You are DIRECTOR of Architecture. Spawn specialists for: code review, performance analysis, scalability audit, tech debt assessment. Synthesize findings.","system-architect")// Results in 10-12 agents total (2 Directors + 4 specialists each)
Workspace hygiene and artifact governance patterns.
π§Ή ARTIFACT AUTHORIZATION TIERS
Tier
Agent Type
Create Files
AgentDB
1
Directors
β Yes
β Yes
2
Document Agents
β Authorized only
β Yes
3
Workers
β No
β Required
π PROMPT PATTERNS
Worker (No Files)
WORKSPACE HYGIENE:
- Do NOT create files
- Store ALL findings in AgentDB:
npx agentdb reflexion store "[session]" "[task]" [score] [success] "[data]"
- Return summary only (max 10 points)
Director (Authorized)
AUTHORIZATION: Create institutional documents.
- [name]-synthesis.md
- [name]-recommendations.md
Store details in AgentDB. Workers store there too.
Document Agent (Scoped)
AUTHORIZATION SCOPE:
- Create: [specific-doc].md
- NOT authorized: Other file types
Store research in AgentDB.
Worker creates report.md β β Store in AgentDB
Worker creates findings.json β β Store in AgentDB
Worker creates analysis.txt β β Store in AgentDB
Director creates synthesis.md β β Authorized
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters