sparc-refine
Run the SPARC Refinement and Completion phases — review code, improve test coverage, validate against specification, and generate documentation
What this skill does
# 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
1. **Retrieve all prior artifacts** — call `mcp__claude-flow__memory_search` with namespace `sparc-phases` and query for the feature slug. Load spec (acceptance criteria), pseudocode, and architecture.
2. **Retrieve phase state** — call `mcp__claude-flow__memory_search` with namespace `sparc-state` to confirm we are in Phase 4.
3. **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
4. **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
5. **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
6. **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
7. **Store refinement artifact** — call `mcp__claude-flow__memory_store` with namespace `sparc-phases`, key `refine-{feature-slug}`, value: `{ status: "complete", reviewFindings: [...], coveragePercent: N, performanceResults: {...}, iterations: N }`
8. **Record trajectory step** — call `mcp__claude-flow__hooks_intelligence_trajectory-step` with refinement summary
### Phase 5 — Completion
9. **Full regression** — run the complete test suite to verify no regressions from refinement changes
10. **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
11. **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
12. **Deployment readiness checklist**:
- [ ] All tests passing
- [ ] Documentation complete
- [ ] Database migrations prepared (if applicable)
- [ ] Configuration changes documented
- [ ] Feature flags configured (if applicable)
- [ ] Rollback plan defined
- [ ] Security review complete (no secrets, inputs validated)
13. **Store completion artifact** — call `mcp__claude-flow__memory_store` with namespace `sparc-phases`, key `complete-{feature-slug}`, value: `{ status: "complete", traceabilityMatrix: [...], documentationFiles: [...], deploymentChecklist: {...}, regressionResult: "pass" }`
14. **End trajectory** — call `mcp__claude-flow__hooks_intelligence_trajectory-end` with the full SPARC cycle summary
15. **Train neural patterns** — call `mcp__claude-flow__neural_train` with the successful SPARC cycle data to improve future predictions
16. **Store learned pattern** — call `mcp__claude-flow__memory_store` with namespace `patterns`, key `sparc-{feature-slug}`, value summarizing what worked, phase durations, and common blockers encountered
17. **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.
```
Related in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.