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 归档
相关推荐
Thomas.Sir31 分钟前
第017讲:AI模型开发|可行性评分卡与一票否决:把主观判断结构化:数据不及格,其余满分也必须 No-Go
人工智能·ai
wflynn2 小时前
Gemini 3.8 Flash 和 Cyber 版本发布,网络安全与软件工程能力双线突破
ai·技术
Jeff-Tsai3 小时前
手上的纸质单据,能不能直接变成系统里的表单?
ai·.net·blazor·erp
xiezhr3 小时前
期待已久的workbuddy多设备同步终于来了
ai·ai-agent·workbuddy
知了一笑3 小时前
当项目只留下一个人
ai·职场·打工人
Summer-Bright1 天前
深度 | 决策模型抢滩:OpenAI 微软同周下场,大模型从生成文本转向输出概率判断
人工智能·microsoft·ai·微软·qwen·决策
wflynn2 天前
Inkling 2 Mini:26B 参数循环 Transformer 的本地多模态模型
人工智能·ai
我才是银古2 天前
DSH插件开发实录
ai·deepseek·dsh·dsh插件
万有AI2 天前
FastAPI中间件复盘:注册顺序换算、限流分层与SSE直通的三个设计决策
ai·api
aicat_cn2 天前
AI Studio 做的安卓 App 有后端了,Gemini 密钥不用塞进 APK
ai·大模型