sparc-spec
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSPARC Specification Phase
SPARC规范阶段
Run Phase 1 of the SPARC methodology: define what must be built and how success is measured.
执行SPARC方法论的第一阶段:定义需要构建的内容以及衡量成功的标准。
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 — callwith metadata
mcp__claude-flow__hooks_intelligence_trajectory-start{ "phase": "specification", "feature": "$ARGUMENTS" } -
Check for prior work — callwith namespace
mcp__claude-flow__memory_searchand 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.sparc-state -
Search for similar patterns — callwith the feature description to find relevant past specifications and learned patterns
mcp__claude-flow__neural_predict -
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 — callwith:
mcp__claude-flow__memory_store- Namespace:
sparc-phases - Key:
spec-{feature-slug} - Value: JSON with
{ status: "complete", requirements, acceptanceCriteria, constraints, edgeCases, integrationPoints }
- Namespace:
-
Update phase state — callwith:
mcp__claude-flow__memory_store- Namespace:
sparc-state - Key:
current-phase-{feature-slug} - Value: updated state with artifacts list including the spec key
- Namespace:
-
Record trajectory step — callwith the specification summary
mcp__claude-flow__hooks_intelligence_trajectory-step -
Present specification — display the full specification document to the user with a summary table and suggest runningto pass the gate and move to the Pseudocode phase
/sparc advance
-
初始化阶段跟踪 — 调用,传入元数据
mcp__claude-flow__hooks_intelligence_trajectory-start{ "phase": "specification", "feature": "$ARGUMENTS" } -
检查已有工作 — 调用,命名空间为
mcp__claude-flow__memory_search,查询该功能以查看是否已存在SPARC工作流。若存在,检索现有工件;若不存在,则初始化第一阶段的状态。sparc-state -
搜索相似模式 — 调用,传入功能描述以查找相关的过往规范和已习得模式
mcp__claude-flow__neural_predict -
收集需求 — 分析功能描述和代码库,识别:
- 功能需求:功能必须实现的内容(面向用户的行为)
- 非功能需求:性能目标、安全约束、可扩展性需求
- 集成点:受影响的现有系统或API
- 数据需求:需要创建、读取、更新或删除的数据
-
定义验收标准 — 编写至少3条具体、可测试的Given/When/Then格式验收标准:
AC-1: Given [前置条件], when [操作], then [预期结果] AC-2: Given [前置条件], when [操作], then [预期结果] AC-3: Given [前置条件], when [操作], then [预期结果] -
识别约束条件 — 记录:
- 性能约束(延迟、吞吐量、资源限制)
- 安全约束(身份验证、授权、数据敏感度)
- 兼容性约束(浏览器支持、API版本、向后兼容性)
- 基础设施约束(部署环境、依赖项)
-
梳理边缘情况 — 列出至少3种边缘情况或故障场景:
- 输入无效时会发生什么?
- 并发访问时会发生什么?
- 外部依赖失败时会发生什么?
-
存储规范 — 调用,参数如下:
mcp__claude-flow__memory_store- 命名空间:
sparc-phases - 键:
spec-{feature-slug} - 值:包含的JSON
{ status: "complete", requirements, acceptanceCriteria, constraints, edgeCases, integrationPoints }
- 命名空间:
-
更新阶段状态 — 调用,参数如下:
mcp__claude-flow__memory_store- 命名空间:
sparc-state - 键:
current-phase-{feature-slug} - 值:更新后的状态,包含工件列表及规范键
- 命名空间:
-
记录轨迹步骤 — 调用,传入规范摘要
mcp__claude-flow__hooks_intelligence_trajectory-step -
展示规范 — 向用户展示完整的规范文档及摘要表格,并建议运行以通过阶段门控,进入伪代码阶段
/sparc advance
Output format
输出格式
undefinedundefinedSpecification: {Feature Name}
规范:{功能名称}
Requirements
需求
Functional
功能需求
- FR-1: ...
- FR-2: ...
- FR-1: ...
- FR-2: ...
Non-Functional
非功能需求
- NFR-1: ...
- NFR-1: ...
Acceptance Criteria
验收标准
- AC-1: Given ..., when ..., then ...
- AC-2: Given ..., when ..., then ...
- AC-3: Given ..., when ..., then ...
- 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: ...
- EC-1: ...
- EC-2: ...
- EC-3: ...
Integration Points
集成点
- IP-1: ...
Phase 1 complete. Run to pass the gate check.
/sparc advanceundefined- IP-1: ...
第一阶段完成。运行以通过阶段门控检查。
/sparc advanceundefined