SPARC Methodology Skill
Systematic Test-Driven Development using SPARC (Specification, Pseudocode, Architecture, Refinement, Completion).
Quick Commands
# Run complete TDD workflow
npx agentic-flow@alpha sparc tdd "implement user authentication"
# Run specific phase
npx agentic-flow@alpha sparc run specification "auth system"
npx agentic-flow@alpha sparc run pseudocode "auth system"
npx agentic-flow@alpha sparc run architect "auth system"
npx agentic-flow@alpha sparc run refinement "auth system"
npx agentic-flow@alpha sparc run completion "auth system"
# Batch execution
npx agentic-flow@alpha sparc batch "spec-pseudocode,architect" "feature X"
SPARC Phases
1. Specification (spec)
Define requirements and acceptance criteria.
Agent: specification
Output: Requirements doc, test cases
Command:
npx agentic-flow@alpha sparc run spec "user login feature"
2. Pseudocode (pseudo)
Design algorithms and logic flow.
Agent: pseudocode
Output: Algorithm design, flow diagrams
Command:
npx agentic-flow@alpha sparc run pseudo "auth flow"
3. Architecture (arch)
System design and component structure.
Agent: architecture
Output: Component diagram, API design
Command:
npx agentic-flow@alpha sparc run arch "microservices layout"
4. Refinement (refine)
Iterative TDD implementation.
Agent: refinement
Output: Tests + Implementation
Command:
npx agentic-flow@alpha sparc run refine "auth module"
5. Completion (complete)
Integration and deployment.
Agent: completion
Output: Integrated system, docs
Command:
npx agentic-flow@alpha sparc run complete "auth system"
SPARC Modes
Additional specialized modes:
| Mode | Description |
|---|---|
dev |
General development |
api |
API design |
ui |
UI/UX development |
test |
Testing focus |
refactor |
Code improvement |
debug |
Bug investigation |
security |
Security review |
devops |
CI/CD setup |
TDD Workflow
# Full TDD cycle
npx agentic-flow@alpha sparc tdd "implement OAuth2"
# This runs:
# 1. Specification: Define requirements
# 2. Pseudocode: Design algorithm
# 3. Architecture: Plan structure
# 4. Refinement: Write tests first, then implement
# 5. Completion: Integrate and document
Agent Integration
SPARC uses specialized agents:
// Via Claude Code Task tool
Task("Specification agent", "Define requirements for OAuth", "specification")
Task("Architecture agent", "Design OAuth architecture", "architecture")
Task("Coder agent", "Implement OAuth with TDD", "sparc-coder")
Task("Tester agent", "Verify OAuth implementation", "tester")
Task("Reviewer agent", "Review OAuth code quality", "reviewer")
Best Practices
- Start with specification: Clear requirements first
- Write tests first: TDD in refinement phase
- Iterate small: Small increments
- Document as you go: Keep docs updated
- Review at each phase: Quality gates
- Use parallel execution: Multiple agents