v2/docs/reference/SPARC.md
SPARC (Specification → Pseudocode → Architecture → Refinement → Code) is a systematic development methodology that provides structured, mode-based development environments for different software development tasks. This comprehensive approach ensures consistent, high-quality results across all phases of development.
SPARC transforms development from ad-hoc coding to systematic engineering by:
# List all available SPARC modes
npx claude-flow@alpha sparc modes [--verbose]
# Get detailed information about a specific mode
npx claude-flow@alpha sparc info <mode-slug>
# Execute a task in a specific SPARC mode
npx claude-flow@alpha sparc run <mode> "<task-description>"
# Run Test-Driven Development workflow
npx claude-flow@alpha sparc tdd "<feature-description>"
--help, -h - Show help information--verbose, -v - Enable detailed output--dry-run, -d - Show configuration without executing--non-interactive, -n - Run without user prompts--namespace <name> - Use custom memory namespace--enable-permissions - Enable permission prompts (default: auto-skip)--dangerously-skip-permissions - Skip all permission prompts (automatically applied)--config <path> - Use custom MCP configuration file--interactive, -i - Enable interactive mode (for TDD workflow)# Code implementation with custom namespace
npx claude-flow@alpha sparc run code "implement user authentication" --namespace auth_system
# Architecture planning with verbose output
npx claude-flow@alpha sparc run architect "design microservices architecture" --verbose
# Test-driven development for payment system
npx claude-flow@alpha sparc run tdd "payment processing with validation" --namespace payments
# Security review of existing codebase
npx claude-flow@alpha sparc run security-review "audit authentication system" --verbose
# Performance optimization with non-interactive mode
npx claude-flow@alpha sparc run optimizer "optimize database queries" --non-interactive
# Interactive TDD workflow (step-by-step)
npx claude-flow@alpha sparc tdd "user registration system" --interactive
# Automated TDD workflow
npx claude-flow@alpha sparc tdd "shopping cart functionality" --namespace ecommerce
# TDD with custom configuration
npx claude-flow@alpha sparc tdd "payment gateway integration" --config ./custom-mcp.json
SPARC modes can be orchestrated using BatchTool for parallel and sequential execution:
# Run multiple modes concurrently
batchtool run --parallel \
"npx claude-flow@alpha sparc run architect 'system design' --non-interactive" \
"npx claude-flow@alpha sparc run security-review 'security requirements' --non-interactive" \
"npx claude-flow@alpha sparc run researcher 'technology evaluation' --non-interactive"
# Sequential execution with result chaining
batchtool pipeline \
--stage1 "npx claude-flow@alpha sparc run ask 'gather requirements' --non-interactive" \
--stage2 "npx claude-flow@alpha sparc run architect 'design system' --non-interactive" \
--stage3 "npx claude-flow@alpha sparc run code 'implement features' --non-interactive" \
--stage4 "npx claude-flow@alpha sparc run tdd 'create test suite' --non-interactive"
# Iterative development with feedback loops
batchtool orchestrate --boomerang \
--research "npx claude-flow@alpha sparc run researcher 'best practices' --non-interactive" \
--design "npx claude-flow@alpha sparc run architect 'system design' --non-interactive" \
--implement "npx claude-flow@alpha sparc run code 'feature implementation' --non-interactive" \
--test "npx claude-flow@alpha sparc run tdd 'validation suite' --non-interactive" \
--refine "npx claude-flow@alpha sparc run optimizer 'performance tuning' --non-interactive"
# End-to-end feature development pipeline
npx claude-flow@alpha sparc pipeline "user authentication system" \
--phases "ask,architect,security-review,code,tdd,optimizer,documenter" \
--namespace "auth_feature" \
--parallel-compatible "ask,security-review,documenter"
# Parallel microservices development
batchtool run --max-parallel 3 \
"npx claude-flow@alpha sparc run code 'user service' --namespace users --non-interactive" \
"npx claude-flow@alpha sparc run code 'order service' --namespace orders --non-interactive" \
"npx claude-flow@alpha sparc run code 'payment service' --namespace payments --non-interactive" \
"npx claude-flow@alpha sparc run integration 'service communication' --namespace integration --non-interactive"
The SPARC TDD mode implements London School TDD with the following phases:
# Start interactive TDD workflow
npx claude-flow@alpha sparc tdd "shopping cart with discounts" --interactive
# Automated TDD with custom namespace
npx claude-flow@alpha sparc tdd "payment validation system" --namespace payments
# TDD with integration testing focus
npx claude-flow@alpha sparc run tdd "API endpoint with database" --namespace api_tests
Memory namespaces organize context and enable coordination between modes:
feature_<name> - Feature development contextbug_<id> - Bug fix trackingarch_ - Architecture planningtest_<suite> - Test developmentintegration_<service> - Integration work# Store progress and context
npx claude-flow@alpha memory store <namespace>_progress "Current implementation status"
npx claude-flow@alpha memory store <namespace>_decisions "Key architectural decisions"
npx claude-flow@alpha memory store <namespace>_blockers "Current impediments"
# Query previous work and context
npx claude-flow@alpha memory query <namespace>
npx claude-flow@alpha memory query <namespace>_architecture
npx claude-flow@alpha memory query <namespace>_requirements
# List all namespaces
npx claude-flow@alpha memory list
# Architect stores system design
npx claude-flow@alpha sparc run architect "design user system" --namespace user_feature
# Coder implements based on architect's design
npx claude-flow@alpha sparc run code "implement user CRUD" --namespace user_feature
# Tester validates implementation
npx claude-flow@alpha sparc run tdd "test user operations" --namespace user_feature
# All modes share the user_feature namespace for context
# 1. Requirements and research
npx claude-flow@alpha sparc run ask "e-commerce requirements" --namespace ecommerce
# 2. System architecture
npx claude-flow@alpha sparc run architect "microservices design" --namespace ecommerce
# 3. Parallel service development
batchtool run --parallel \
"npx claude-flow@alpha sparc run code 'user service API' --namespace ecommerce_users --non-interactive" \
"npx claude-flow@alpha sparc run code 'product catalog API' --namespace ecommerce_products --non-interactive" \
"npx claude-flow@alpha sparc run code 'order processing API' --namespace ecommerce_orders --non-interactive"
# 4. Integration and testing
npx claude-flow@alpha sparc run integration "service communication" --namespace ecommerce
npx claude-flow@alpha sparc run tdd "end-to-end testing" --namespace ecommerce
# 5. Security and optimization
batchtool run --parallel \
"npx claude-flow@alpha sparc run security-review 'security audit' --namespace ecommerce --non-interactive" \
"npx claude-flow@alpha sparc run optimizer 'performance tuning' --namespace ecommerce --non-interactive"
# Test-driven API development
npx claude-flow@alpha sparc tdd "RESTful user management API" --namespace user_api
# Add authentication layer
npx claude-flow@alpha sparc run security-review "API authentication" --namespace user_api
# Performance optimization
npx claude-flow@alpha sparc run optimizer "API response times" --namespace user_api
# Documentation generation
npx claude-flow@alpha sparc run documenter "API documentation" --namespace user_api
# 1. Research and reproduction
npx claude-flow@alpha sparc run debugger "investigate login failures" --namespace bug_1234
# 2. Root cause analysis
npx claude-flow@alpha sparc run analyst "analyze authentication flow" --namespace bug_1234
# 3. Fix implementation with tests
npx claude-flow@alpha sparc run tdd "fix and test authentication" --namespace bug_1234
# 4. Security validation
npx claude-flow@alpha sparc run security-review "validate auth fix" --namespace bug_1234
# Infrastructure planning
npx claude-flow@alpha sparc run architect "CI/CD architecture" --namespace devops
# Pipeline implementation
npx claude-flow@alpha sparc run devops "GitHub Actions workflow" --namespace devops
# Monitoring and alerts
npx claude-flow@alpha sparc run devops "application monitoring" --namespace devops
# Documentation
npx claude-flow@alpha sparc run documenter "deployment guide" --namespace devops
# Research phase
npx claude-flow@alpha sparc run researcher "JavaScript framework comparison" --namespace tech_eval
# Architecture implications
npx claude-flow@alpha sparc run architect "framework integration design" --namespace tech_eval
# Prototype development
npx claude-flow@alpha sparc run code "proof of concept" --namespace tech_eval
# Analysis and recommendation
npx claude-flow@alpha sparc run analyst "framework recommendation" --namespace tech_eval
ask mode to clarify requirementsResearch → Design → Implement → Test → Optimize → Loop back
Multiple features developed concurrently with coordination
Sequential phases with hand-off between specialized modes
Continuous improvement through multiple optimization cycles
Mode Not Found
.roomodes file exists in project directorynpx claude-flow@alpha init --sparc to set up SPARC environmentPermission Issues
--enable-permissions for manual control--dangerously-skip-permissions for efficiencyMemory Namespace Conflicts
npx claude-flow@alpha memory listBatchTool Integration
--non-interactive flag for parallel executionPerformance Issues
--verbose flag for debuggingCreate custom SPARC modes by extending the .roomodes configuration:
{
"customModes": [
{
"name": "Custom Mode",
"slug": "custom",
"roleDefinition": "Custom role description",
"customInstructions": "Specific instructions",
"groups": ["read", "edit", "command"],
"source": "custom"
}
]
}
SPARC provides a comprehensive, mode-based development methodology that transforms ad-hoc coding into systematic engineering. By leveraging specialized modes, memory persistence, and parallel execution capabilities, SPARC enables efficient, high-quality software development at scale.
Key advantages:
Start with npx claude-flow@alpha sparc modes to explore available modes, and use npx claude-flow@alpha sparc run <mode> "<task>" to begin systematic development with SPARC.