🌱 Spec Kit
更快地构建高质量软件。
一个开源工具包,让你专注于产品场景与可预期的产出,而不是从零开始“凭感觉写代码(vibe coding)”。
目录
- 🤔 什么是规范驱动开发(Spec-Driven Development)?
- ⚡ 快速开始
- 📽️ 视频概览
- 🤖 支持的 AI 代理
- 🔧 Specify CLI 参考
- 📚 核心理念
- 🌟 开发阶段
- 🎯 实验目标
- 🔧 先决条件
- 📖 进一步阅读
- 📋 详细流程
- 🔍 故障排查
- 👥 维护者
- 💬 支持
- 🙏 致谢
- 📄 许可证
🤔 什么是规范驱动开发(Spec-Driven Development)?
规范驱动开发(Spec-Driven Development)颠覆了传统软件开发的叙事。多年来,代码一直是“王者”——规范只是脚手架:在“真正的工作”(编码)开始后,我们就把它丢在一边。规范驱动开发改变了这一点:规范变得可执行,它们不只是指导实现,而是可以直接生成可工作的实现。
⚡ 快速开始
1. 安装 Specify CLI
选择你偏好的安装方式:
方案 1:常驻安装(推荐)
一次安装,随处使用:
uv tool install specify-cli --from git+https://github.com/github/spec-kit.git然后直接使用该工具:
# 创建新项目
specify init <PROJECT_NAME>
# 或在现有项目中初始化
specify init . --ai claude
# 或
specify init --here --ai claude
# 检查已安装工具
specify check要升级 Specify,请参阅更详细的 升级指南。快速升级:
uv tool install specify-cli --force --from git+https://github.com/github/spec-kit.git方案 2:一次性使用
无需安装,直接运行:
uvx --from git+https://github.com/github/spec-kit.git specify init <PROJECT_NAME>常驻安装的优势:
- 工具保持安装状态并可在 PATH 中直接调用
- 无需创建 shell 别名
- 借助
uv tool list、uv tool upgrade、uv tool uninstall更好地管理工具 - Shell 配置更简洁
2. 建立项目原则
在项目目录中启动你的 AI 助手。助手中会提供 /speckit.* 命令。
使用 /speckit.constitution 命令创建项目的治理原则与开发指南,以指导后续所有开发。
/speckit.constitution Create principles focused on code quality, testing standards, user experience consistency, and performance requirements3. 创建规范(Spec)
使用 /speckit.specify 命令描述你要构建的内容。聚焦 做什么(what) 与 为什么(why),而不是技术栈。
/speckit.specify Build an application that can help me organize my photos in separate photo albums. Albums are grouped by date and can be re-organized by dragging and dropping on the main page. Albums are never in other nested albums. Within each album, photos are previewed in a tile-like interface.4. 创建技术实现计划
使用 /speckit.plan 命令提供你的技术栈与架构选择。
/speckit.plan The application uses Vite with minimal number of libraries. Use vanilla HTML, CSS, and JavaScript as much as possible. Images are not uploaded anywhere and metadata is stored in a local SQLite database.5. 拆分任务
使用 /speckit.tasks 根据你的实现计划生成可执行的任务列表。
/speckit.tasks6. 执行实现
使用 /speckit.implement 按计划执行所有任务并构建功能。
/speckit.implement如需更详细的分步说明,请参阅 完整指南。
📽️ 视频概览
想看看 Spec Kit 的实际演示?观看我们的 视频概览!
🤖 支持的 AI 代理
| Agent | 支持情况 | 备注 |
|---|---|---|
| Qoder CLI | ✅ | |
| Amazon Q Developer CLI | ⚠️ | Amazon Q Developer CLI 不支持 为斜杠命令传入自定义参数。 |
| Amp | ✅ | |
| Auggie CLI | ✅ | |
| Claude Code | ✅ | |
| CodeBuddy CLI | ✅ | |
| Codex CLI | ✅ | |
| Cursor | ✅ | |
| Gemini CLI | ✅ | |
| GitHub Copilot | ✅ | |
| IBM Bob | ✅ | 基于 IDE 的代理,支持斜杠命令 |
| Jules | ✅ | |
| Kilo Code | ✅ | |
| opencode | ✅ | |
| Qwen Code | ✅ | |
| Roo Code | ✅ | |
| SHAI (OVHcloud) | ✅ | |
| Windsurf | ✅ |
🔧 Specify CLI 参考
specify 命令支持以下选项:
命令
| 命令 | 说明 |
|---|---|
init |
从最新模板初始化一个新的 Specify 项目 |
check |
检查已安装工具(git、claude、gemini、code/code-insiders、cursor-agent、windsurf、qwen、opencode、codex、shai、qoder) |
specify init 参数与选项
| 参数/选项 | 类型 | 说明 |
|---|---|---|
<project-name> |
参数 | 新项目目录名(若使用 --here 可选,也可用 . 表示当前目录) |
--ai |
选项 | 选择使用的 AI 助手:claude、gemini、copilot、cursor-agent、qwen、opencode、codex、windsurf、kilocode、auggie、roo、codebuddy、amp、shai、q、bob 或 qoder |
--script |
选项 | 选择脚本版本:sh(bash/zsh)或 ps(PowerShell) |
--ignore-agent-tools |
标志 | 跳过对 Claude Code 等 AI 代理工具的检查 |
--no-git |
标志 | 跳过 Git 仓库初始化 |
--here |
标志 | 在当前目录初始化项目,而不是创建新目录 |
--force |
标志 | 在当前目录初始化时强制合并/覆盖(跳过确认) |
--skip-tls |
标志 | 跳过 SSL/TLS 校验(不推荐) |
--debug |
标志 | 输出更详细的调试信息,用于排障 |
--github-token |
选项 | GitHub API 请求使用的 Token(或设置 GH_TOKEN/GITHUB_TOKEN 环境变量) |
示例
# 基础初始化
specify init my-project
# 指定 AI 助手初始化
specify init my-project --ai claude
# 初始化并启用 Cursor 支持
specify init my-project --ai cursor-agent
# 初始化并启用 Qoder 支持
specify init my-project --ai qoder
# 初始化并启用 Windsurf 支持
specify init my-project --ai windsurf
# 初始化并启用 Amp 支持
specify init my-project --ai amp
# 初始化并启用 SHAI 支持
specify init my-project --ai shai
# 初始化并启用 IBM Bob 支持
specify init my-project --ai bob
# 使用 PowerShell 脚本(Windows/跨平台)
specify init my-project --ai copilot --script ps
# 在当前目录初始化
specify init . --ai copilot
# 或使用 --here 标志
specify init --here --ai copilot
# 将模板强制合并到当前(非空)目录,跳过确认
specify init . --force --ai copilot
# 或
specify init --here --force --ai copilot
# 跳过 git 初始化
specify init my-project --ai gemini --no-git
# 排障:输出调试信息
specify init my-project --ai claude --debug
# 企业环境中可使用 GitHub Token(API 请求)
specify init my-project --ai claude --github-token ghp_your_token_here
# 检查系统要求
specify check可用斜杠命令
运行 specify init 后,你的 AI 编程代理将获得这些结构化开发所需的斜杠命令:
核心命令
SDD 工作流的关键命令:
| 命令 | 说明 |
|---|---|
/speckit.constitution |
创建或更新项目治理原则与开发指南 |
/speckit.specify |
定义你要构建的内容(需求与用户故事) |
/speckit.plan |
基于你选择的技术栈生成技术实现计划 |
/speckit.tasks |
生成可执行的任务列表,用于实现 |
/speckit.implement |
按计划执行所有任务并构建功能 |
可选命令
用于增强质量与验证的补充命令:
| 命令 | 说明 |
|---|---|
/speckit.clarify |
澄清规范中未充分说明的内容(建议在 /speckit.plan 之前运行;原名 /quizme) |
/speckit.analyze |
交叉检查工件一致性与覆盖度(建议在 /speckit.tasks 之后、/speckit.implement 之前运行) |
/speckit.checklist |
生成定制质量清单,用于验证需求完整性、清晰度与一致性(类似“英文的单元测试”) |
环境变量
| 变量 | 说明 |
|---|---|
SPECIFY_FEATURE |
为非 Git 仓库覆盖特性检测。将其设置为特性目录名(例如 001-photo-albums),以便在不使用 Git 分支时也能在特定特性上工作。**必须在你所使用的代理运行环境中提前设置,再使用 /speckit.plan 或后续命令。 |
📚 核心理念
规范驱动开发是一套结构化过程,强调:
- 意图驱动开发:先用规范定义“做什么(what)”,再讨论“怎么做(how)”
- 高质量规范产出:借助约束与组织原则(guardrails & principles)形成可复用、可审查的规范
- 多轮迭代完善:不是“一次性提示词”生成,而是多步骤逐层细化
- 强依赖先进模型能力:利用更强 AI 模型对规范的理解与推理能力
🌟 开发阶段
| 阶段 | 关注点 | 关键活动 |
|---|---|---|
| 0→1 开发(Greenfield) | 从零生成 |
|
| 创意探索 | 并行实现 |
|
| 迭代增强(Brownfield) | 既有系统改造/演进 |
|
🎯 实验目标
我们的研究与实验聚焦于:
技术无关性
- 使用多样的技术栈构建应用
- 验证一个假设:规范驱动开发是一种流程方法,而不是绑定特定技术、语言或框架
企业约束
- 证明可用于关键业务系统的应用开发
- 纳入组织约束(云厂商、技术栈、工程实践)
- 支持企业设计系统与合规要求
用户中心开发
- 面向不同用户群体与偏好构建应用
- 支持多种开发风格(从 vibe-coding 到 AI-native 开发)
创意与迭代流程
- 验证“并行实现探索”的概念
- 提供稳健的迭代式功能开发工作流
- 扩展流程以覆盖升级与现代化改造任务
🔧 先决条件
- Linux/macOS/Windows
- 一个 支持的 AI 编程代理
- 用于包管理的 uv
- Python 3.11+
- Git
如果你在使用某个代理时遇到问题,请提 issue,帮助我们改进集成。
📖 进一步阅读
- 完整的规范驱动开发方法论 - 深入理解完整流程
- 详细演练 - 分步实施指南
📋 详细流程
点击展开详细的分步演练
你可以使用 Specify CLI 为项目引导初始化,它会将必要的工件引入你的环境。运行:
specify init <project_name>
或在当前目录初始化:
specify init .
# 或使用 --here 标志
specify init --here
# 当目录已有文件时跳过确认
specify init . --force
# 或
specify init --here --force

