SPARC Refinement + Completion
Run Phases 4 and 5 of the SPARC methodology: iteratively improve through code review and testing, then finalize with validation, documentation, and deployment readiness.
When to use
After the Architecture phase is complete and its gate has been passed. This skill covers the final two phases that bring a feature from implemented to production-ready.
Steps
Phase 4 — Refinement
Retrieve all prior artifacts — call mcp__plugin_ruflo-core_ruflo__memory_search with namespace sparc-phases and query for the feature slug. Load spec (acceptance criteria), pseudocode, and architecture.
Retrieve phase state — call mcp__plugin_ruflo-core_ruflo__memory_search with namespace sparc-state to confirm we are in Phase 4.
Code review — review the implementation against:
a. Specification compliance: does every acceptance criterion have a corresponding code path?
b. Architecture adherence: do modules follow the defined boundaries and dependency rules?
c. Pseudocode fidelity: does the implementation match the designed algorithms?
d. Code quality: naming conventions, single responsibility, error handling, no dead code
e. Document findings as review comments
Test coverage analysis:
a. Run existing tests and measure coverage
b. Identify uncovered acceptance criteria
c. Write missing tests:
- Unit tests for each public function
- Integration tests for cross-module interactions
- Edge case tests for each identified edge case from the spec
d. Target coverage >= 80% on new code
Performance validation — if the spec includes performance constraints:
a. Profile critical paths identified in the pseudocode
b. Compare measured performance against constraint thresholds
c. Optimize if thresholds are not met
Iterate — repeat steps 3-5 until:
- All acceptance criteria have passing tests
- Code review has no critical or high-severity issues
- Coverage meets the threshold
- Performance constraints are satisfied
Store refinement artifact — call mcp__plugin_ruflo-core_ruflo__memory_store with namespace sparc-phases, key refine-{feature-slug}, value: { status: "complete", reviewFindings: [...], coveragePercent: N, performanceResults: {...}, iterations: N }
Record trajectory step — call mcp__plugin_ruflo-core_ruflo__hooks_intelligence_trajectory-step with refinement summary
Phase 5 — Completion
Full regression — run the complete test suite to verify no regressions from refinement changes
Traceability matrix — build a matrix mapping every acceptance criterion to:
- The test(s) that verify it
- The code file(s) that implement it
- The current pass/fail status
Documentation:
a. Generate API documentation from code comments and type definitions
b. Write usage examples for key public interfaces
c. Update any existing documentation affected by the changes
Deployment readiness checklist:
Store completion artifact — call mcp__plugin_ruflo-core_ruflo__memory_store with namespace sparc-phases, key complete-{feature-slug}, value: { status: "complete", traceabilityMatrix: [...], documentationFiles: [...], deploymentChecklist: {...}, regressionResult: "pass" }
End trajectory — call mcp__plugin_ruflo-core_ruflo__hooks_intelligence_trajectory-end with the full SPARC cycle summary
Train neural patterns — call mcp__plugin_ruflo-core_ruflo__neural_train with the successful SPARC cycle data to improve future predictions
Store learned pattern — call mcp__plugin_ruflo-core_ruflo__memory_store with namespace patterns, key sparc-{feature-slug}, value summarizing what worked, phase durations, and common blockers encountered
Present completion report — display the traceability matrix, deployment checklist, and final status. Suggest running /sparc advance to pass the final gate, or /sparc report for the full methodology report.
Output format
# Refinement: {Feature Name}
## Code Review Summary
- Critical issues: {N} (must be 0 to pass gate)
- High issues: {N}
- Medium issues: {N}
- Resolved: {N}/{total}
## Test Coverage
- Overall: {N}%
- New code: {N}%
- Acceptance criteria covered: {N}/{total}
## Performance
| Constraint | Target | Measured | Status |
|-----------|--------|----------|--------|
| Response time | <200ms | 145ms | Pass |
---
# Completion: {Feature Name}
## Traceability Matrix
| AC | Test | Code | Status |
|----|------|------|--------|
| AC-1 | test_xxx | service.ts:42 | Pass |
| AC-2 | test_yyy | controller.ts:18 | Pass |
| AC-3 | test_zzz | repository.ts:31 | Pass |
## Deployment Checklist
- [x] All tests passing
- [x] Documentation complete
- [x] Migrations prepared
- [x] Config documented
- [x] Rollback plan defined
- [x] Security reviewed
---
SPARC workflow complete. Run `/sparc report` for the full methodology report.
Source: ruvnet/ruflo → plugins/ruflo-sparc/skills/sparc-refine/SKILL.md
1---2name: sparc-refine3description: Run the SPARC Refinement and Completion phases — review code, improve test coverage, validate against specification, and generate documentation4---5
6
7# SPARC Refinement + Completion
8
9Run Phases 4 and 5 of the SPARC methodology: iteratively improve through code review and testing, then finalize with validation, documentation, and deployment readiness.
10
11## When to use
12
13After the Architecture phase is complete and its gate has been passed. This skill covers the final two phases that bring a feature from implemented to production-ready.
14
15## Steps
16
17### Phase 4 — Refinement
18
191. **Retrieve all prior artifacts** — call `mcp__plugin_ruflo-core_ruflo__memory_search` with namespace `sparc-phases` and query for the feature slug. Load spec (acceptance criteria), pseudocode, and architecture.
20
212. **Retrieve phase state** — call `mcp__plugin_ruflo-core_ruflo__memory_search` with namespace `sparc-state` to confirm we are in Phase 4.
22
233. **Code review** — review the implementation against:
24 a. **Specification compliance**: does every acceptance criterion have a corresponding code path?
25 b. **Architecture adherence**: do modules follow the defined boundaries and dependency rules?
26 c. **Pseudocode fidelity**: does the implementation match the designed algorithms?
27 d. **Code quality**: naming conventions, single responsibility, error handling, no dead code
28 e. Document findings as review comments
29
304. **Test coverage analysis**:
31 a. Run existing tests and measure coverage
32 b. Identify uncovered acceptance criteria
33 c. Write missing tests:
34 - Unit tests for each public function
35 - Integration tests for cross-module interactions
36 - Edge case tests for each identified edge case from the spec
37 d. Target coverage >= 80% on new code
38
395. **Performance validation** — if the spec includes performance constraints:
40 a. Profile critical paths identified in the pseudocode
41 b. Compare measured performance against constraint thresholds
42 c. Optimize if thresholds are not met
43
446. **Iterate** — repeat steps 3-5 until:
45 - All acceptance criteria have passing tests
46 - Code review has no critical or high-severity issues
47 - Coverage meets the threshold
48 - Performance constraints are satisfied
49
507. **Store refinement artifact** — call `mcp__plugin_ruflo-core_ruflo__memory_store` with namespace `sparc-phases`, key `refine-{feature-slug}`, value: `{ status: "complete", reviewFindings: [...], coveragePercent: N, performanceResults: {...}, iterations: N }`
51
528. **Record trajectory step** — call `mcp__plugin_ruflo-core_ruflo__hooks_intelligence_trajectory-step` with refinement summary
53
54### Phase 5 — Completion
55
569. **Full regression** — run the complete test suite to verify no regressions from refinement changes
57
5810. **Traceability matrix** — build a matrix mapping every acceptance criterion to:
59 - The test(s) that verify it
60 - The code file(s) that implement it
61 - The current pass/fail status
62
6311. **Documentation**:
64 a. Generate API documentation from code comments and type definitions
65 b. Write usage examples for key public interfaces
66 c. Update any existing documentation affected by the changes
67
6812. **Deployment readiness checklist**:
69 - [ ] All tests passing
70 - [ ] Documentation complete
71 - [ ] Database migrations prepared (if applicable)
72 - [ ] Configuration changes documented
73 - [ ] Feature flags configured (if applicable)
74 - [ ] Rollback plan defined
75 - [ ] Security review complete (no secrets, inputs validated)
76
7713. **Store completion artifact** — call `mcp__plugin_ruflo-core_ruflo__memory_store` with namespace `sparc-phases`, key `complete-{feature-slug}`, value: `{ status: "complete", traceabilityMatrix: [...], documentationFiles: [...], deploymentChecklist: {...}, regressionResult: "pass" }`
78
7914. **End trajectory** — call `mcp__plugin_ruflo-core_ruflo__hooks_intelligence_trajectory-end` with the full SPARC cycle summary
80
8115. **Train neural patterns** — call `mcp__plugin_ruflo-core_ruflo__neural_train` with the successful SPARC cycle data to improve future predictions
82
8316. **Store learned pattern** — call `mcp__plugin_ruflo-core_ruflo__memory_store` with namespace `patterns`, key `sparc-{feature-slug}`, value summarizing what worked, phase durations, and common blockers encountered
84
8517. **Present completion report** — display the traceability matrix, deployment checklist, and final status. Suggest running `/sparc advance` to pass the final gate, or `/sparc report` for the full methodology report.
86
87## Output format
88
89```
90# Refinement: {Feature Name}
91
92## Code Review Summary
93- Critical issues: {N} (must be 0 to pass gate)
94- High issues: {N}
95- Medium issues: {N}
96- Resolved: {N}/{total}
97
98## Test Coverage
99- Overall: {N}%
100- New code: {N}%
101- Acceptance criteria covered: {N}/{total}
102
103## Performance
104| Constraint | Target | Measured | Status |
105|-----------|--------|----------|--------|
106| Response time | <200ms | 145ms | Pass |
107
108---
109
110# Completion: {Feature Name}
111
112## Traceability Matrix
113| AC | Test | Code | Status |
114|----|------|------|--------|
115| AC-1 | test_xxx | service.ts:42 | Pass |
116| AC-2 | test_yyy | controller.ts:18 | Pass |
117| AC-3 | test_zzz | repository.ts:31 | Pass |
118
119## Deployment Checklist
120- [x] All tests passing
121- [x] Documentation complete
122- [x] Migrations prepared
123- [x] Config documented
124- [x] Rollback plan defined
125- [x] Security reviewed
126
127---
128SPARC workflow complete. Run `/sparc report` for the full methodology report.
129```
130
131---
132
133**Source:** [`ruvnet/ruflo`](https://github.com/ruvnet/ruflo) → `plugins/ruflo-sparc/skills/sparc-refine/SKILL.md`