Spec Kit — Spec-Driven Development
Build high-quality software faster using Spec-Driven Development (SDD). Specifications become executable artifacts that generate working implementations, not just documentation.
Homepage: https://github.github.com/spec-kit/
GitHub: https://github.com/github/spec-kit
What is Spec-Driven Development?
SDD flips traditional software development:
| Traditional | Spec-Driven |
|---|
| Specs are scaffolding → discarded | Specs are executable → generate code |
| Code is king |
Intent is king |
| One-shot prompts | Multi-step refinement |
| Focus on "how" | Focus on "what" and "why" |
Core Philosophy:
- - Intent-driven development
- Rich specifications with guardrails
- Heavy reliance on AI model capabilities
- Technology-independent process
Prerequisites
- - OS: Linux, macOS, Windows (PowerShell supported)
- AI Agent: Claude Code, GitHub Copilot, Gemini CLI, or Codebuddy CLI
- Package Manager: uv
- Python: 3.11+
- Git: Any recent version
Installation & Setup
Initialize a New Project
CODEBLOCK0
Specify AI Agent
CODEBLOCK1
Script Type (Shell vs PowerShell)
Auto-selected by OS, or force explicitly:
CODEBLOCK2
Skip Tool Checks
CODEBLOCK3
The 6-Step Spec-Driven Process
Step 1: Initialize
Run specify init to create project structure with templates.
CODEBLOCK4
Creates:
- -
.speckit/ directory with configuration - Agent-specific templates
- Git repository structure
Step 2: Define Constitution
Establish core rules and principles for your project.
Slash Command:
CODEBLOCK5
Purpose: Sets guardrails and organizational principles that all specs must follow.
Step 3: Create Specification
Describe what you want to build, not how.
Slash Command:
CODEBLOCK6
Best Practices:
- - Focus on user scenarios and behaviors
- Avoid tech stack details (AI picks appropriate tech)
- Describe UI/UX in plain language
- Include constraints and business rules
Step 4: Refine (Clarify)
Identify and resolve ambiguities in your specification.
Slash Command:
CODEBLOCK7
What it does:
- - Detects vague or ambiguous requirements
- Asks clarifying questions
- Suggests concrete implementations
- Updates spec with resolved details
Step 5: Plan
Generate detailed implementation plan from specification.
Slash Command:
CODEBLOCK8
Output:
- - Architecture decisions
- File structure
- Implementation steps
- Testing strategy
- Dependencies to install
Step 6: Build
Execute the implementation plan.
Slash Command:
CODEBLOCK9
Features:
- - Generates code based on spec + plan
- Creates files incrementally
- Runs tests as specified
- Commits progress to Git
Context Awareness: Git Branch-Based
Spec Kit automatically detects the active feature based on your current Git branch.
Naming Convention:
CODEBLOCK10
To switch between specifications:
CODEBLOCK11
Context is automatically loaded when you run Spec Kit commands.
Development Phases
Phase 1: 0-to-1 (Greenfield)
Focus: Generate from scratch
- - Start with high-level requirements
- Generate specifications
- Plan implementation steps
- Build production-ready applications
Phase 2: Creative Exploration
Focus: Parallel implementations
- - Explore diverse solutions
- Support multiple technology stacks
- Experiment with UX patterns
- Compare approaches
Phase 3: Iterative Enhancement (Brownfield)
Focus: Modernization
- - Add features iteratively
- Modernize legacy systems
- Adapt existing processes
- Refactor with specs
All Slash Commands Reference
| Command | Purpose | When to Use |
|---|
| INLINECODE2 | Define project principles | At project start |
| INLINECODE3 |
Create specification | For each new feature |
|
/speckit.clarify | Resolve ambiguities | When spec is vague |
|
/speckit.plan | Generate implementation plan | Before coding |
|
/speckit.build | Execute implementation | After planning |
Enterprise Features
Organizational Constraints
- - Cloud Providers: Target specific platforms (AWS, Azure, GCP)
- Tech Stacks: Enforce approved technologies
- Design Systems: Integrate enterprise UI libraries
- Compliance: Meet security/regulatory requirements
Technology Independence
Spec Kit works with:
- - Any programming language
- Any framework
- Any architecture pattern
- Any deployment target
Local Development (Contributing)
Clone and Setup
CODEBLOCK12
Run CLI Directly
CODEBLOCK13
Editable Install
CODEBLOCK14
Test From Branch
CODEBLOCK15
Best Practices
Specification Writing
✅ DO:
- - Describe user scenarios
- Include business rules
- Mention constraints
- Use plain language
- Focus on behavior, not implementation
❌ DON'T:
- - Specify tech stack (let AI choose)
- Write implementation details
- Use jargon without context
- Make assumptions unstated
Example Good Spec
CODEBLOCK16
Example Bad Spec
CODEBLOCK17
Troubleshooting
Command Not Found
Problem: AI agent doesn't recognize /speckit.* commands
Solution: Re-run specify init in the project directory
Wrong Context Loaded
Problem: Working on wrong specification
Solution: Check current branch with git branch and switch: INLINECODE10
Script Type Issues
Problem: PowerShell scripts on macOS or vice versa
Solution: Force script type: --script sh or INLINECODE12
Agent Tool Missing
Problem: Spec Kit complains about missing AI agent tools
Solution: Use --ignore-agent-tools flag during init
Workflow Examples
New Feature Workflow
CODEBLOCK18
Brownfield Enhancement
CODEBLOCK19
Resources
- - Documentation: https://github.github.com/spec-kit/
- GitHub Repo: https://github.com/github/spec-kit
- Contributing: https://github.com/github/spec-kit/blob/main/CONTRIBUTING.md
- Support: https://github.com/github/spec-kit/blob/main/SUPPORT.md
Key Principles Summary
- 1. Intent over Implementation — Describe what, not how
- Specifications are Assets — Treat them as primary deliverables
- Multi-step Refinement — Iterate: Constitute → Specify → Clarify → Plan → Build
- Context-Aware — Git branches maintain feature context
- Technology Agnostic — Process works with any stack
Last updated: 2026-02-28
Spec Kit — 规范驱动开发
使用规范驱动开发(SDD)更快地构建高质量软件。规范成为可执行的工件,生成可工作的实现,而不仅仅是文档。
主页: https://github.github.com/spec-kit/
GitHub: https://github.com/github/spec-kit
什么是规范驱动开发?
SDD 颠覆了传统软件开发:
| 传统方式 | 规范驱动方式 |
|---|
| 规范是脚手架 → 被丢弃 | 规范是可执行的 → 生成代码 |
| 代码为王 |
意图为王 |
| 一次性提示 | 多步细化 |
| 关注如何做 | 关注做什么和为什么 |
核心理念:
- - 意图驱动开发
- 带有护栏的丰富规范
- 高度依赖 AI 模型能力
- 技术无关的流程
前提条件
- - 操作系统: Linux、macOS、Windows(支持 PowerShell)
- AI 代理: Claude Code、GitHub Copilot、Gemini CLI 或 Codebuddy CLI
- 包管理器: uv
- Python: 3.11+
- Git: 任何较新版本
安装与设置
初始化新项目
bash
创建新项目目录
uvx --from git+https://github.com/github/spec-kit.git specify init <项目名称>
在当前目录初始化
uvx --from git+https://github.com/github/spec-kit.git specify init .
uvx --from git+https://github.com/github/spec-kit.git specify init --here
指定 AI 代理
bash
在初始化时主动设置 AI 代理
uvx --from git+https://github.com/github/spec-kit.git specify init <项目> --ai claude
uvx --from git+https://github.com/github/spec-kit.git specify init <项目> --ai gemini
uvx --from git+https://github.com/github/spec-kit.git specify init <项目> --ai copilot
uvx --from git+https://github.com/github/spec-kit.git specify init <项目> --ai codebuddy
脚本类型(Shell vs PowerShell)
由操作系统自动选择,或强制指定:
bash
强制使用 PowerShell(Windows)
uvx --from git+https://github.com/github/spec-kit.git specify init <项目> --script ps
强制使用 POSIX shell(Linux/macOS)
uvx --from git+https://github.com/github/spec-kit.git specify init <项目> --script sh
跳过工具检查
bash
uvx --from git+https://github.com/github/spec-kit.git specify init <项目> --ai claude --ignore-agent-tools
6 步规范驱动流程
第 1 步:初始化
运行 specify init 创建带有模板的项目结构。
bash
uvx --from git+https://github.com/github/spec-kit.git specify init my-app --ai claude
创建内容:
- - 包含配置的 .speckit/ 目录
- 代理特定模板
- Git 仓库结构
第 2 步:定义章程
为项目建立核心规则和原则。
斜杠命令:
/speckit.constitution 本项目遵循库优先方法。
所有功能必须首先作为独立库实现。
我们严格使用 TDD。我们偏好函数式编程模式。
目的: 设置所有规范必须遵循的护栏和组织原则。
第 3 步:创建规范
描述你想要构建的内容,而不是方式。
斜杠命令:
/speckit.specify 构建一个应用程序,帮助我整理照片到不同的相册中。
相册按日期分组,可以通过在主页面拖放重新组织。
相册不会嵌套在其他相册中。
在每个相册内,照片以磁贴式界面预览。
最佳实践:
- - 关注用户场景和行为
- 避免技术栈细节(AI 会选择合适的技术)
- 用通俗语言描述 UI/UX
- 包含约束和业务规则
第 4 步:细化(澄清)
识别并解决规范中的歧义。
斜杠命令:
/speckit.clarify 关注安全影响和边界情况
功能:
- - 检测模糊或歧义的需求
- 提出澄清性问题
- 建议具体实现方案
- 用已解决的细节更新规范
第 5 步:规划
根据规范生成详细的实现计划。
斜杠命令:
/speckit.plan
输出:
- - 架构决策
- 文件结构
- 实现步骤
- 测试策略
- 需要安装的依赖
第 6 步:构建
执行实现计划。
斜杠命令:
/speckit.build
特性:
- - 基于规范+计划生成代码
- 增量创建文件
- 按指定方式运行测试
- 将进度提交到 Git
上下文感知:基于 Git 分支
Spec Kit 根据当前 Git 分支自动检测活动功能。
命名约定:
001-feature-name
002-user-authentication
003-photo-album-grid
在规范之间切换:
bash
git checkout 001-feature-name # 处理功能 1
git checkout 002-user-auth # 处理功能 2
运行 Spec Kit 命令时自动加载上下文。
开发阶段
阶段 1:从零到一(绿地开发)
重点: 从头生成
- - 从高层需求开始
- 生成规范
- 规划实现步骤
- 构建生产就绪的应用程序
阶段 2:创意探索
重点: 并行实现
- - 探索多种解决方案
- 支持多种技术栈
- 尝试 UX 模式
- 比较不同方法
阶段 3:迭代增强(棕地开发)
重点: 现代化
- - 迭代添加功能
- 现代化遗留系统
- 适配现有流程
- 使用规范进行重构
所有斜杠命令参考
| 命令 | 用途 | 使用时机 |
|---|
| /speckit.constitution | 定义项目原则 | 项目开始时 |
| /speckit.specify |
创建规范 | 每个新功能 |
| /speckit.clarify | 解决歧义 | 规范模糊时 |
| /speckit.plan | 生成实现计划 | 编码之前 |
| /speckit.build | 执行实现 | 规划之后 |
企业级特性
组织约束
- - 云提供商: 针对特定平台(AWS、Azure、GCP)
- 技术栈: 强制使用批准的技术
- 设计系统: 集成企业 UI 库
- 合规性: 满足安全/监管要求
技术无关性
Spec Kit 支持:
本地开发(贡献)
克隆与设置
bash
git clone https://github.com/github/spec-kit.git
cd spec-kit
直接运行 CLI
bash
最快反馈 - 无需安装
python -m src.specify_cli --help
python -m src.specify_cli init demo-project --ai claude --script sh
可编辑安装
bash
uv venv
source .venv/bin/activate # Windows: .venv\Scripts\Activate.ps1
uv pip install -e .
specify --help
从分支测试
bash
先推送分支
git push origin your-feature-branch
通过 uvx 测试
uvx --from git+https://github.com/github/spec-kit.git@your-feature-branch \
specify init demo-branch-test --script ps
最佳实践
规范编写
✅ 应该做:
- - 描述用户场景
- 包含业务规则
- 提及约束条件
- 使用通俗语言
- 关注行为,而非实现
❌ 不应该做:
- - 指定技术栈(让 AI 选择)
- 编写实现细节
- 使用无上下文的术语
- 做出未说明的假设
良好规范示例
/speckit.specify 构建一个任务管理应用,其中:
- - 用户可以创建带有颜色编码标签的项目
- 任务具有优先级(高/中/低)并带有视觉指示器
- 通过拖放重新排序项目内的任务
- 任务可以分配给多个用户
- 截止日期在 24 小时前触发