Version: 1.0.0 Date: 2025-09-26 Purpose: Complete reference for accelerated development using SPARC + Claude-Flow
本專案現已配備完整的 SPARC 方法論 和 Claude-Flow 協作框架,提供 84.8% SWE-Bench 解決率 和 2.8-4.4x 速度提升。
5-Phase Workflow:
Specification → Pseudocode → Architecture → Refinement → Completion
Commands:
# Complete TDD workflow
npx claude-flow sparc tdd "Add multi-site intent validation"
# Individual phases
npx claude-flow sparc run spec-pseudocode "Feature description"
npx claude-flow sparc run architect "System design"
npx claude-flow sparc run integration "Integrate components"
# Parallel batch execution (300% faster)
npx claude-flow sparc batch "spec-pseudocode,architect" "New feature"
npx claude-flow sparc pipeline "Complete implementation task"Location: .claude/agents/
Categories:
- Core Development:
coder,reviewer,tester,planner,researcher - O-RAN/Nephio Specific:
oran-network-functions-agent- RIC/RAN deploymentcu-du-config-agent- CU/DU configurationslice-management-agent- Network slice lifecycleconfiguration-management-agent- Nephio R5 configperformance-optimization-agent- SMO integration optimization
- Kubernetes:
kubernetes-architect- GitOps, multi-cluster - Testing:
test-automator,tdd-london-swarm,production-validator - Architecture:
docs-architect,system-architect,base-template-generator - DevOps:
deployment-engineer,cicd-engineer - Security:
security-compliance-agent,security-auditor - Specialized:
golang-pro,python-pro,ai-engineer
Usage via Claude Code Task Tool:
// ✅ CORRECT: Spawn agents in parallel (single message)
[Single Message]:
Task("Implement intent processor", "Build TMF921 adapter...", "coder")
Task("Add unit tests", "90% coverage...", "tester")
Task("Review code", "Check security...", "reviewer")
Task("Document API", "Generate OpenAPI...", "docs-architect")
// Batch all todos
TodoWrite { todos: [
{content: "Implement processor", status: "in_progress", activeForm: "Implementing processor"},
{content: "Write tests", status: "pending", activeForm: "Writing tests"},
{content: "Review code", status: "pending", activeForm: "Reviewing code"},
...
]}Installed Servers (from .claude/settings.json):
claude-flow- Core SPARC and swarm coordinationruv-swarm- Enhanced swarm intelligence (optional)
MCP Usage (Coordination Setup):
// MCP tools ONLY coordinate, Claude Code executes
[Coordination Setup]:
mcp__claude-flow__swarm_init { topology: "mesh", maxAgents: 5 }
mcp__claude-flow__agent_spawn { type: "coder" }
mcp__claude-flow__agent_spawn { type: "tester" }
// Claude Code Task tool does actual work
[Execution]:
Task("Coder agent", "Implement feature", "coder")
Task("Tester agent", "Create tests", "tester")Location: .claude/settings.json - hooks section
Pre-Tool Hooks (Before operations):
PreToolUse[Bash]- Validate safety, prepare resourcesPreToolUse[Write|Edit]- Auto-assign agents, load contextPreCompact- Provide guidance before context compression
Post-Tool Hooks (After operations):
PostToolUse[Bash]- Track metrics, store resultsPostToolUse[Write|Edit]- Auto-format code, update memoryStop- Generate summary, persist state on session end
Example:
# When you run Bash, hooks automatically:
npx claude-flow@alpha hooks pre-command --validate-safety true
# ... execute command ...
npx claude-flow@alpha hooks post-command --track-metrics trueLocation: .claude/commands/
Available Categories:
agents - Agent management
analysis - Code and system analysis
automation - Workflow automation
coordination - Swarm coordination
flow-nexus - Cloud-based orchestration
github - Repository operations
hive-mind - Collective intelligence
hooks - Lifecycle hooks
memory - Context and state management
monitoring - Performance tracking
optimization - Performance tuning
pair - Pair programming
sparc - SPARC methodology
stream-chain - Streaming workflows
swarm - Swarm operations
training - Neural pattern training
truth - Verification and validation
verify - Quality assurance
workflows - Pipeline automation
Location: summit/, slides/, runbook/
Key Files:
summit/SUMMIT_OVERVIEW_2025.md- Complete demo overviewsummit/POCKET_QA_V2.md- Quick reference Q&A (42 questions)slides/SUMMIT_DEMO_2025.md- HackMD presentation slidesrunbook/POCKET_QA.md- Operational runbook
Golden Intents (Test Data):
ls summit/golden-intents/
# both-federated-learning.json - Multi-site federated learning
# edge1-analytics.json - Edge1 analytics workload
# edge2-ml-inference.json - Edge2 ML inferenceLocation: scripts/
Key Scripts:
# Complete LLM-driven demo (2,143 lines)
./scripts/demo_llm.sh --target edge1 --mode automated
# Multi-site orchestration demo
./scripts/demo_multisite.sh
# Rollback demonstration (841 lines)
./scripts/demo_rollback.sh
# Quick demo (8,223 lines)
./scripts/demo_quick.sh
# Orchestrator demo (678 lines)
./scripts/demo_orchestrator.sh# Use SPARC TDD workflow
npx claude-flow sparc tdd "Add intent validation for O2IMS provisioning requests"
# This automatically:
# 1. Generates specification
# 2. Creates pseudocode
# 3. Designs architecture
# 4. Implements with tests
# 5. Integrates and validatesSingle Message Pattern (CRITICAL):
// ✅ ALL operations in ONE message
[Message]:
// Spawn all agents
Task("Backend developer", "Implement TMF921 adapter with retry logic", "coder")
Task("Test engineer", "Create integration tests for adapter", "tester")
Task("DevOps engineer", "Setup CI/CD for adapter", "deployment-engineer")
Task("Security auditor", "Review adapter security", "security-compliance-agent")
// Batch ALL todos (8-10 minimum)
TodoWrite { todos: [
{content: "Implement TMF921 adapter", status: "in_progress", activeForm: "Implementing adapter"},
{content: "Add retry mechanism", status: "pending", activeForm: "Adding retry mechanism"},
{content: "Write unit tests", status: "pending", activeForm: "Writing tests"},
{content: "Integration tests", status: "pending", activeForm: "Creating integration tests"},
{content: "Setup Docker build", status: "pending", activeForm: "Setting up Docker"},
{content: "Configure GitHub Actions", status: "pending", activeForm: "Configuring CI/CD"},
{content: "Security audit", status: "pending", activeForm: "Auditing security"},
{content: "Update documentation", status: "pending", activeForm: "Updating docs"}
]}
// Batch file operations
Write "adapter/tmf921_client.py"
Write "adapter/tests/test_tmf921.py"
Write ".github/workflows/adapter-ci.yml"
Write "adapter/README.md"# Use specialized O-RAN agents
[Message]:
Task("Deploy RIC platform", "Setup Near-RT RIC with xApps", "ric-deployment-agent")
Task("Configure CU/DU", "Setup gNB with F1 interface", "cu-du-config-agent")
Task("Manage slices", "Create eMBB and URLLC slices", "slice-management-agent")
Task("Optimize performance", "Tune SMO integration", "performance-optimization-agent")# Use testing agents in parallel
[Message]:
Task("Unit testing", "90% coverage for intent processor", "test-automator")
Task("Integration testing", "E2E GitOps workflow", "production-validator")
Task("Security testing", "WG11 compliance validation", "security-compliance-agent")
Task("Performance testing", "Load test SLO gates", "performance-optimization-agent")1️⃣ ONE MESSAGE = ALL OPERATIONS
// ✅ CORRECT: Everything in single message
[Single Message]:
Task(agent1), Task(agent2), Task(agent3)
TodoWrite { todos: [8+ todos] }
Bash "cmd1"; Bash "cmd2"; Bash "cmd3"
Write file1, Write file2, Write file3
// ❌ WRONG: Multiple messages
Message 1: Task(agent1)
Message 2: TodoWrite { todos: [todo1] }
Message 3: Write file12️⃣ BATCH ALL TODOS (5-10+ minimum)
// ✅ CORRECT: Batch all todos
TodoWrite { todos: [
{content: "Task 1", status: "in_progress", activeForm: "Doing task 1"},
{content: "Task 2", status: "pending", activeForm: "Doing task 2"},
{content: "Task 3", status: "pending", activeForm: "Doing task 3"},
...8-10 total tasks...
]}
// ❌ WRONG: One todo at a time
TodoWrite { todos: [{content: "Task 1", status: "in_progress"}] }3️⃣ FILE ORGANIZATION
- ❌ NEVER save to root folder
- ✅ ALWAYS use subdirectories:
/src,/tests,/docs,/config,/scripts
With proper parallel execution:
- 84.8% SWE-Bench solve rate
- 32.3% token reduction
- 2.8-4.4x speed improvement
- 27+ neural models available
CRITICAL: Never save working files to root folder!
Correct Structure:
/src/ - Source code
/tests/ - Test files
/docs/ - Documentation
/config/ - Configuration
/scripts/ - Utility scripts
/examples/ - Example code
/operator/ - Operator code
/tools/ - Development tools
Wrong:
❌ /my-feature.md - Don't save to root
❌ /test.py - Don't save to root
❌ /notes.txt - Don't save to root
# Initialize SPARC configuration
npx claude-flow@latest init --sparc
# This creates:
# - .roomodes file (17+ SPARC modes)
# - .roo/ directory (templates and workflows)
# - Enhanced CLAUDE.md# Check available SPARC modes
npx claude-flow sparc modes
# List all agents
ls .claude/agents/*.md
# Check commands
ls .claude/commands/
# Verify MCP servers
cat .claude/settings.json | jq '.enabledMcpjsonServers'npx claude-flow sparc batch "analysis,refinement" "Fix intent validation bug in TMF921 adapter"npx claude-flow sparc tdd "Add support for mMTC network slices"[Message]:
Task("Analyze code structure", "Identify refactoring opportunities", "code-analyzer")
Task("Apply refactoring", "Improve modularity", "coder")
Task("Update tests", "Maintain 90% coverage", "tester")
Task("Review changes", "Verify correctness", "reviewer")[Message]:
Task("Edge1 deployment", "Deploy eMBB slice to edge1", "oran-network-functions-agent")
Task("Edge2 deployment", "Deploy URLLC slice to edge2", "oran-network-functions-agent")
Task("GitOps sync", "Configure Config Sync", "kubernetes-architect")
Task("Monitoring setup", "Setup Prometheus/Grafana", "monitoring-analytics-agent")Every agent spawned via Task tool MUST follow:
npx claude-flow@alpha hooks pre-task --description "task description"
npx claude-flow@alpha hooks session-restore --session-id "swarm-[id]"npx claude-flow@alpha hooks post-edit --file "[file]" --memory-key "swarm/[agent]/[step]"
npx claude-flow@alpha hooks notify --message "what was done"npx claude-flow@alpha hooks post-task --task-id "[task]"
npx claude-flow@alpha hooks session-end --export-metrics true- Multiple Messages for Related Operations
Message 1: Task("agent1")
Message 2: Task("agent2") // ❌ Should be in Message 1- Single Todo at a Time
TodoWrite { todos: [{content: "one task"}] } // ❌ Batch 8-10 todos- Files in Root Folder
Write "/test.md" // ❌ Use /docs/test.md or /tests/test.md- Using MCP for Execution
mcp__claude-flow__task_orchestrate // ❌ Use Claude Code Task tool instead- Batch Everything
[Single Message]:
Task(agent1), Task(agent2), Task(agent3)
TodoWrite { todos: [8+ todos] }
Bash cmd1, Bash cmd2
Write file1, Write file2- Proper File Organization
Write "/src/feature.py"
Write "/tests/test_feature.py"
Write "/docs/feature.md"- Claude Code for Execution, MCP for Coordination
// Optional: Setup coordination
mcp__claude-flow__swarm_init { topology: "mesh" }
// Required: Execute with Claude Code
Task("agent", "do work", "agent-type")- CLAUDE.md - Complete development guidelines
- docs/architecture/ - System architecture docs
- docs/network/ - Network configuration
- docs/operations/ - Operational guides
- docs/summit-demo/ - Demo materials
- scripts/demo_*.sh - Various demo scripts
- scripts/setup/*.sh - Setup automation
- summit/runbook.sh - Complete runbook
- .claude/settings.json - Claude Code configuration
- .claude/agents/ - All agent definitions
- .claude/commands/ - Command categories
- Beginner: Start with
npx claude-flow sparc tdd "simple feature" - Intermediate: Use specialized agents via Task tool
- Advanced: Orchestrate parallel swarms with coordination
- Expert: Create custom agents and workflows
- Always batch operations - Single message = all related operations
- Use specialized agents - 52 agents for specific tasks
- Follow file organization - Never save to root
- Leverage SPARC - Systematic TDD workflow
- Monitor hooks - Automatic formatting and validation
- Check demos - Learn from working examples
- Read CLAUDE.md - Complete reference guide
Remember:
- MCP coordinates (topology, strategy)
- Claude Code executes (Task tool spawns real agents)
- SPARC systematizes (TDD workflow)
- Hooks automate (formatting, validation, metrics)
Status: ✅ Ready for accelerated development Performance: 2.8-4.4x faster with 84.8% solve rate Agents Available: 52 specialized agents Commands Available: 19 categories
Next Steps: See examples above and start using Task tool with parallel agents!