spec
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese/spec
/spec
Manage protocol-level specifications - the contract defining what a system must do.
管理协议级规范——定义系统必须实现内容的契约。
What is a Spec?
什么是Spec?
A spec (specification) defines requirements at the protocol/standard level:
- External specs: Standards you implement (LEAF spec, OAuth, OpenAPI)
- Self-authored specs: Your own protocol defining what your system does
Specs are NOT feature breakdowns or epics. They are the source of truth for requirements.
spec(规范) 在协议/标准层面定义要求:
- 外部规范:需实现的标准(LEAF spec、OAuth、OpenAPI)
- 自定义规范:由你方定义的、描述系统功能的协议
Spec并非功能分解或史诗级需求,而是需求的唯一可信来源。
Usage
使用方法
bash
/spec # Show current project's spec status
/spec --import <url> # Import external spec (GitHub, raw URL)
/spec --init # Create new protocol spec for project
/spec --sync # Sync imported spec with upstream
/spec --section <name> # Show specific section of specbash
/spec # 显示当前项目的spec状态
/spec --import <url> # 导入外部spec(GitHub、原始URL)
/spec --init # 为项目创建新的协议spec
/spec --sync # 与上游同步已导入的spec
/spec --section <name> # 显示spec的特定章节File Structure
文件结构
spaces/[project]/
├── docs/
│ ├── specs/ # The protocol spec (source of truth)
│ │ ├── README.md # Spec overview and compliance status
│ │ ├── api-specification.md # API contract
│ │ ├── data-models.md # Data structures
│ │ ├── required-features.md # Feature requirements
│ │ └── ...
│ └── adrs/ # Architecture decisions
└── src/ # Implementation
ideas/[project]/
├── project-brief.md # Strategy (private)
└── issues/
└── 001-auth/
└── TASK.md # implements: docs/specs/required-features.md#authenticationWhy specs live with code:
- Specs are the contract the code fulfills
- Developers need them alongside implementation
- Changes to spec and code can be atomic commits
- All documentation (specs, ADRs) lives together in docs/
spaces/[project]/
├── docs/
│ ├── specs/ # 协议spec(唯一可信来源)
│ │ ├── README.md # spec概述与合规状态
│ │ ├── api-specification.md # API契约
│ │ ├── data-models.md # 数据结构
│ │ ├── required-features.md # 功能需求
│ │ └── ...
│ └── adrs/ # 架构决策记录
└── src/ # 实现代码
ideas/[project]/
├── project-brief.md # 策略文档(私有)
└── issues/
└── 001-auth/
└── TASK.md # implements: docs/specs/required-features.md#authenticationSpec与代码共存的原因:
- Spec是代码需满足的契约
- 开发者需要在实现时随时参考Spec
- Spec与代码的变更可作为原子提交
- 所有文档(Spec、ADR)统一存放在docs/目录下
Execution Flow
执行流程
1. Determine Context
1. 确定上下文
bash
Read: ideas/[project]/project-brief.md # Strategy context
Glob: spaces/[project]/docs/specs/*.md # Existing specsQuestions:
- Does this project implement an external spec?
- Or does it need its own protocol spec?
bash
Read: ideas/[project]/project-brief.md # 策略上下文
Glob: spaces/[project]/docs/specs/*.md # 现有spec需明确的问题:
- 该项目是否需要实现外部spec?
- 还是需要自定义专属的协议spec?
2a. Import External Spec
2a. 导入外部Spec
For projects implementing a standard (like leaf-nextjs-convex → LEAF spec):
bash
/spec --import https://github.com/leafspec/specProcess:
- Clone/fetch spec files
- Copy to
spaces/[project]/docs/specs/ - Create with:
docs/specs/README.md- Source URL and version
- Last synced date
- Compliance checklist
- Suggest initial TASKs based on spec sections
Sync upstream changes:
bash
/spec --sync对于需实现标准的项目(如leaf-nextjs-convex → LEAF spec):
bash
/spec --import https://github.com/leafspec/spec流程:
- 克隆/拉取spec文件
- 复制到目录
spaces/[project]/docs/specs/ - 创建,包含:
docs/specs/README.md- 源URL与版本
- 最后同步日期
- 合规性检查清单
- 根据spec章节建议初始TASK
同步上游变更:
bash
/spec --sync2b. Create Protocol Spec
2b. 创建协议Spec
For projects that need their own spec (like coordinatr):
bash
/spec --initConversational creation:
- What does this system do? (elevator pitch)
- Who are the actors/users?
- What are the core operations?
- What are the API boundaries?
- What are the data models?
Output structure:
markdown
undefined对于需要自定义spec的项目(如coordinatr):
bash
/spec --init交互式创建流程:
- 该系统的功能是什么?(电梯演讲式描述)
- 参与者/用户有哪些?
- 核心操作包含哪些?
- API边界如何定义?
- 数据模型是什么?
输出结构:
markdown
undefined[Project] Specification
[项目名称] 规范
Overview
概述
[What this system does and why]
[该系统的功能与存在价值]
Actors
参与者
[Who/what interacts with the system]
[与系统交互的对象/角色]
Core Operations
核心操作
[The fundamental things the system must do]
[系统必须实现的基础功能]
API Specification
API规范
[Endpoints, inputs, outputs, errors]
[接口、输入、输出、错误处理]
Data Models
数据模型
[Entity definitions, relationships, constraints]
[实体定义、关系、约束]
Required Features
必备功能
[Feature requirements organized by domain]
[按领域划分的功能需求]
Test Criteria
测试标准
[How to verify compliance]
undefined[如何验证合规性]
undefined3. Spec Status Dashboard
3. Spec状态仪表盘
bash
/spec # No argumentsShows:
- Spec source (external URL or self-authored)
- Last updated/synced
- Sections and their implementation status
- Linked TASKs per section
bash
/spec # 不带参数显示内容:
- Spec来源(外部URL或自定义)
- 最后更新/同步时间
- 各章节及其实现状态
- 每个章节关联的TASK
Spec vs Old "Feature Specs"
Spec与旧版“功能Spec”的对比
| Old Model (Wrong) | New Model (Correct) |
|---|---|
| SPEC-001, SPEC-002... | Single protocol spec |
| Feature breakdown | Requirements contract |
| Internal planning docs | Source of truth |
| Created per feature | Created once, evolved |
| TASKs link to SPEC-### | TASKs implement spec sections |
| 旧模型(错误方式) | 新模型(正确方式) |
|---|---|
| SPEC-001、SPEC-002... | 单一协议spec |
| 功能分解 | 需求契约 |
| 内部规划文档 | 唯一可信来源 |
| 按功能创建 | 一次性创建,逐步演进 |
| TASK关联到SPEC-### | TASK实现spec章节 |
Integration with /issue
与/issue命令的集成
When creating a TASK, link to the spec section it implements:
yaml
---
implements: docs/specs/required-features.md#authentication
---The command will prompt:
/issue"Which spec section does this implement? (or 'none' for standalone)"
创建TASK时,需关联其实现的spec章节:
yaml
---
implements: docs/specs/required-features.md#authentication
---执行命令时会提示:
/issue“该任务实现哪个spec章节?(若为独立任务请输入'none')”
Compliance Tracking
合规性跟踪
Status is tracked inline within spec documents at the requirement level:
markdown
undefined状态在spec文档内内嵌跟踪,精确到需求级别:
markdown
undefined§1 Authentication
§1 认证
Requirements:
- ✅ User registration with email/password
- ✅ User login with JWT token
- ⏳ Password reset flow
- ⏳ Email verification
API Endpoints:
- ✅
POST /api/auth/register - ✅
POST /api/auth/login - ⏳
POST /api/auth/reset-password
**Status markers:**
- ✅ Implemented and working
- 🚧 In progress
- ⏳ Not started
This allows granular visibility into what's done without referencing private TASKs.
The `/complete` command updates these markers when work is finished.需求:
- ✅ 邮箱/密码用户注册
- ✅ JWT令牌用户登录
- ⏳ 密码重置流程
- ⏳ 邮箱验证
API接口:
- ✅
POST /api/auth/register - ✅
POST /api/auth/login - ⏳
POST /api/auth/reset-password
**状态标记:**
- ✅ 已实现且可用
- 🚧 开发中
- ⏳ 未启动
这种方式无需参考私有TASK,即可清晰查看已完成的内容。
当工作完成时,`/complete`命令会更新这些标记。Self-Authored Spec Guidelines
自定义Spec指南
When creating your own protocol spec:
- Be specific - Vague specs lead to vague implementations
- Define boundaries - What's in scope vs out of scope
- Include test criteria - How do you verify compliance?
- Version it - Specs evolve; track changes
- Keep it stable - Changes should be deliberate
创建专属协议spec时需遵循:
- 具体明确 - 模糊的spec会导致模糊的实现
- 定义边界 - 明确范围与非范围
- 包含测试标准 - 如何验证合规性?
- 版本化 - Spec会演进,需跟踪变更
- 保持稳定 - 变更需经过审慎考虑
Spec Versioning (differs from ADRs)
Spec版本控制(与ADR不同)
ADRs are immutable - changes create a new superseding document.
Specs are edited in place - they're living contracts that evolve:
- Frontmatter version - Use semantic versioning ()
version: 1.0.0 - Git history - Preserves full evolution
- Git tags - Mark release points ()
git tag spec-v1.0.0 - CHANGELOG - Note significant spec changes
Version bumps:
- Patch (1.0.1): Typos, clarifications, no behavior change
- Minor (1.1.0): New optional features, backwards compatible
- Major (2.0.0): Breaking changes, removed requirements
This keeps specs simple while git provides the audit trail.
ADR是不可变的 - 变更会创建新的替代文档。
Spec可原地编辑 - 它们是不断演进的活契约:
- 前置元数据版本 - 使用语义化版本()
version: 1.0.0 - Git历史 - 完整保留演进过程
- Git标签 - 标记发布节点()
git tag spec-v1.0.0 - CHANGELOG - 记录重大spec变更
版本升级规则:
- 补丁版本(1.0.1):错别字修正、说明补充,无行为变更
- 次要版本(1.1.0):新增可选功能,保持向后兼容
- 主要版本(2.0.0):破坏性变更、移除需求
这种方式让spec保持简洁,同时Git提供完整的审计轨迹。
Workflow
工作流
/spec --init or --import # Define what to build
↓
/issue # Create work items that implement spec sections
↓
/plan # Break down implementation
↓
/implement # Build against the spec
↓
/complete # Verify spec compliance/spec --init 或 --import # 定义需实现的内容
↓
/issue # 创建实现spec章节的工作项
↓
/plan # 分解实现任务
↓
/implement # 基于spec进行开发
↓
/complete # 验证spec合规性Related Commands
相关命令
- - Create TASKs that implement spec sections
/issue - - Break down implementation of a TASK
/plan - - Check implementation against spec
/validate-spec - - See spec compliance overview
/project-status
- - 创建实现spec章节的TASK
/issue - - 分解TASK的实现细节
/plan - - 检查实现是否符合spec要求
/validate-spec - - 查看spec合规性概览
/project-status