sparc-spec

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

SPARC 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

步骤

  1. Initialize phase tracking — call
    mcp__claude-flow__hooks_intelligence_trajectory-start
    with metadata
    { "phase": "specification", "feature": "$ARGUMENTS" }
  2. 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.
  3. Search for similar patterns — call
    mcp__claude-flow__neural_predict
    with the feature description to find relevant past specifications and learned patterns
  4. 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
  5. 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]
  6. 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)
  7. 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?
  8. 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 }
  9. 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
  10. Record trajectory step — call
    mcp__claude-flow__hooks_intelligence_trajectory-step
    with the specification summary
  11. 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
  1. 初始化阶段跟踪 — 调用
    mcp__claude-flow__hooks_intelligence_trajectory-start
    ,传入元数据
    { "phase": "specification", "feature": "$ARGUMENTS" }
  2. 检查已有工作 — 调用
    mcp__claude-flow__memory_search
    ,命名空间为
    sparc-state
    ,查询该功能以查看是否已存在SPARC工作流。若存在,检索现有工件;若不存在,则初始化第一阶段的状态。
  3. 搜索相似模式 — 调用
    mcp__claude-flow__neural_predict
    ,传入功能描述以查找相关的过往规范和已习得模式
  4. 收集需求 — 分析功能描述和代码库,识别:
    • 功能需求:功能必须实现的内容(面向用户的行为)
    • 非功能需求:性能目标、安全约束、可扩展性需求
    • 集成点:受影响的现有系统或API
    • 数据需求:需要创建、读取、更新或删除的数据
  5. 定义验收标准 — 编写至少3条具体、可测试的Given/When/Then格式验收标准:
    AC-1: Given [前置条件], when [操作], then [预期结果]
    AC-2: Given [前置条件], when [操作], then [预期结果]
    AC-3: Given [前置条件], when [操作], then [预期结果]
  6. 识别约束条件 — 记录:
    • 性能约束(延迟、吞吐量、资源限制)
    • 安全约束(身份验证、授权、数据敏感度)
    • 兼容性约束(浏览器支持、API版本、向后兼容性)
    • 基础设施约束(部署环境、依赖项)
  7. 梳理边缘情况 — 列出至少3种边缘情况或故障场景:
    • 输入无效时会发生什么?
    • 并发访问时会发生什么?
    • 外部依赖失败时会发生什么?
  8. 存储规范 — 调用
    mcp__claude-flow__memory_store
    ,参数如下:
    • 命名空间:
      sparc-phases
    • 键:
      spec-{feature-slug}
    • 值:包含
      { status: "complete", requirements, acceptanceCriteria, constraints, edgeCases, integrationPoints }
      的JSON
  9. 更新阶段状态 — 调用
    mcp__claude-flow__memory_store
    ,参数如下:
    • 命名空间:
      sparc-state
    • 键:
      current-phase-{feature-slug}
    • 值:更新后的状态,包含工件列表及规范键
  10. 记录轨迹步骤 — 调用
    mcp__claude-flow__hooks_intelligence_trajectory-step
    ,传入规范摘要
  11. 展示规范 — 向用户展示完整的规范文档及摘要表格,并建议运行
    /sparc advance
    以通过阶段门控,进入伪代码阶段

Output format

输出格式

undefined
undefined

Specification: {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
/sparc advance
to pass the gate check.
undefined
  • IP-1: ...

第一阶段完成。运行
/sparc advance
以通过阶段门控检查。
undefined