OpenSpec
AI 驱动的规范驱动开发工作流——在写代码之前,让 AI 与你共同定义"要做什么、怎么做"。
README · 项目总览
v3.0 + OPSXOpenSpec
Write better code with less back-and-forth. OpenSpec is an AI-powered, spec-driven development workflow that brings the structure of formal specification to your coding assistant workflow.
Instead of iterating endlessly on what to build, OpenSpec shifts the conversation to "before we code, let's agree on what we're building."
Why OpenSpec?
AI coding assistants are powerful, but they often miss the mark because they lack context, make incorrect assumptions, or skip important edge cases. OpenSpec solves this by creating a shared understanding between you and your AI before any code is written.
Core Problem
- AI writes code based on incomplete understanding
- You spend time correcting and guiding
- Missed edge cases cause rework
- No record of why decisions were made
OpenSpec Approach
- Shared understanding first — Define what you're building together
- Structured exploration — Investigate the problem space before coding
- Documented decisions — Keep a record of intent and reasoning
- Iterative refinement — Evolve specs as you learn
Quick Start
1. Install
npm install -g @fission-ai/openspec
2. Initialize
openspec init
3. Work with your AI
/opsx:propose add-dark-mode # Create a change with all artifacts
/opsx:apply # Implement tasks
/opsx:archive # Finalize and merge specs
Key Concepts
Specs
The source of truth for how your system works. Specs are organized by domain and describe behavior using requirements and scenarios (Given/When/Then format).
Changes
Proposed modifications to your system. Each change is self-contained with:
- proposal.md — Why you're doing this
- specs/ — What you're adding/changing
- design.md — How you'll implement it
- tasks.md — Implementation checklist
Delta Specs
Changes don't modify main specs directly. Instead, they use delta specs that show what was ADDED, MODIFIED, or REMOVED. When archived, these are merged into the main specs.
Commands
| Command | Purpose |
|---|---|
/opsx:propose | Create change + planning artifacts |
/opsx:explore | Think through ideas before committing |
/opsx:apply | Implement tasks |
/opsx:archive | Archive completed change |
Supported Tools
OpenSpec works with Claude Code, Cursor, Windsurf, GitHub Copilot, Amazon Q, Trae, and many more.
OpenSpec · 开放规范
更少的来回沟通,写出更好的代码。OpenSpec 是一个AI 驱动的规范驱动开发工作流,它将正式规格文档的结构引入 AI 辅助编码工作流。
不再无休止地迭代"要做什么",OpenSpec 将对话提前到"写代码之前,让我们先对齐要做什么。"
为什么需要 OpenSpec?
AI 编程助手很强大,但常常偏离目标,因为缺少上下文、做错误的假设、或跳过了重要的边界情况。OpenSpec 通过在写代码之前建立你和 AI 之间的共同理解来解决这个问题。
核心问题
- AI 基于不完整的理解写代码
- 你花大量时间纠正和引导
- 遗漏的边界情况导致返工
- 没有记录决策的原因
OpenSpec 的方法
- 先建立共同理解 — 在动手之前共同定义要做什么
- 结构化探索 — 写代码前先调研问题空间
- 记录决策 — 保留意图和推理的记录
- 迭代优化 — 在学习过程中演进规范
快速开始
1. 安装
npm install -g @fission-ai/openspec
2. 初始化
openspec init
3. 与 AI 协同工作
/opsx:propose add-dark-mode # 创建变更 + 所有产物
/opsx:apply # 执行实现任务
/opsx:archive # 归档并合并规范
核心概念
规范(Specs)
系统如何运作的真相之源。规范按领域组织,使用需求和场景(Given/When/Then 格式)描述行为。
变更(Changes)
对系统的拟议修改。每个变更自包含:
- proposal.md — 为什么要做这件事
- specs/ — 你要添加/修改什么
- design.md — 你打算如何实现
- tasks.md — 实现检查清单
增量规范(Delta Specs)
变更不直接修改主规范,而是使用增量规范来展示新增(ADDED)、修改(MODIFIED)或删除(REMOVED)的内容。归档时,这些会被合并到主规范中。
命令
| 命令 | 用途 |
|---|---|
/opsx:propose | 创建变更 + 规划产物 |
/opsx:explore | 深入思考想法后再决定 |
/opsx:apply | 执行实现任务 |
/opsx:archive | 归档完成的变更 |
支持的工具
OpenSpec 支持 Claude Code、Cursor、Windsurf、GitHub Copilot、Amazon Q、Trae 以及更多。
Getting Started · 入门指南
Getting Started
This guide explains how OpenSpec works after you've installed and initialized it.
How It Works
OpenSpec helps you and your AI coding assistant agree on what to build before any code is written.
Default quick path (core profile):
/opsx:propose ──► /opsx:apply ──► /opsx:archive
Expanded path (custom workflow selection):
/opsx:new ──► /opsx:ff or /opsx:continue ──► /opsx:apply ──► /opsx:verify ──► /opsx:archive
The default global profile is core, which includes propose, explore, apply, and archive. You can enable the expanded workflow commands with openspec config profile and then openspec update.
What OpenSpec Creates
openspec/
├── specs/ # Source of truth (your system's behavior)
│ └── <domain>/
│ └── spec.md
├── changes/ # Proposed updates (one folder per change)
│ └── <change-name>/
│ ├── proposal.md
│ ├── design.md
│ ├── tasks.md
│ └── specs/ # Delta specs (what's changing)
└── config.yaml # Project configuration (optional)
Two key directories:
specs/— The source of truth. These specs describe how your system currently behaves.changes/— Proposed modifications. Each change gets its own folder with all related artifacts. When a change is complete, its specs merge into the mainspecs/directory.
Understanding Artifacts
| Artifact | Purpose |
|---|---|
proposal.md | The "why" and "what" — captures intent, scope, and approach |
specs/ | Delta specs showing ADDED/MODIFIED/REMOVED requirements |
design.md | The "how" — technical approach and architecture decisions |
tasks.md | Implementation checklist with checkboxes |
How Delta Specs Work
Delta specs are the key concept in OpenSpec. They show what's changing relative to your current specs. When you archive a change:
- ADDED requirements are appended to the main spec
- MODIFIED requirements replace the existing version
- REMOVED requirements are deleted from the main spec
Example: Your First Change
Let's walk through adding dark mode to an application.
1. Start the Change
You: /opsx:propose add-dark-mode
AI: Created openspec/changes/add-dark-mode/
✓ proposal.md
✓ specs/ui/spec.md
✓ design.md
✓ tasks.md
Ready for implementation!
2. Implement
You: /opsx:apply
AI: Working through tasks...
✓ 1.1 Created ThemeContext with light/dark state
✓ 1.2 Added CSS custom properties
All tasks complete!
3. Archive
You: /opsx:archive
AI: ✓ Merged specs into openspec/specs/ui/spec.md
✓ Moved to openspec/changes/archive/
Done!
Verifying and Reviewing
openspec list # List active changes
openspec show <name> # View change details
openspec validate # Validate spec formatting
openspec view # Interactive dashboard
入门指南
本指南说明安装并初始化 OpenSpec 后它是如何工作的。
工作原理
OpenSpec 帮助你和你的 AI 编程助手在写任何代码之前就先对齐要做什么。
默认快捷路径(core 配置):
/opsx:propose ──► /opsx:apply ──► /opsx:archive
扩展路径(自定义工作流选择):
/opsx:new ──► /opsx:ff 或 /opsx:continue ──► /opsx:apply ──► /opsx:verify ──► /opsx:archive
默认全局配置为 core,包含 propose、explore、apply 和 archive。你可以通过 openspec config profile 启用扩展工作流命令,然后运行 openspec update。
OpenSpec 创建的内容
openspec/
├── specs/ # 真相之源(系统的行为描述)
│ └── <domain>/
│ └── spec.md
├── changes/ # 提议的更新(每个变更一个文件夹)
│ └── <change-name>/
│ ├── proposal.md
│ ├── design.md
│ ├── tasks.md
│ └── specs/ # Delta Specs(增量规范)
└── config.yaml # 项目配置(可选)
两个核心目录:
specs/— 真相之源。这些规范描述系统当前的行为。changes/— 拟议的修改。每个变更有自己独立的文件夹,包含所有相关产物。变更完成后,其规范会合并到主specs/目录。
理解产物(Artifacts)
| 产物 | 用途 |
|---|---|
proposal.md | "为什么"和"做什么"——捕获意图、范围和方法 |
specs/ | Delta Specs,展示新增/修改/删除的需求 |
design.md | "怎么做"——技术方案和架构决策 |
tasks.md | 带复选框的实现检查清单 |
Delta Specs 的工作原理
Delta Specs(增量规范)是 OpenSpec 的核心概念。它们展示相对于当前规范的变更。归档变更时:
- ADDED(新增)的需求追加到主规范
- MODIFIED(修改)的需求替换现有版本
- REMOVED(删除)的需求从主规范中删除
示例:你的第一个变更
我们以给应用添加深色模式为例走一遍完整流程。
1. 发起变更
你: /opsx:propose add-dark-mode
AI: 创建了 openspec/changes/add-dark-mode/
✓ proposal.md
✓ specs/ui/spec.md
✓ design.md
✓ tasks.md
准备开始实现!
2. 实现
你: /opsx:apply
AI: 正在执行任务...
✓ 1.1 创建了 ThemeContext(light/dark state)
✓ 1.2 添加了 CSS 自定义属性
所有任务完成!
3. 归档
你: /opsx:archive
AI: ✓ 合并规范到 openspec/specs/ui/spec.md
✓ 移动到 openspec/changes/archive/
完成!
验证和审查
openspec list # 列出活跃变更
openspec show <name> # 查看变更详情
openspec validate # 验证规范格式
openspec view # 交互式仪表盘
Commands · 斜杠命令参考
Commands
This is the reference for OpenSpec's slash commands. These commands are invoked in your AI coding assistant's chat interface (e.g., Claude Code, Cursor, Windsurf).
Quick Reference
Default Quick Path (core profile)
| Command | Purpose |
|---|---|
/opsx:propose | Create a change and generate planning artifacts in one step |
/opsx:explore | Think through ideas before committing to a change |
/opsx:apply | Implement tasks from the change |
/opsx:archive | Archive a completed change |
Expanded Workflow Commands
| Command | Purpose |
|---|---|
/opsx:new | Start a new change scaffold |
/opsx:continue | Create the next artifact based on dependencies |
/opsx:ff | Fast-forward: create all planning artifacts at once |
/opsx:verify | Validate implementation matches artifacts |
/opsx:sync | Merge delta specs into main specs (optional) |
/opsx:bulk-archive | Archive multiple changes at once |
/opsx:onboard | Guided tutorial through the complete workflow |
Command Reference
/opsx:propose
Create a new change and generate planning artifacts in one step. This is the default start command in the core profile.
Syntax: /opsx:propose [change-name-or-description]
What it does:
- Creates
openspec/changes/<change-name>/ - Generates artifacts needed before implementation (for
spec-driven: proposal, specs, design, tasks) - Stops when the change is ready for
/opsx:apply
/opsx:explore
Think through ideas, investigate problems, and clarify requirements before committing to a change. Opens an exploratory conversation with no structure required. Investigates the codebase to answer questions. Can transition to /opsx:propose or /opsx:new when insights crystallize.
/opsx:new
Start a new change scaffold. Creates the change folder and waits for you to generate artifacts with /opsx:continue or /opsx:ff. Part of the expanded workflow set (not in default core profile).
/opsx:continue
Create the next artifact in the dependency chain. Creates one artifact at a time for incremental progress. Queries the artifact dependency graph, shows which artifacts are ready vs blocked, reads dependency files for context.
/opsx:ff
Fast-forward through artifact creation. Creates all planning artifacts at once.
/opsx:apply
Implement tasks from the change. Works through the task list, writing code and checking off items. Reads tasks.md and identifies incomplete tasks, works through them one by one, marks tasks complete with checkboxes [x].
/opsx:verify
Validate that implementation matches your change artifacts. Checks three dimensions:
| Dimension | What it validates |
|---|---|
| Completeness | All tasks done, all requirements implemented, scenarios covered |
| Correctness | Implementation matches spec intent, edge cases handled |
| Coherence | Design decisions reflected in code, patterns consistent |
/opsx:archive
Archive a completed change. Finalizes the change and moves it to the archive folder. Checks artifact completion, checks task completion (warns if incomplete), offers to sync delta specs, moves change folder to openspec/changes/archive/YYYY-MM-DD-<name>/.
/opsx:onboard
Guided onboarding through the complete OpenSpec workflow. An interactive tutorial using your actual codebase. Walks through: Welcome → Find opportunity → Create change → Write proposal → Create specs → Write design → Create tasks → Implement → Verify → Archive → Summary.
Command Syntax by AI Tool
| Tool | Syntax |
|---|---|
| Claude Code | /opsx:propose, /opsx:apply |
| Cursor | /opsx-propose, /opsx-apply |
| Windsurf | /opsx-propose, /opsx-apply |
| Trae | Skill-based (e.g., /openspec-propose) |
斜杠命令参考
这是 OpenSpec 斜杠命令的完整参考。这些命令在 AI 编程助手的聊天界面中调用(如 Claude Code、Cursor、Windsurf)。
快速参考
默认快捷路径(core 配置)
| 命令 | 用途 |
|---|---|
/opsx:propose | 一步创建变更并生成所有规划产物 |
/opsx:explore | 深入思考想法后再决定是否发起变更 |
/opsx:apply | 执行变更中的实现任务 |
/opsx:archive | 归档已完成的变更 |
扩展工作流命令
| 命令 | 用途 |
|---|---|
/opsx:new | 搭建新变更脚手架 |
/opsx:continue | 基于依赖关系创建下一个产物 |
/opsx:ff | 快进:一次创建所有规划产物 |
/opsx:verify | 验证实现与产物是否匹配 |
/opsx:sync | 将增量规范合并到主规范(可选) |
/opsx:bulk-archive | 一次归档多个变更 |
/opsx:onboard | 引导式完整工作流教程 |
命令详解
/opsx:propose
一步创建新变更并生成规划产物。这是 core 配置下的默认起始命令。
语法: /opsx:propose [变更名或描述]
功能:
- 创建
openspec/changes/<变更名>/ - 生成实现前所需的产物(
spec-driven模式:proposal、specs、design、tasks) - 在变更准备好进入
/opsx:apply时停止
/opsx:explore
深入思考想法、调研问题、在确定变更前澄清需求。开启无结构约束的探索式对话,调研代码库来回答问题。当洞察清晰时,可转向 /opsx:propose 或 /opsx:new。
/opsx:new
搭建新变更脚手架。创建变更文件夹,然后等待你通过 /opsx:continue 或 /opsx:ff 生成产物。属于扩展工作流集(默认 core 配置不包含)。
/opsx:continue
在依赖链中创建下一个产物。每次创建一个产物,实现渐进式推进。查询产物依赖图,展示哪些产物已就绪/被阻塞,读取依赖文件以获取上下文。
/opsx:ff
快进产物创建。一次创建所有规划产物。
/opsx:apply
执行变更中的实现任务。遍历任务列表,写代码并勾选完成项。读取 tasks.md 并识别未完成的任务,逐个处理,按需写代码、创建文件、运行测试,用复选框 [x] 标记任务完成。
/opsx:verify
验证实现是否符合变更产物。检查三个维度:
| 维度 | 验证内容 |
|---|---|
| 完整性(Completeness) | 所有任务完成,所有需求已实现,场景已覆盖 |
| 正确性(Correctness) | 实现符合规范意图,边界情况已处理 |
| 一致性(Coherence) | 设计决策体现在代码中,模式一致 |
/opsx:archive
归档已完成的变更。完成变更并移动到归档文件夹。检查产物完成状态,检查任务完成情况(未完成会警告),如果尚未同步则提示同步增量规范,将变更文件夹移动到 openspec/changes/archive/YYYY-MM-DD-<名称>/。
/opsx:onboard
引导式入门,完整走一遍 OpenSpec 工作流。使用你真实代码库的交互式教程。流程:欢迎 → 寻找改进点 → 创建变更 → 撰写提案 → 创建规范 → 撰写设计 → 创建任务 → 实现 → 验证 → 归档 → 总结。
各 AI 工具的命令语法
| 工具 | 语法 |
|---|---|
| Claude Code | /opsx:propose, /opsx:apply |
| Cursor | /opsx-propose, /opsx-apply |
| Windsurf | /opsx-propose, /opsx-apply |
| Trae | 基于 Skill 的调用(如 /openspec-propose) |
CLI Reference · 终端命令参考
CLI Reference
The OpenSpec CLI (openspec) provides terminal commands for project setup, validation, status inspection, and management.
Summary
| Category | Commands | Purpose |
|---|---|---|
| Setup | init, update | Initialize and update OpenSpec in your project |
| Browsing | list, view, show | Explore changes and specs |
| Validation | validate | Check changes and specs for issues |
| Lifecycle | archive | Finalize completed changes |
| Workflow | status, instructions, templates, schemas | Artifact-driven workflow support |
| Schemas | schema init/fork/validate/which | Create and manage custom workflows |
| Config | config | View and modify settings |
| Utility | feedback, completion | Feedback and shell integration |
Setup Commands
openspec init
openspec init [path] [options]
Options: --tools <list> (configure AI tools), --force (auto-cleanup legacy), --profile <profile> (override global profile)
Supported tool IDs: claude, cursor, windsurf, github-copilot, amazon-q, trae, gemini, codex, continue, kiro, and many more.
openspec update
Update OpenSpec instruction files after upgrading the CLI.
Browsing Commands
openspec list
Options: --specs, --changes, --sort <order>, --json
openspec view
Display an interactive dashboard for exploring specs and changes.
openspec show
Options: --type <type>, --json, --deltas-only
Validation Commands
openspec validate
Options: --all, --changes, --specs, --strict, --json, --concurrency <n>
Workflow Commands
openspec status
openspec status [options]
Options: --change <id>, --schema <name>, --json
Display artifact completion status for a change. JSON output is used by AI agents to determine next steps.
openspec instructions
Get enriched instructions for creating an artifact or applying tasks. Used by AI agents to understand what to create next.
openspec schemas
List available workflow schemas with their descriptions and artifact flows.
Schema Commands
openspec schema init <name>
Create a new project-local schema.
openspec schema fork <source> [name]
Copy an existing schema to your project for customization.
openspec schema validate [name]
Validate a schema's structure and templates.
openspec schema which [name]
Show where a schema resolves from (useful for debugging precedence).
Schema precedence: Project → User → Package (built-in)
Configuration Commands
openspec config
Subcommands: path, list, get <key>, set <key> <value>, unset <key>, reset, edit, profile [preset]
# Configure profile with action-based wizard
openspec config profile
# Fast preset: switch to core workflows
openspec config profile core
Utility Commands
openspec feedback <message>
Submit feedback about OpenSpec via GitHub issue.
openspec completion <subcommand> [shell]
Subcommands: generate, install, uninstall. Supported shells: bash, zsh, fish, powershell
Environment Variables
| Variable | Description |
|---|---|
OPENSPEC_TELEMETRY | Set to 0 to disable telemetry |
DO_NOT_TRACK | Set to 1 to disable telemetry |
OPENSPEC_CONCURRENCY | Default concurrency for bulk validation (default: 6) |
NO_COLOR | Disable color output when set |
终端命令参考
OpenSpec CLI(openspec)提供项目初始化、验证、状态检查和管理的终端命令。
概览
| 类别 | 命令 | 用途 |
|---|---|---|
| 初始化 | init, update | 在项目中初始化和更新 OpenSpec |
| 浏览 | list, view, show | 探索变更和规范 |
| 验证 | validate | 检查变更和规范的问题 |
| 生命周期 | archive | 完成已完成的变更 |
| 工作流 | status, instructions, templates, schemas | 产物驱动的工作流支持 |
| Schema | schema init/fork/validate/which | 创建和管理自定义工作流 |
| 配置 | config | 查看和修改设置 |
| 工具 | feedback, completion | 反馈和 Shell 集成 |
初始化命令
openspec init
openspec init [path] [options]
选项: --tools <list>(配置 AI 工具),--force(自动清理遗留),--profile <profile>(覆盖全局配置)
支持的工具 ID: claude、cursor、windsurf、github-copilot、amazon-q、trae、gemini、codex、continue、kiro 等。
openspec update
升级 CLI 后更新 OpenSpec 指令文件。
浏览命令
openspec list
选项: --specs、--changes、--sort <order>、--json
openspec view
显示交互式仪表盘,用于探索规范和变更。
openspec show
选项: --type <type>、--json、--deltas-only
验证命令
openspec validate
选项: --all、--changes、--specs、--strict、--json、--concurrency <n>
工作流命令
openspec status
openspec status [options]
选项: --change <id>、--schema <name>、--json
显示变更的产物完成状态。JSON 输出供 AI Agent 判断下一步。
openspec instructions
获取创建产物或执行任务的增强指令。供 AI Agent 理解下一步要创建什么。
openspec schemas
列出可用的工作流 Schema,包含描述和产物流程。
Schema 命令
openspec schema init <name>
创建新的项目级 Schema。
openspec schema fork <source> [name]
将现有 Schema 复制到项目中以便自定义。
openspec schema validate [name]
验证 Schema 的结构和模板。
openspec schema which [name]
显示 Schema 从哪里解析(用于调试优先级)。
Schema 优先级(从高到低): 项目级 → 用户级 → 包内置
配置命令
openspec config
子命令: path、list、get <key>、set <key> <value>、unset <key>、reset、edit、profile [preset]
# 通过向导配置 Profile
openspec config profile
# 快速切换到 core 工作流
openspec config profile core
工具命令
openspec feedback <message>
通过 GitHub Issue 提交 OpenSpec 反馈。
openspec completion <subcommand> [shell]
子命令: generate、install、uninstall。 支持的 Shell: bash、zsh、fish、powershell
环境变量
| 变量 | 说明 |
|---|---|
OPENSPEC_TELEMETRY | 设为 0 禁用遥测 |
DO_NOT_TRACK | 设为 1 禁用遥测 |
OPENSPEC_CONCURRENCY | 批量验证的默认并发数(默认:6) |
NO_COLOR | 设置后禁用彩色输出 |
OPSX Workflow · OPSX 工作流详解
New in v3OPSX Workflow
OPSX is now the standard workflow for OpenSpec. It's a fluid, iterative workflow for OpenSpec changes. No more rigid phases — just actions you can take anytime.
Why This Exists
The legacy OpenSpec workflow works, but it's locked down:
- Instructions are hardcoded — buried in TypeScript, you can't change them
- All-or-nothing — one big command creates everything, can't test individual pieces
- Fixed structure — same workflow for everyone, no customization
- Black box — when AI output is bad, you can't tweak the prompts
OPSX opens it up. Now anyone can:
- Experiment with instructions — edit a template, see if the AI does better
- Test granularly — validate each artifact's instructions independently
- Customize workflows — define your own artifacts and dependencies
- Iterate quickly — change a template, test immediately, no rebuild
The User Experience
The problem with linear workflows: You're "in planning phase", then "in implementation phase", then "done". But real work doesn't work that way.
OPSX approach:
- Actions, not phases — create, implement, update, archive — do any of them anytime
- Dependencies are enablers — they show what's possible, not what's required next
proposal ──→ specs ──→ design ──→ tasks ──→ implement
Commands
| Command | What it does |
|---|---|
/opsx:propose | Create a change and generate planning artifacts in one step (default quick path) |
/opsx:explore | Think through ideas, investigate problems, clarify requirements |
/opsx:new | Start a new change scaffold (expanded workflow) |
/opsx:continue | Create the next artifact (expanded workflow) |
/opsx:ff | Fast-forward planning artifacts (expanded workflow) |
/opsx:apply | Implement tasks, updating artifacts as needed |
/opsx:verify | Validate implementation against artifacts (expanded workflow) |
/opsx:sync | Sync delta specs to main (expanded workflow, optional) |
/opsx:archive | Archive when done |
/opsx:bulk-archive | Archive multiple completed changes (expanded workflow) |
/opsx:onboard | Guided walkthrough of an end-to-end change (expanded workflow) |
When to Update vs. Start Fresh
Update the Existing Change When:
- Same intent, refined execution
- Scope narrows (MVP first approach)
- Learning-driven corrections (codebase isn't structured as expected)
Start a New Change When:
- Intent fundamentally changed
- Scope exploded (essentially different work)
- Original is completable and new work stands alone
The Principle
Update preserves context. New change provides clarity.
Choose update when the history of your thinking is valuable. Choose new when starting fresh would be clearer than patching.
What's Different?
| Legacy | OPSX | |
|---|---|---|
| Structure | One big proposal document | Discrete artifacts with dependencies |
| Workflow | Linear phases: plan → implement → archive | Fluid actions — do anything anytime |
| Iteration | Awkward to go back | Update artifacts as you learn |
| Customization | Fixed structure | Schema-driven (define your own artifacts) |
Architecture Deep Dive
Dependency Graph Model
Artifacts form a directed acyclic graph (DAG). Dependencies are enablers, not gates:
proposal
│
┌─────────────┴─────────────┐
▼ ▼
specs design
(requires: (requires:
proposal) proposal)
│ │
└─────────────┬─────────────┘
▼
tasks
(requires:
specs, design)
│
▼
┌──────────────┐
│ APPLY PHASE │
└──────────────┘
State Transitions
BLOCKED ────────────────► READY ────────────────► DONE
│ │ │
Missing All deps File exists
dependencies are DONE on filesystem
Summary
| Aspect | Legacy | OPSX |
|---|---|---|
| Templates | Hardcoded TypeScript | External YAML + Markdown |
| Dependencies | None (all at once) | DAG with topological sort |
| State | Phase-based mental model | Filesystem existence |
| Customization | Edit source, rebuild | Create schema.yaml |
| Iteration | Phase-locked | Fluid, edit anything |
| Editor Support | Tool-specific configurator/adapters | Single skills directory |
OPSX 工作流
OPSX 现在是 OpenSpec 的标准工作流。它是一个流体式、迭代式的 OpenSpec 变更工作流。没有僵化的阶段——只有随时可执行的操作。
为什么存在这个工作流?
旧的 OpenSpec 工作流能用,但它是封闭的:
- 指令硬编码——埋在 TypeScript 里,你无法修改
- 全有或全无——一条命令创建所有产物,无法单独测试每个部分
- 结构固定——所有人用相同的工作流,无法定制
- 黑箱——当 AI 输出很差时,你无法调整提示词
OPSX 将其打开。现在任何人都可以:
- 实验指令——编辑模板,看 AI 效果是否更好
- 细粒度测试——独立验证每个产物的指令
- 自定义工作流——定义你自己的产物和依赖关系
- 快速迭代——改模板,立即测试,无需重新构建
用户体验
线性工作流的问题:你"处于规划阶段",然后"处于实现阶段",然后"完成了"。但实际工作不是这样的。
OPSX 的方法:
- 操作而非阶段——创建、实现、更新、归档——随时可以做任何事
- 依赖是赋能工具——它们展示什么是可能的,而不是下一步必须做什么
proposal ──► specs ──► design ──► tasks ──► implement
命令
| 命令 | 功能 |
|---|---|
/opsx:propose | 一步创建变更并生成规划产物(默认快捷路径) |
/opsx:explore | 深入思考想法、调研问题、澄清需求 |
/opsx:new | 搭建新变更脚手架(扩展工作流) |
/opsx:continue | 创建下一个产物(扩展工作流) |
/opsx:ff | 快进规划产物(扩展工作流) |
/opsx:apply | 执行任务,按需更新产物 |
/opsx:verify | 根据产物验证实现(扩展工作流) |
/opsx:sync | 同步增量规范到主规范(扩展工作流,可选) |
/opsx:archive | 完成时归档 |
/opsx:bulk-archive | 一次归档多个已完成的变更(扩展工作流) |
/opsx:onboard | 端到端变更的引导式演示(扩展工作流) |
何时更新 vs 重新开始
更新现有变更当:
- 意图相同,执行已优化
- 范围收窄(先做 MVP)
- 学习驱动的修正(代码库结构与预期不符)
发起新变更当:
- 意图根本性改变
- 范围爆炸(本质上变成了不同的工作)
- 原变更可以完成,且新工作独立存在
原则
更新保留上下文。新变更提供清晰度。
当你的思考历程有价值时选择更新。当重新开始比打补丁更清晰时选择新变更。
有什么不同?
| 旧版 | OPSX | |
|---|---|---|
| 结构 | 一个大提案文档 | 有依赖关系的离散产物 |
| 工作流 | 线性阶段:规划 → 实现 → 归档 | 流体操作——随时做任意事 |
| 迭代 | 难以回头 | 在学习过程中更新产物 |
| 定制 | 固定结构 | Schema 驱动(可定义自己的产物) |
架构深入解析
依赖图模型
产物形成一个有向无环图(DAG)。依赖是赋能工具,不是关卡:
proposal
│
┌─────────────┴─────────────┐
▼ ▼
specs design
(依赖: (依赖:
proposal) proposal)
│ │
└─────────────┬─────────────┘
▼
tasks
(依赖:
specs, design)
│
▼
┌──────────────┐
│ 应用阶段 │
└──────────────┘
状态转换
BLOCKED ────────────────► READY ────────────────► DONE
│ │ │
缺少依赖 所有依赖 文件存在于
满足 已完成 文件系统
总结
| 方面 | 旧版 | OPSX |
|---|---|---|
| 模板 | 硬编码 TypeScript | 外部 YAML + Markdown |
| 依赖 | 无(一次全部) | 带拓扑排序的 DAG |
| 状态 | 基于阶段的心理模型 | 基于文件系统存在性 |
| 定制 | 编辑源码,重新构建 | 创建 schema.yaml |
| 迭代 | 阶段锁定 | 流体式,可编辑任何内容 |
| 编辑器支持 | 工具特定的配置器/适配器 | 单一 skills 目录 |
Workflows · 工作流模式
Workflows
This guide covers common patterns and when to use each OpenSpec command.
Two Workflow Profiles
Core Profile (Default)
The fastest end-to-end path. Four commands cover the full lifecycle:
/opsx:propose ──► /opsx:apply ──► /opsx:archive
Use when: You know what you want to build. You want the fastest path from idea to implemented code.
Expanded Profile (Custom Workflow Selection)
Granular control over each artifact. More commands, more flexibility:
/opsx:new ──► /opsx:continue (or /opsx:ff) ──► /opsx:apply ──► /opsx:verify ──► /opsx:archive
Use when: You want to review each artifact before creating the next. You're exploring or the scope is unclear.
Choosing the Right Path
Start with /opsx:explore when:
- Requirements are unclear
- You're evaluating multiple approaches
- You need to investigate the codebase first
- The change is large or complex
Use /opsx:propose or /opsx:ff when:
- You have a clear picture of what you're building
- Scope is well-defined
- You want the fastest path
Use /opsx:continue when:
- You want to review each artifact
- The change is complex and you want control
- You may need to adjust earlier artifacts
Multi-Change Management
You can work on multiple changes in parallel. Use change names to direct commands:
/opsx:apply add-auth # Apply auth change
/opsx:apply fix-ui-bug # Switch to different change
Use openspec list to see all active changes and their status.
Tips
- Use
/opsx:explorebefore/opsx:proposefor complex changes - During
/opsx:apply, if specs are wrong — update them and continue - Run
/opsx:verifybefore/opsx:archiveto catch issues - Use
openspec statusto check progress anytime
工作流模式
本指南涵盖常见模式及每个 OpenSpec 命令的使用时机。
两种工作流配置
Core 配置(默认)
最快的端到端路径。四个命令覆盖完整生命周期:
/opsx:propose ──► /opsx:apply ──► /opsx:archive
适用场景:你清楚要做什么。想从想法到已实现代码的最快路径。
Expanded 配置(自定义工作流选择)
对每个产物的细粒度控制。更多命令,更多灵活性:
/opsx:new ──► /opsx:continue (或 /opsx:ff) ──► /opsx:apply ──► /opsx:verify ──► /opsx:archive
适用场景:你想在创建下一个产物前审查每个产物。正在探索或范围不明确。
选择正确的路径
从 /opsx:explore 开始当:
- 需求不明确
- 正在评估多种方案
- 需要先调研代码库
- 变更规模大或复杂
使用 /opsx:propose 或 /opsx:ff 当:
- 你清楚要做什么
- 范围定义明确
- 想要最快路径
使用 /opsx:continue 当:
- 想审查每个产物
- 变更复杂,想要控制权
- 可能需要调整之前的产物
多变更管理
你可以并行处理多个变更。用变更名来引导命令:
/opsx:apply add-auth # 执行 auth 变更
/opsx:apply fix-ui-bug # 切换到另一个变更
用 openspec list 查看所有活跃变更及其状态。
技巧
- 复杂变更先用
/opsx:explore再用/opsx:propose - 执行
/opsx:apply时,如果规范有误——更新它们然后继续 - 归档前运行
/opsx:verify以发现问题 - 随时用
openspec status检查进度
Concepts · 核心概念
Concepts
This document explains the core concepts that power OpenSpec.
Specs
Specs are the source of truth for how your system works. They're organized by domain and written in a structured format.
Structure
Each spec file covers a domain and contains:
- Requirements — What the system must do (using MUST/SHALL keywords)
- Scenarios — Concrete examples using Given/When/Then format
Requirements Keywords
- MUST — Absolute requirement (system failure if not met)
- SHALL — Important requirement (should work but not fatal)
- Should — Recommendation (nice to have)
- May — Optional feature
Scenario Format
#### Scenario: [name]
- GIVEN [precondition]
- WHEN [action]
- THEN [expected outcome]
- AND [additional outcome]
Changes
A change is a proposed modification to your system. It's a self-contained folder that contains everything about that change:
- What you're doing (proposal)
- What you're adding/changing (delta specs)
- How you'll do it (design)
- What needs to be done (tasks)
Change Lifecycle
created ──► in-progress ──► completed ──► archived
│ │ │ │
/opsx:new /opsx:apply /opsx:verify /opsx:archive
Delta Specs
Changes don't modify main specs directly. Instead, they use delta specs that show:
- ADDED — New requirements being introduced
- MODIFIED — Existing requirements being changed
- REMOVED — Requirements being deleted
When archived, delta specs are merged into the main specs.
Schemas
Schemas define the structure of a change — what artifacts exist and how they depend on each other.
The default schema is spec-driven: proposal → specs → design → tasks → implement
You can create custom schemas for different workflows.
Artifacts
| Artifact | File | Purpose |
|---|---|---|
| Proposal | proposal.md | Why — intent, scope, approach |
| Specs | specs/**/*.md | What — delta requirements |
| Design | design.md | How — technical approach |
| Tasks | tasks.md | Do — implementation checklist |
Project Configuration
Project config (openspec/config.yaml) lets you customize how artifacts are generated:
- Schema — Default schema for new changes
- Context — Project-specific info injected into all artifacts
- Rules — Per-artifact instructions (e.g., "use Given/When/Then for specs")
核心概念
本文档解释驱动 OpenSpec 的核心概念。
规范(Specs)
规范是系统如何运作的真相之源。它们按领域组织,以结构化格式编写。
结构
每个规范文件覆盖一个领域,包含:
- 需求(Requirements) — 系统必须做什么(使用 MUST/SHALL 关键词)
- 场景(Scenarios) — 使用 Given/When/Then 格式的具体示例
需求关键词
- MUST — 绝对需求(不满足则系统故障)
- SHALL — 重要需求(不满足但非致命)
- Should — 建议(最好有)
- May — 可选功能
场景格式
#### Scenario: [名称]
- GIVEN [前置条件]
- WHEN [动作]
- THEN [预期结果]
- AND [附加结果]
变更(Changes)
变更是对系统拟议的修改。它是一个自包含的文件夹,包含该变更的所有内容:
- 你要做什么(proposal)
- 你要添加/修改什么(delta specs)
- 你打算怎么做(design)
- 需要做什么(tasks)
变更生命周期
created ──► in-progress ──► completed ──► archived
│ │ │ │
/opsx:new /opsx:apply /opsx:verify /opsx:archive
Delta Specs(增量规范)
变更不直接修改主规范,而是使用增量规范来展示:
- ADDED(新增) — 正在引入的新需求
- MODIFIED(修改) — 正在被修改的现有需求
- REMOVED(删除) — 正在被删除的需求
归档时,增量规范会被合并到主规范中。
Schema
Schema 定义变更的结构——存在哪些产物以及它们如何相互依赖。
默认 Schema 是 spec-driven:proposal → specs → design → tasks → implement
你可以为不同工作流创建自定义 Schema。
产物(Artifacts)
| 产物 | 文件 | 用途 |
|---|---|---|
| Proposal(提案) | proposal.md | 为什么做——意图、范围、方法 |
| Specs(规范) | specs/**/*.md | 做什么——增量需求 |
| Design(设计) | design.md | 怎么做——技术方案 |
| Tasks(任务) | tasks.md | 做什么——实现检查清单 |
项目配置
项目配置(openspec/config.yaml)让你自定义产物的生成方式:
- Schema — 新变更的默认 Schema
- Context — 注入到所有产物的项目特定信息
- Rules — 每种产物的指令(如"规范使用 Given/When/Then")
Customization · 自定义配置
Customization
OpenSpec is designed to be customized. You can modify templates, create custom schemas, and configure project-specific rules.
Project Configuration
Create or edit openspec/config.yaml in your project root:
schema: spec-driven
context: |
Tech stack: TypeScript, React, Node.js
API conventions: RESTful, JSON responses
Testing: Vitest for unit tests, Playwright for e2e
rules:
proposal:
- Include rollback plan
- Identify affected teams
specs:
- Use Given/When/Then format for scenarios
- Cover happy path and edge cases
design:
- Include sequence diagrams for complex flows
- Document error handling approach
Custom Schemas
Schemas define what artifacts exist and their dependencies. You can create custom schemas for different workflows.
Create a Schema
# Interactive creation
openspec schema init my-workflow
# Or fork an existing one
openspec schema fork spec-driven my-workflow
Schema Structure
openspec/schemas/my-workflow/
├── schema.yaml
└── templates/
├── proposal.md
├── specs.md
├── design.md
└── tasks.md
schema.yaml Format
name: my-workflow
description: Custom workflow for rapid iteration
artifacts:
- id: proposal
generates: proposal.md
requires: []
- id: tasks
generates: tasks.md
requires: [proposal]
Template Variables
Templates can use these variables that get replaced at generation time:
{{changeName}}— Name of the change{{date}}— Current date{{author}}— User running the command{{schema}}— Schema name
Context Injection
Context from config.yaml is prepended to every artifact's instructions, wrapped in <context>...</context> tags. This helps AI understand your project's conventions.
Per-Artifact Rules
Rules in config.yaml are injected per-artifact, wrapped in <rules>...</rules> tags. They appear after context, before the template.
自定义配置
OpenSpec 设计为可自定义的。你可以修改模板、创建自定义 Schema、配置项目特定规则。
项目配置
在项目根目录创建或编辑 openspec/config.yaml:
schema: spec-driven
context: |
Tech stack: TypeScript, React, Node.js
API conventions: RESTful, JSON responses
Testing: Vitest for unit tests, Playwright for e2e
rules:
proposal:
- Include rollback plan
- Identify affected teams
specs:
- Use Given/When/Then format for scenarios
- Cover happy path and edge cases
design:
- Include sequence diagrams for complex flows
- Document error handling approach
自定义 Schema
Schema 定义存在哪些产物及其依赖关系。你可以为不同工作流创建自定义 Schema。
创建 Schema
# 交互式创建
openspec schema init my-workflow
# 或基于现有 Schema 派生
openspec schema fork spec-driven my-workflow
Schema 结构
openspec/schemas/my-workflow/
├── schema.yaml
└── templates/
├── proposal.md
├── specs.md
├── design.md
└── tasks.md
schema.yaml 格式
name: my-workflow
description: Custom workflow for rapid iteration
artifacts:
- id: proposal
generates: proposal.md
requires: []
- id: tasks
generates: tasks.md
requires: [proposal]
模板变量
模板可使用在生成时被替换的变量:
{{changeName}}— 变更名称{{date}}— 当前日期{{author}}— 运行命令的用户{{schema}}— Schema 名称
上下文注入
config.yaml 中的上下文被预先添加到每个产物的指令中,用 <context>...</context> 标签包裹。这帮助 AI 理解你项目的规范,而无需在每次变更中重复。
每产物规则
config.yaml 中的规则被按产物注入,用 <rules>...</rules> 标签包裹。它们出现在上下文之后、模板之前。
Multi-Language · 多语言支持
Multi-Language Support
OpenSpec supports multiple natural languages for specs, commands, and documentation.
Spec Languages
Specs can be written in any language. The AI coding assistant will work with your specs in whatever language they're written.
Supported Languages
- English (default)
- Chinese (中文)
- Japanese (日本語)
- Korean (한국어)
- And any other language your AI tool supports
Configuration
Set your preferred language in openspec/config.yaml:
specLanguage: zh-CN # or en, ja, ko, etc.
When set, artifact templates and validation messages will use the specified language.
Command Localization
Slash commands are currently English-only (/opsx:propose, /opsx:apply, etc.), regardless of spec language. This is intentional to maintain consistency across teams using different languages.
Best Practices
- Be consistent — pick one language per project
- Consider your team — choose a language everyone reads
- Spec language is independent of code language
多语言支持
OpenSpec 支持多种自然语言的规范、命令和文档。
规范语言
规范可以用任何语言编写。AI 编程助手将使用你编写的语言来处理规范。
支持的语言
- English(默认)
- Chinese(中文)
- Japanese(日语)
- Korean(韩语)
- 以及你的 AI 工具支持的任何其他语言
配置
在 openspec/config.yaml 中设置首选语言:
specLanguage: zh-CN # 或 en, ja, ko 等
设置后,产物模板和验证消息将使用指定语言。
命令本地化
斜杠命令目前仅支持英语(/opsx:propose、/opsx:apply 等),与规范语言无关。这样做是为了保持使用不同语言的团队之间的一致性。
最佳实践
- 保持一致——每个项目选择一种语言
- 考虑你的团队——选择每个人都读得懂的语言
- 规范语言与代码语言独立
Supported Tools · 支持的 AI 工具
Supported Tools
OpenSpec works with a growing list of AI coding assistants and tools.
Full Support (Skills + Commands)
| Tool | Skills | Commands | Notes |
|---|---|---|---|
| Claude Code | ✓ | ✓ | Recommended. Full integration. |
| Cursor | ✓ | ✓ | Full support via skills + commands |
| Windsurf | ✓ | ✓ | Full support via skills + commands |
Skills Support
| Tool | Skills | Notes |
|---|---|---|
| GitHub Copilot | ✓ | IDE only (VS Code, JetBrains, Visual Studio). CLI not supported. |
| Amazon Q | ✓ | Skills support |
| Trae | ✓ | Skill-based invocations (e.g., /openspec-propose) |
| Continue | ✓ | OpenAI, Claude, Gemini, local models |
| Kiro | ✓ | AI coding assistant |
| Codex | ✓ | OpenAI's coding assistant |
| Gemini | ✓ | Google's AI assistant |
Installation
When you run openspec init, it auto-detects your installed tools and generates the appropriate configuration files.
# Or specify tools explicitly
openspec init --tools claude,cursor,windsurf
Command Syntax by Tool
| Tool | Syntax |
|---|---|
| Claude Code | /opsx:propose, /opsx:apply |
| Cursor | /opsx-propose, /opsx-apply |
| Windsurf | /opsx-propose, /opsx-apply |
| Trae | Skill-based invocations |
支持的 AI 工具
OpenSpec 支持越来越多的 AI 编程助手和工具。
完整支持(Skills + Commands)
| 工具 | Skills | Commands | 备注 |
|---|---|---|---|
| Claude Code | ✓ | ✓ | 推荐。完整集成。 |
| Cursor | ✓ | ✓ | 通过 skills + commands 完整支持 |
| Windsurf | ✓ | ✓ | 通过 skills + commands 完整支持 |
Skills 支持
| 工具 | Skills | 备注 |
|---|---|---|
| GitHub Copilot | ✓ | 仅 IDE(VS Code、JetBrains、Visual Studio)。CLI 不支持。 |
| Amazon Q | ✓ | Skills 支持 |
| Trae | ✓ | 基于 Skill 的调用(如 /openspec-propose) |
| Continue | ✓ | 支持 OpenAI、Claude、Gemini、本地模型 |
| Kiro | ✓ | AI 编程助手 |
| Codex | ✓ | OpenAI 的编程助手 |
| Gemini | ✓ | Google 的 AI 助手 |
安装
当你运行 openspec init 时,它会自动检测你已安装的工具并生成相应的配置文件。
# 或显式指定工具
openspec init --tools claude,cursor,windsurf
各工具的命令语法
| 工具 | 语法 |
|---|---|
| Claude Code | /opsx:propose, /opsx:apply |
| Cursor | /opsx-propose, /opsx-apply |
| Windsurf | /opsx-propose, /opsx-apply |
| Trae | 基于 Skill 的调用 |