逑美(皮肤健康咨询)
89.22M · 2025-09-29
在使用AI进行开发时,你是否遇到过以下问题?
如果你也面临这些困扰,那么Spec-Kit将是你的理想解决方案。
Spec-Kit是由GitHub开发的一款规范驱动开发工具,它通过标准化的工作流程,让AI辅助编程变得更加可控、高效和规范。
Spec-Kit采用"规范先行"的开发模式:
在开始之前,请确保你的系统满足以下要求:
pip install uv
Spec-Kit提供了多种安装方式,你可以根据需求选择:
创建一个名为chat-service
的新项目(可在创建时指定AI助手):
# 默认方式(使用默认AI后端)
uvx --from git+https://github.com/github/spec-kit.git specify init chat-service
# 创建时指定AI助手
# Claude Code(推荐)
uvx --from git+https://github.com/github/spec-kit.git specify init my-project --ai claude
# GitHub Copilot
uvx --from git+https://github.com/github/spec-kit.git specify init my-project --ai copilot
# Gemini CLI
uvx --from git+https://github.com/github/spec-kit.git specify init my-project --ai gemini
# Cursor
uvx --from git+https://github.com/github/spec-kit.git specify init my-project --ai cursor
如果你想在当前目录初始化Spec-Kit(同样可指定AI助手):
# 使用Claude Code(推荐)
specify init --here --ai claude
# 使用GitHub Copilot
specify init --here --ai copilot
# 使用Google Gemini
specify init --here --ai gemini
# 使用Cursor
specify init --here --ai cursor
如果你使用MCP(Model Context Protocol):
npx -y mcp-server-spec-driven-development@latest
安装成功后,你应该能看到类似的输出:
初始化成功后,Spec-Kit会在你的AI代理中注入三个核心命令:
/specify
- 规范定义用于定义项目规范和需求:
/specify "创建一个用户管理系统,包含注册、登录、权限管理功能"
该命令会生成详细的规范文档,包括:
/plan
- 计划制定基于规范生成实施计划:
/plan
输出内容包括:
/tasks
- 任务执行查看和执行具体任务:
/tasks # 查看所有任务
/tasks start 1 # 开始执行任务1
/tasks done 1 # 标记任务1完成
让我们通过一个实际例子来体验Spec-Kit的强大功能:
/specify "创建一个图书管理REST API,支持CRUD操作,使用FastAPI框架"
/plan
系统会自动生成类似这样的计划:
1. 项目初始化和环境配置
2. 定义数据模型
3. 实现CRUD接口
4. 添加数据验证
5. 编写单元测试
6. 添加API文档
/tasks start 1 # 开始第一个任务
# AI会自动生成相应的代码
/tasks done 1 # 完成后标记
/tasks start 2 # 继续下一个任务
你可以创建自己的规范模板:
# spec_templates/my_template.py
TEMPLATE = """
项目名称: {project_name}
技术栈: {tech_stack}
功能模块: {features}
性能要求: {performance}
"""
Spec-Kit可以与CI/CD工具集成:
# .github/workflows/spec-kit.yml
name: Spec-Kit Validation
on: [push]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Validate Specifications
run: specify validate
通过共享规范库实现团队协作:
# 导出规范
specify export --output team-specs.json
# 导入团队规范
specify import team-specs.json
/tasks
命令跟踪进度,及时调整A: Spec-Kit是语言无关的,支持所有主流编程语言,包括Python、JavaScript、Java、Go等。
A: 可以通过配置文件修改:
# .spec-kit/config.yml
ai_backend: claude # 可选: claude, gemini, copilot
A: 默认存储在项目根目录的.spec-kit/specs/
目录下。
examples/
目录包含多个示例Spec-Kit通过引入规范驱动的开发模式,有效解决了AI辅助编程中的诸多痛点。它不仅提高了开发效率,更重要的是建立了一套可复制、可扩展的标准化流程。
无论你是个人开发者还是团队领导者,Spec-Kit都能帮助你:
立即开始使用Spec-Kit,让你的AI开发之旅更加顺畅高效!
如果本文对你有帮助,欢迎Star项目并分享给更多开发者。有问题或建议?欢迎在GitHub上提Issue交流!