CLI 会提示你选择正在使用的 AI 代理。你也可以直接在终端中主动指定:
specify init <project_name> --ai claude
specify init <project_name> --ai gemini
specify init <project_name> --ai copilot
# 或在当前目录:
specify init . --ai claude
specify init . --ai codex
# 或使用 --here 标志
specify init --here --ai claude
specify init --here --ai codex
# 强制合并到非空的当前目录
specify init . --force --ai claude
# 或
specify init --here --force --ai claude
CLI 会检查你是否安装了 Claude Code、Gemini CLI、Cursor CLI、Qwen CLI、opencode、Codex CLI、Qoder CLI 或 Amazon Q Developer CLI。如果你未安装,或者你希望在不检查工具的情况下获取模板,请在命令中使用 --ignore-agent-tools:
specify init <project_name> --ai claude --ignore-agent-tools
第 1 步: 建立项目原则
进入项目文件夹并运行你的 AI 代理。示例中我们使用 claude。

如果你看到 /speckit.constitution、/speckit.specify、/speckit.plan、/speckit.tasks 和 /speckit.implement 命令可用,说明配置正确。
第一步应该使用 /speckit.constitution 建立项目的治理原则。这有助于在后续所有开发阶段保持决策一致性:
/speckit.constitution Create principles focused on code quality, testing standards, user experience consistency, and performance requirements. Include governance for how these principles should guide technical decisions and implementation choices.
此步骤会创建或更新 .specify/memory/constitution.md 文件,作为项目的基础指南;AI 代理会在规范、规划与实现阶段引用它。
第 2 步: 创建项目规范
有了项目原则后,就可以创建功能规范。使用 /speckit.specify 命令,并提供你要开发项目的具体需求。
[!IMPORTANT]
请尽可能明确说明你要构建的 是什么(what) 和 为什么(why)。此时不要关注技术栈。
示例提示词:
Develop Taskify, a team productivity platform. It should allow users to create projects, add team members,
assign tasks, comment and move tasks between boards in Kanban style. In this initial phase for this feature,
let's call it "Create Taskify," let's have multiple users but the users will be declared ahead of time, predefined.
I want five users in two different categories, one product manager and four engineers. Let's create three
different sample projects. Let's have the standard Kanban columns for the status of each task, such as "To Do,"
"In Progress," "In Review," and "Done." There will be no login for this application as this is just the very
first testing thing to ensure that our basic features are set up. For each task in the UI for a task card,
you should be able to change the current status of the task between the different columns in the Kanban work board.
You should be able to leave an unlimited number of comments for a particular card. You should be able to, from that task
card, assign one of the valid users. When you first launch Taskify, it's going to give you a list of the five users to pick
from. There will be no password required. When you click on a user, you go into the main view, which displays the list of
projects. When you click on a project, you open the Kanban board for that project. You're going to see the columns.
You'll be able to drag and drop cards back and forth between different columns. You will see any cards that are
assigned to you, the currently logged in user, in a different color from all the other ones, so you can quickly
see yours. You can edit any comments that you make, but you can't edit comments that other people made. You can
delete any comments that you made, but you can't delete comments anybody else made.
输入该提示后,你应该会看到 Claude Code 开始规划与起草规范。Claude Code 也会触发部分内置脚本来初始化仓库。
完成该步骤后,你应该会得到一个新分支(例如 001-create-taskify),以及位于 specs/001-create-taskify 目录下的新规范。
生成的规范应当包含模板所定义的一组用户故事与功能需求。
此时你的项目目录结构应类似于:
└── .specify
├── memory
│ └── constitution.md
├── scripts
│ ├── check-prerequisites.sh
│ ├── common.sh
│ ├── create-new-feature.sh
│ ├── setup-plan.sh
│ └── update-claude-md.sh
├── specs
│ └── 001-create-taskify
│ └── spec.md
└── templates
├── plan-template.md
├── spec-template.md
└── tasks-template.md
第 3 步: 功能规范澄清(规划前必须)
有了基础规范后,你可以进一步澄清第一轮生成中没有捕捉准确的需求点。
建议在生成技术计划 之前 运行结构化澄清流程,以减少后续返工。
推荐顺序:
- 使用
/speckit.clarify(结构化)——按覆盖度逐步提问,并将答案记录在 Clarifications 部分。 - 若仍有模糊点,可继续用自由形式进行补充与精炼。
如果你有意跳过澄清(例如做 spike 或探索性原型),请明确说明,以免代理被缺失澄清阻塞。
自由形式精炼提示示例(若 /speckit.clarify 后仍需补充):
For each sample project or project that you create there should be a variable number of tasks between 5 and 15
tasks for each one randomly distributed into different states of completion. Make sure that there's at least
one task in each stage of completion.
你也可以让 Claude Code 验证 Review & Acceptance Checklist:对满足要求的条目打勾,不满足的保留未勾选。可使用如下提示:
Read the review and acceptance checklist, and check off each item in the checklist if the feature spec meets the criteria. Leave it empty if it does not.
把与 Claude Code 的互动当作澄清与提问的机会——不要把它的第一版输出当作最终版本。
第 4 步: 生成技术计划
现在你可以更具体地描述技术栈与其他技术要求。使用 /speckit.plan 命令,并提供类似这样的提示:
We are going to generate this using .NET Aspire, using Postgres as the database. The frontend should use
Blazor server with drag-and-drop task boards, real-time updates. There should be a REST API created with a projects API,
tasks API, and a notifications API.
该步骤输出会包含若干实现细节文档,你的目录结构将类似于:
.
├── CLAUDE.md
├── memory
│ └── constitution.md
├── scripts
│ ├── check-prerequisites.sh
│ ├── common.sh
│ ├── create-new-feature.sh
│ ├── setup-plan.sh
│ └── update-claude-md.sh
├── specs
│ └── 001-create-taskify
│ ├── contracts
│ │ ├── api-spec.json
│ │ └── signalr-spec.md
│ ├── data-model.md
│ ├── plan.md
│ ├── quickstart.md
│ ├── research.md
│ └── spec.md
└── templates
├── CLAUDE-template.md
├── plan-template.md
├── spec-template.md
└── tasks-template.md
检查 research.md,确保采用了符合你指令的技术栈。如果某些组件显得不合适,你可以要求 Claude Code 进一步调整;也可以让它检查你本机安装的平台/框架版本(例如 .NET)。
另外,如果你选择的技术栈变化很快(例如 .NET Aspire、JS 框架),你也可以让 Claude Code 做更有针对性的调研,示例提示:
I want you to go through the implementation plan and implementation details, looking for areas that could
benefit from additional research as .NET Aspire is a rapidly changing library. For those areas that you identify that
require further research, I want you to update the research document with additional details about the specific
versions that we are going to be using in this Taskify application and spawn parallel research tasks to clarify
any details using research from the web.
在此过程中,你可能会发现 Claude Code 卡在“调研错方向”上——可以用如下提示把它拉回更可执行、更聚焦的问题:
I think we need to break this down into a series of steps. First, identify a list of tasks
that you would need to do during implementation that you're not sure of or would benefit
from further research. Write down a list of those tasks. And then for each one of these tasks,
I want you to spin up a separate research task so that the net results is we are researching
all of those very specific tasks in parallel. What I saw you doing was it looks like you were
researching .NET Aspire in general and I don't think that's gonna do much for us in this case.
That's way too untargeted research. The research needs to help you solve a specific targeted question.
[!NOTE]
Claude Code 可能会过于积极地加入你未要求的组件。你可以要求它解释变更理由以及变更来源。
第 5 步: 让 Claude Code 验证计划
有了计划之后,让 Claude Code 过一遍,确保没有缺项。可使用如下提示:
Now I want you to go and audit the implementation plan and the implementation detail files.
Read through it with an eye on determining whether or not there is a sequence of tasks that you need
to be doing that are obvious from reading this. Because I don't know if there's enough here. For example,
when I look at the core implementation, it would be useful to reference the appropriate places in the implementation
details where it can find the information as it walks through each step in the core implementation or in the refinement.
这有助于进一步完善实现计划,避免 Claude Code 在规划周期中遗漏的盲点。完成第一轮完善后,再让 Claude Code 复查一次清单,然后再进入实现阶段。
如果你安装了 GitHub CLI,也可以让 Claude Code 从当前分支向 main 创建 Pull Request 并附上详细描述,以便跟踪工作进展。
[!NOTE]
在让代理开始实现之前,也值得让 Claude Code 检查是否存在过度工程(它可能会过度热情)。如有,要求它进行收敛。并确保 Claude Code 在制定计划时遵循 constitution 这一基础原则。
第 6 步: 使用 /speckit.tasks 生成任务拆分
当实现计划验证完成后,就可以把计划拆成一组按顺序执行的、可落地的具体任务。使用 /speckit.tasks 自动从实现计划生成任务清单:
/speckit.tasks
这一步会在你的特性规范目录中创建一个 tasks.md 文件,包含:
- 按用户故事组织的任务拆分:每个用户故事成为一个独立的实现阶段,并带有各自的任务集合
- 依赖管理:任务按依赖顺序排列(例如先模型再服务、先服务再接口)
- 并行标记:可并行的任务以
[P]标记,优化开发效率 - 文件路径标注:每项任务都给出应修改的准确文件路径
- 测试驱动结构:若要求测试,则包含测试任务并优先于实现任务
- 检查点验证:每个用户故事阶段包含检查点,用于验证阶段性功能独立可用
生成的 tasks.md 为 /speckit.implement 提供清晰的执行路线图,确保实现过程系统化、质量可控,并支持按用户故事增量交付。
第 7 步: 实现
准备就绪后,使用 /speckit.implement 执行实现计划:
/speckit.implement
/speckit.implement 将会:
- 验证先决条件齐备(constitution、spec、plan、tasks)
- 解析
tasks.md中的任务拆分 - 按正确顺序执行任务,并遵守依赖与并行标记
- 遵循任务计划中定义的 TDD 路径
- 输出进度并处理错误
[!IMPORTANT]
AI 代理会执行本地 CLI 命令(如dotnet、npm等),请确保你的机器已安装必要工具。
实现完成后,请测试应用并解决运行期错误(例如浏览器控制台错误),这些错误往往不会出现在 CLI 日志中。你可以将错误复制粘贴回 AI 代理,让它继续修复。
🔍 故障排查
Linux 上的 Git Credential Manager
如果你在 Linux 上遇到 Git 认证问题,可以安装 Git Credential Manager:
#!/usr/bin/env bash
set -e
echo "Downloading Git Credential Manager v2.6.1..."
wget https://github.com/git-ecosystem/git-credential-manager/releases/download/v2.6.1/gcm-linux_amd64.2.6.1.deb
echo "Installing Git Credential Manager..."
sudo dpkg -i gcm-linux_amd64.2.6.1.deb
echo "Configuring Git to use GCM..."
git config --global credential.helper manager
echo "Cleaning up..."
rm gcm-linux_amd64.2.6.1.deb👥 维护者
💬 支持
如需支持,请提交 GitHub issue。我们欢迎 bug 报告、功能建议,以及关于规范驱动开发的使用问题。
🙏 致谢
本项目在很大程度上受到了 John Lam 的工作与研究影响,并以此为基础。
📄 许可证
本项目采用 MIT 开源许可证发布。完整条款请参阅 LICENSE 文件。
最后编辑:Ddd4j 更新时间:2026-01-22 17:51
