SDD Spec-Driven Development

记录几个模板

规格文件

不同团队的具体模板会有差异,但核心内容大致包括:

  • 页面/交互结构定义:应用包含哪些页面、每个页面的字段组成、操作按钮及其触发条件,以及页面之间的跳转关系
  • 数据模型定义:数据实体、字段类型与约束、实体间的关联关系
  • 业务规则与权限约束:核心业务逻辑、访问控制边界
  • 验收标准:以验收准则为导向的功能与非功能需求(如延迟、可用性等可量化指标)
  • 技术架构与依赖:数据契约、集成边界、错误行为、并发假设,以及风险与缓解措施

spec.md

  • 明确 Non-Goals/Goals
  • Problem Statement:为什么做?
  • Success Metrics:做到什么程度算完?(必须可量化)
  • User Stories:谁在什么场景下用?
  • Acceptance Criteria:如何验证?
  • Constraints:技术限制是什么?
工具 定位 核心特点 适用场景
Spec Kit (GitHub) Agent-agnostic 框架 三文件体系 + constitution 通用项目(43.7k Star)
OpenSpec (Fission-AI) 轻量迭代工具 Spec 在对话中完善 小型快速项目
Kiro (AWS) SDD-native IDE 完整 IDE 集成 AWS 生态
QoderWork (阿里) Quest 执行引擎 Spec → Quest → PR 自动化 阿里生态

Feature Spec 模板

Goal(一句话目标)

  • ...

Non-goals(明确不做)

  • ...

Acceptance Criteria(验收标准)

  • Given ...
  • When ...
  • Then ...

Edge Cases(边界条件)

  • 空值/缺省:
  • 重复/幂等:
  • 并发/竞态:
  • 权限/可见性:

Output / Deliverables(交付物)

  • API / DB / UI 变更:
  • 测试清单:
  • 回滚说明:

另一种Simple Example

复制代码
## Login Feature

**What it does:** Allows registered users to access the application.

**Requirements:**
- SHALL accept email and password
- SHALL validate email format before submission
- SHALL display error for invalid credentials
- SHALL redirect to dashboard on successful login
- SHALL rate-limit to 5 attempts per 15 minutes

**Scenarios:**
1. Valid credentials → redirect to /dashboard
2. Invalid credentials → show error, do not redirect
3. Empty fields → show validation errors
4. 6th failed attempt → show rate limit message

**Constraints:**
- SHALL NOT store passwords in plain text
- SHALL NOT allow brute force attacks
- SHALL NOT expose whether email exists

docs/specs/checkout-coupon/ proposal.md 为什么现在做、影响谁 spec.md 需求和场景 design.md 决策和取舍 tasks.md 可评审实现切片 test-evidence.md 合并前必须提供的证据

API Spec 模板(OpenAPI 思路)

Endpoint

  • Method: GET/POST/PUT/DELETE
  • Path: /v1/...
  • Owner: ...

Request

  • Headers:
  • Query:
  • Body schema:
    • field: type / required / default / constraints
  • Example request:

Response

  • Success (2xx):
    • schema:
    • example:
  • Error (4xx/5xx):
    • code: string
    • message: string
    • traceId: string
    • example:

Compatibility

  • 向后兼容说明:
  • 废弃策略:

Test Checklist

  • 正常路径
  • 参数校验失败
  • 鉴权/权限
  • 超时/重试/幂等

openspec使用记录

  1. openspec init
  2. /opsx:explore 先梳理需求
  3. /opsx:propose 创建规格和任务
  4. 人工检查 proposal/design/tasks/spec
  5. /opsx:apply 开始编码
  6. openspec validate 校验
  7. /opsx:archive 归档
相关推荐
2601_950790681 小时前
国产单片机厂家推荐:英锐恩8位MCU适合哪些控制项目
ai
葡萄城技术团队2 小时前
把商业表格引擎接进 Agent 工作台:四次取舍
ai
howdoyoudo2026066 小时前
AI审计手记 #28:从“暂停训练”到“切断联网”——AI安全控制手段的极限升级
大数据·人工智能·安全·ai·语言模型
·云扬·10 小时前
Prompt 工程与安全:从 System 设计到注入防御
java·人工智能·安全·ai·prompt
九卷11 小时前
企业级Agent系统整体技术架构介绍
ai·架构·大模型·llm·agent·智能体
俊哥V15 小时前
每日 AI 研究简报 · 2026-10-12
人工智能·ai
空堂与归17 小时前
REA登顶GitHub:AI如何逆向一切软件
ai·大模型·agent
效率工作实验室17 小时前
2026年企业级 AI 智能体平台选型指南:关键评估维度
ai·agent·企业级·智能体平台·智能体平台选型