sparc-refine
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSPARC Refinement + Completion
SPARC优化与完成阶段
Run Phases 4 and 5 of the SPARC methodology: iteratively improve through code review and testing, then finalize with validation, documentation, and deployment readiness.
执行SPARC方法论的第4和第5阶段:通过代码审查与测试迭代优化,随后通过验证、文档编制和部署就绪检查完成收尾工作。
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
第4阶段——优化
-
Retrieve all prior artifacts — callwith namespace
mcp__claude-flow__memory_searchand query for the feature slug. Load spec (acceptance criteria), pseudocode, and architecture.sparc-phases -
Retrieve phase state — callwith namespace
mcp__claude-flow__memory_searchto confirm we are in Phase 4.sparc-state -
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 — callwith namespace
mcp__claude-flow__memory_store, keysparc-phases, value:refine-{feature-slug}{ status: "complete", reviewFindings: [...], coveragePercent: N, performanceResults: {...}, iterations: N } -
Record trajectory step — callwith refinement summary
mcp__claude-flow__hooks_intelligence_trajectory-step
-
获取所有前期工件 —— 调用,命名空间为
mcp__claude-flow__memory_search,查询功能slug。加载规范(验收标准)、伪代码和架构文档。sparc-phases -
获取阶段状态 —— 调用,命名空间为
mcp__claude-flow__memory_search,确认当前处于第4阶段。sparc-state -
代码审查 —— 对照以下维度审查实现代码: a. 规范符合性:每项验收标准是否都有对应的代码路径? b. 架构一致性:模块是否遵循定义的边界和依赖规则? c. 伪代码忠实度:实现是否与设计的算法一致? d. 代码质量:命名规范、单一职责原则、错误处理、无死代码 e. 将审查结果记录为评审意见
-
测试覆盖率分析: a. 运行现有测试并测量覆盖率 b. 识别未覆盖的验收标准 c. 编写缺失的测试:
- 每个公共函数的单元测试
- 跨模块交互的集成测试
- 规范中每个已识别边缘场景的边缘用例测试 d. 目标:新代码覆盖率≥80%
-
性能验证 —— 如果规范包含性能约束: a. 对伪代码中识别的关键路径进行性能剖析 b. 将实测性能与约束阈值对比 c. 若未达到阈值则进行优化
-
迭代 —— 重复步骤3-5,直到:
- 所有验收标准对应的测试均通过
- 代码审查无严重或高优先级问题
- 覆盖率达到阈值要求
- 满足性能约束
-
存储优化阶段工件 —— 调用,命名空间为
mcp__claude-flow__memory_store,键为sparc-phases,值为:refine-{feature-slug}{ status: "complete", reviewFindings: [...], coveragePercent: N, performanceResults: {...}, iterations: N } -
记录轨迹步骤 —— 调用,传入优化阶段摘要
mcp__claude-flow__hooks_intelligence_trajectory-step
Phase 5 — Completion
第5阶段——完成
-
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:
- 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)
-
Store completion artifact — callwith namespace
mcp__claude-flow__memory_store, keysparc-phases, value:complete-{feature-slug}{ status: "complete", traceabilityMatrix: [...], documentationFiles: [...], deploymentChecklist: {...}, regressionResult: "pass" } -
End trajectory — callwith the full SPARC cycle summary
mcp__claude-flow__hooks_intelligence_trajectory-end -
Train neural patterns — callwith the successful SPARC cycle data to improve future predictions
mcp__claude-flow__neural_train -
Store learned pattern — callwith namespace
mcp__claude-flow__memory_store, keypatterns, value summarizing what worked, phase durations, and common blockers encounteredsparc-{feature-slug} -
Present completion report — display the traceability matrix, deployment checklist, and final status. Suggest runningto pass the final gate, or
/sparc advancefor the full methodology report./sparc report
-
全量回归测试 —— 运行完整测试套件,验证优化阶段的修改未引入回归问题
-
可追溯矩阵 —— 构建矩阵,将每项验收标准映射至:
- 验证该标准的测试用例
- 实现该标准的代码文件
- 当前的通过/失败状态
-
文档编制: a. 从代码注释和类型定义生成API文档 b. 编写关键公共接口的使用示例 c. 更新受修改影响的现有文档
-
部署就绪检查清单:
- 所有测试通过
- 文档编制完成
- 数据库迁移已准备(如适用)
- 配置变更已记录
- 功能标志已配置(如适用)
- 回滚计划已定义
- 安全审查完成(无密钥泄露、输入已验证)
-
存储完成阶段工件 —— 调用,命名空间为
mcp__claude-flow__memory_store,键为sparc-phases,值为:complete-{feature-slug}{ status: "complete", traceabilityMatrix: [...], documentationFiles: [...], deploymentChecklist: {...}, regressionResult: "pass" } -
结束轨迹 —— 调用,传入完整SPARC周期摘要
mcp__claude-flow__hooks_intelligence_trajectory-end -
训练神经模式 —— 调用,传入成功的SPARC周期数据以提升未来预测能力
mcp__claude-flow__neural_train -
存储学习到的模式 —— 调用,命名空间为
mcp__claude-flow__memory_store,键为patterns,值总结有效实践、阶段时长和遇到的常见障碍sparc-{feature-slug} -
展示完成报告 —— 显示可追溯矩阵、部署检查清单和最终状态。建议运行以通过最终阶段门,或运行
/sparc advance获取完整方法论报告。/sparc report
Output format
输出格式
undefinedundefinedRefinement: {Feature Name}
优化阶段: {功能名称}
Code Review Summary
代码审查摘要
- Critical issues: {N} (must be 0 to pass gate)
- High issues: {N}
- Medium issues: {N}
- Resolved: {N}/{total}
- 严重问题: {N} (必须为0才能通过阶段门)
- 高优先级问题: {N}
- 中优先级问题: {N}
- 已解决: {N}/{总数}
Test Coverage
测试覆盖率
- Overall: {N}%
- New code: {N}%
- Acceptance criteria covered: {N}/{total}
- 整体覆盖率: {N}%
- 新代码覆盖率: {N}%
- 已覆盖验收标准: {N}/{总数}
Performance
性能
| Constraint | Target | Measured | Status |
|---|---|---|---|
| Response time | <200ms | 145ms | Pass |
| 约束条件 | 目标值 | 实测值 | 状态 |
|---|---|---|---|
| 响应时间 | <200ms | 145ms | 通过 |
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 |
| 验收标准 | 测试用例 | 代码 | 状态 |
|---|---|---|---|
| AC-1 | test_xxx | service.ts:42 | 通过 |
| AC-2 | test_yyy | controller.ts:18 | 通过 |
| AC-3 | test_zzz | repository.ts:31 | 通过 |
Deployment Checklist
部署检查清单
- All tests passing
- Documentation complete
- Migrations prepared
- Config documented
- Rollback plan defined
- Security reviewed
SPARC workflow complete. Run for the full methodology report.
/sparc reportundefined- 所有测试通过
- 文档编制完成
- 迁移已准备
- 配置已记录
- 回滚计划已定义
- 安全审查完成
SPARC工作流完成。运行获取完整方法论报告。
/sparc reportundefined