locales/zh-CN/skills/spec-driven-dev/SKILL.md
在编写代码前,建立、审查和管理规格文件。 使用时机:建立规格、审查设计、规格驱动开发流程。 关键字:spec, specification, SDD, design, review, 规格, 设计, 审查, 验证。
npx skillsauth add asiaostrich/universal-dev-standards locales/zh-CN/skills/spec-driven-devInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
在编写代码前,建立、审查和管理规格文件。
在编写代码前,建立、审查和管理规格文件。
/sdd vs uds spec | 何时使用| 场景 | /sdd | uds spec |
|----------|--------|------------|
| 带审查周期的正式功能开发 | ✅ | ❌ |
| 完整 spec 生命周期(Draft → Archived) | ✅ | ❌ |
| 快速原型 / Vibe coding | ❌ | ✅ |
| 小幅增量改动 | ❌ | ✅ |
| 需要利益相关方签核 | ✅ | ❌ |
| 从自然语言意图生成 micro-spec | ❌ | ✅ |
/sdd= 用于正式开发的完整 spec 生命周期uds spec= 用于快速迭代的轻量 micro-spec
/sdd= 正式开发的完整规格生命周期uds spec= 快速迭代的轻量微规格
specs/、docs/specs/ 或项目的 spec 目录SPEC-NNN 或 kebab-case 变更 IDNew request? | 新需求?
├─ Bug fix restoring spec behavior? → Fix directly | 直接修复
├─ Typo/format/comment? → Fix directly | 直接修复
├─ Dependency update (non-breaking)? → Fix directly | 直接修复
├─ New feature/capability? → Create proposal | 建立提案
├─ Breaking change? → Create proposal | 建立提案
├─ Architecture change? → Create proposal | 建立提案
├─ Agent/role definition (spans multiple features)? → Use spec-type: agent | 使用 Agent SPEC template
└─ Unclear? → Create proposal (safer) | 建立提案(较安全)
DISCUSS ──► CREATE ──► REVIEW ──► APPROVE ──► IMPLEMENT ──► VERIFY ──► ARCHIVE
捕捉灰色地带、建立指导原则,并在撰写 spec 前消解歧义。
定义需求、技术设计、验收条件与测试计划。
与利益相关方一起检查完整性、一致性与可行性。
在实作开始前取得利益相关方签核。
依据已核准的 spec 进行开发,参照需求与 AC。
确保实作与 spec 相符、所有测试通过、AC 满足。
将完成的 spec 归档,并附上指向 commit/PR 的链接。
| 状态 | Description | 说明 | |-------|-------------|------| | Draft | Work in progress | 草稿中 | | Review | Under review | 审查中 | | Approved | Ready for implementation | 已核准 | | Implemented | Code complete | 已实作 | | Archived | Completed or deprecated | 已归档 |
# [SPEC-ID] Feature: [Name]
## Overview
Brief description of the proposed change.
## Motivation
Why is this change needed? What problem does it solve?
## Requirements
### Requirement: [Name]
The system SHALL [behavior description].
#### Scenario: [Success case]
- **GIVEN** [initial context]
- **WHEN** [action performed]
- **THEN** [expected result]
## Acceptance Criteria
- AC-1: Given [context], when [action], then [result]
## Technical Design
[Architecture, API changes, database changes]
## Test Plan
- [ ] Unit tests for [component]
- [ ] Integration tests for [flow]
spec-type: agent)# [SPEC-ID] Agent: [Role Name]
<!-- spec-type: agent -->
<!-- agent-id auto-referenced by feature SPECs -->
## Role Definition
- **Role**: [Agent Name]
- **Responsibility**: [One sentence]
- **Autonomy Level**: L[1-5] (per DEC-065)
## Capability Scope
**Owns:**
- [Capability 1]
- [Capability 2]
**Does NOT own:**
- [Explicit exclusion]
## Interface Contract
### Input
| Message Type | Required Fields | Optional Fields |
|---|---|---|
| [Type] | [fields] | [fields] |
### Output
| Artifact Type | Success Condition | Failure Condition |
|---|---|---|
| [Type] | [condition] | [condition] |
## Agent Interactions
- **Upstream**: [Who calls this agent]
- **Downstream**: [Who this agent calls]
- **Parallel**: [Agents working alongside]
## Related Feature SPECs
- [SPEC-NNN] — [This agent's role in that spec]
#### Scenario:(h4 标题)修改既有 spec 时,使用 delta 区段:
| Operation | Description | 说明 |
|-----------|-------------|------|
| ## ADDED Requirements | New capabilities | 新增功能 |
| ## MODIFIED Requirements | Changed behavior | 修改行为 |
| ## REMOVED Requirements | Deprecated features | 移除功能 |
| ## RENAMED Requirements | Name changes | 重新命名 |
/sdd analyze) | 跨 artifact 一致性检查The executable face of the acceptance-criteria-traceability standard + forward-derivation single-spine principle (XSPEC-262). Validates that every test is a faithful projection of the AC spine across specs. 本命令是 acceptance-criteria-traceability + forward-derivation single-spine 的可执行面,验证每个测试是否忠实投影 AC 主干。
| Signal | Meaning | Gate |
|--------|---------|------|
| orphan test | @SPEC-NNN @AC-N references an AC no spec defines / 引用不存在的 AC | 🔴 BLOCKING |
| uncovered | an AC has no @SPEC-NNN @AC-N reference / AC 无测试引用 | report only / 仅报告 |
| not_implemented | AC marked so in its .ac.yaml / .ac.yaml 标记 | 🔴 BLOCKING before UAT |
| cross-spec conflict | same AC id defined in >1 spec / 同 AC id 跨多 spec | 🔴 BLOCKING |
| orphan .feature | Gherkin @AC-N tag referencing a non-existent AC / @AC-N 引用不存在 | 🔴 BLOCKING |
| AC w/o scenario | AC has no .feature scenario (when BDD in use) / AC 无 BDD scenario | report only / 仅报告 |
| user-guide drift | user-guide T-N with no matching journey/E2E test id / 手册 T-N 无对应测试 | 🔴 BLOCKING |
Coverage % uses the acceptance-criteria-traceability formula (not_implemented excluded). --json for CI.
npm run sdd:analyze -- --specs specs --tests tests [--userguide docs] [--json]
--userguide <dir> enables user-guide↔E2E drift detection (T-NNN, XSPEC-260/257). / 启用手册↔E2E drift 侦测。
vs /ac-coverage: ac-coverage = per-spec detailed AC↔test matrix;/sdd analyze = cross-spec/batch consistency + orphan detection(互补、不取代)。
/converge 借鉴)vs /sdd analyze:/sdd analyze 问「测试有没有正确引用 AC」(引用完整性,deterministic script);convergence check 问「代码的实际行为是否真的符合 spec 描述」(语意漂移,需要读码判断,走 sdd.flow.yaml verify 阶段的 spec-match-check ai-check step)——两者互补、检查的是不同层次的问题,不重叠。
虽然定义在 7-phase 状态机的 verify 阶段(一次性 gate),这个检查可以在任何时间点对已归档的 spec 独立重跑——用于侦测 spec 归档后、code 持续演进累积出的漂移(例如后续 commit 改了行为但没回头更新 spec)。重跑时:
missing(spec 要求但没做)/partial(做一半)/contradicts(行为与描述不同)/unrequested(做了没被要求的事)CRITICAL(违反 spec 明确 MUST)/HIGH/MEDIUM/LOW/sdd - Interactive spec creation wizard | 互动式规格建立向导
/sdd auth-flow - Create spec for specific feature | 为特定功能建立规格
/sdd review - Review existing specs | 审查现有规格
/sdd analyze - Cross-artifact consistency check | 跨 artifact 一致性检查
/sdd --sync-check - Check sync status | 检查同步状态
/sdd 完成后,AI 助手应建议:
规格文件已建立。建议下一步 / Specification document created. Suggested next steps:
- 执行
/derive从规格推导测试工件 ⭐ Recommended / 推荐 — Derive test artifacts from spec- 执行
/derive bdd仅推导 BDD 场景 — Derive BDD scenarios only- 执行
/derive tdd仅推导 TDD 骨架 — Derive TDD skeletons only- 审查 AC 完整性,确保所有验收条件可测试 — Review AC completeness
- 检查 UDS 规范覆盖率 → 执行
/audit --patterns— Check UDS standard coverage → Run/audit --patterns
完整的 AI 行为定义请参阅对应的命令文件:
/sddFor complete AI agent behavior definition, see the corresponding command file:
/sdd
tools
[UDS] 從規格衍生 BDD 場景、TDD 骨架或 ATDD 表格
development
[UDS] /methodology: 選擇並追蹤開發方法論(SDD/BDD/TDD)。 Use when: 選擇方法論、切換開發模式、查詢當前方法論狀態。 若要查詢各階段對應指令請用 /dev-workflow。
testing
[UDS] Derive BDD scenarios, TDD skeletons, or ATDD tables from specifications
development
[UDS] Create or review specification documents for Spec-Driven Development