SPARC Specification Phase
Run Phase 1 of the SPARC methodology: define what must be built and how success is measured.
When to use
When starting a new feature or project that needs structured requirements gathering before any code is written. This phase produces the foundational specification that all subsequent phases (Pseudocode, Architecture, Refinement, Completion) build upon.
Steps
Initialize phase tracking — call mcp__claude-flow__hooks_intelligence_trajectory-start with metadata { "phase": "specification", "feature": "$ARGUMENTS" }
Check for prior work — call mcp__claude-flow__memory_search with namespace sparc-state and query for the feature to see if a SPARC workflow already exists. If it does, retrieve existing artifacts. If not, initialize state with phase 1.
Search for similar patterns — call mcp__claude-flow__neural_predict with the feature description to find relevant past specifications and learned patterns
Gather requirements — analyze the feature description and the codebase to identify:
- Functional requirements: what the feature must do (user-facing behaviors)
- Non-functional requirements: performance targets, security constraints, scalability needs
- Integration points: what existing systems or APIs are affected
- Data requirements: what data is created, read, updated, or deleted
Define acceptance criteria — write at least 3 concrete, testable acceptance criteria in Given/When/Then format:
AC-1: Given [precondition], when [action], then [expected result]
AC-2: Given [precondition], when [action], then [expected result]
AC-3: Given [precondition], when [action], then [expected result]
Identify constraints — document:
- Performance constraints (latency, throughput, resource limits)
- Security constraints (authentication, authorization, data sensitivity)
- Compatibility constraints (browser support, API versions, backward compatibility)
- Infrastructure constraints (deployment environment, dependencies)
Map edge cases — list at least 3 edge cases or failure scenarios:
- What happens with invalid input?
- What happens under concurrent access?
- What happens when external dependencies fail?
Store specification — call mcp__claude-flow__memory_store with:
- Namespace:
sparc-phases
- Key:
spec-{feature-slug}
- Value: JSON with
{ status: "complete", requirements, acceptanceCriteria, constraints, edgeCases, integrationPoints }
Update phase state — call mcp__claude-flow__memory_store with:
- Namespace:
sparc-state
- Key:
current-phase-{feature-slug}
- Value: updated state with artifacts list including the spec key
Record trajectory step — call mcp__claude-flow__hooks_intelligence_trajectory-step with the specification summary
Present specification — display the full specification document to the user with a summary table and suggest running /sparc advance to pass the gate and move to the Pseudocode phase
Output format
# Specification: {Feature Name}
## Requirements
### Functional
- FR-1: ...
- FR-2: ...
### Non-Functional
- NFR-1: ...
## Acceptance Criteria
- AC-1: Given ..., when ..., then ...
- AC-2: Given ..., when ..., then ...
- AC-3: Given ..., when ..., then ...
## Constraints
- Performance: ...
- Security: ...
- Compatibility: ...
## Edge Cases
- EC-1: ...
- EC-2: ...
- EC-3: ...
## Integration Points
- IP-1: ...
---
Phase 1 complete. Run `/sparc advance` to pass the gate check.
1---2name: sparc-spec3description: Run the SPARC Specification phase — gather requirements, define acceptance criteria, identify constraints, and store the spec in memory4---5
6# SPARC Specification Phase
7
8Run Phase 1 of the SPARC methodology: define what must be built and how success is measured.
9
10## When to use
11
12When starting a new feature or project that needs structured requirements gathering before any code is written. This phase produces the foundational specification that all subsequent phases (Pseudocode, Architecture, Refinement, Completion) build upon.
13
14## Steps
15
161. **Initialize phase tracking** — call `mcp__claude-flow__hooks_intelligence_trajectory-start` with metadata `{ "phase": "specification", "feature": "$ARGUMENTS" }`
17
182. **Check for prior work** — call `mcp__claude-flow__memory_search` with namespace `sparc-state` and query for the feature to see if a SPARC workflow already exists. If it does, retrieve existing artifacts. If not, initialize state with phase 1.
19
203. **Search for similar patterns** — call `mcp__claude-flow__neural_predict` with the feature description to find relevant past specifications and learned patterns
21
224. **Gather requirements** — analyze the feature description and the codebase to identify:
23 - **Functional requirements**: what the feature must do (user-facing behaviors)
24 - **Non-functional requirements**: performance targets, security constraints, scalability needs
25 - **Integration points**: what existing systems or APIs are affected
26 - **Data requirements**: what data is created, read, updated, or deleted
27
285. **Define acceptance criteria** — write at least 3 concrete, testable acceptance criteria in Given/When/Then format:
29 ```
30 AC-1: Given [precondition], when [action], then [expected result]
31 AC-2: Given [precondition], when [action], then [expected result]
32 AC-3: Given [precondition], when [action], then [expected result]
33 ```
34
356. **Identify constraints** — document:
36 - Performance constraints (latency, throughput, resource limits)
37 - Security constraints (authentication, authorization, data sensitivity)
38 - Compatibility constraints (browser support, API versions, backward compatibility)
39 - Infrastructure constraints (deployment environment, dependencies)
40
417. **Map edge cases** — list at least 3 edge cases or failure scenarios:
42 - What happens with invalid input?
43 - What happens under concurrent access?
44 - What happens when external dependencies fail?
45
468. **Store specification** — call `mcp__claude-flow__memory_store` with:
47 - Namespace: `sparc-phases`
48 - Key: `spec-{feature-slug}`
49 - Value: JSON with `{ status: "complete", requirements, acceptanceCriteria, constraints, edgeCases, integrationPoints }`
50
519. **Update phase state** — call `mcp__claude-flow__memory_store` with:
52 - Namespace: `sparc-state`
53 - Key: `current-phase-{feature-slug}`
54 - Value: updated state with artifacts list including the spec key
55
5610. **Record trajectory step** — call `mcp__claude-flow__hooks_intelligence_trajectory-step` with the specification summary
57
5811. **Present specification** — display the full specification document to the user with a summary table and suggest running `/sparc advance` to pass the gate and move to the Pseudocode phase
59
60## Output format
61
62```
63# Specification: {Feature Name}
64
65## Requirements
66### Functional
67- FR-1: ...
68- FR-2: ...
69
70### Non-Functional
71- NFR-1: ...
72
73## Acceptance Criteria
74- AC-1: Given ..., when ..., then ...
75- AC-2: Given ..., when ..., then ...
76- AC-3: Given ..., when ..., then ...
77
78## Constraints
79- Performance: ...
80- Security: ...
81- Compatibility: ...
82
83## Edge Cases
84- EC-1: ...
85- EC-2: ...
86- EC-3: ...
87
88## Integration Points
89- IP-1: ...
90
91---
92Phase 1 complete. Run `/sparc advance` to pass the gate check.
93```