安装指南

前置条件

安装

初始化新项目

最简单的入门方式是初始化一个新项目:

  1. uvx --from git+https://github.com/github/spec-kit.git specify init <PROJECT_NAME>

或在当前目录初始化:

  1. uvx --from git+https://github.com/github/spec-kit.git specify init .
  2. # 或使用 --here 标志
  3. uvx --from git+https://github.com/github/spec-kit.git specify init --here

指定 AI 代理

你可以在初始化期间主动指定 AI 代理:

  1. uvx --from git+https://github.com/github/spec-kit.git specify init <project_name> --ai claude
  2. uvx --from git+https://github.com/github/spec-kit.git specify init <project_name> --ai gemini
  3. uvx --from git+https://github.com/github/spec-kit.git specify init <project_name> --ai copilot

指定脚本类型(Shell 与 PowerShell)

所有自动化脚本现均有 Bash(.sh)与 PowerShell(.ps1)两种版本。

自动行为:

  • Windows 默认:ps
  • 其他系统默认:sh
  • 交互模式:会提示你选择,除非传入 --script

强制指定脚本类型:

  1. uvx --from git+https://github.com/github/spec-kit.git specify init <project_name> --script sh
  2. uvx --from git+https://github.com/github/spec-kit.git specify init <project_name> --script ps

忽略代理工具检查

如果你希望在不检查工具的情况下获取模板:

  1. uvx --from git+https://github.com/github/spec-kit.git specify init <project_name> --ai claude --ignore-agent-tools

验证

初始化后,你的 AI 代理中应可使用以下命令:

  • /specify - 创建规范
  • /plan - 生成实现计划
  • /tasks - 拆分为可执行任务

.specify/scripts 目录将同时包含 .sh.ps1 脚本。

故障排除

Linux 上的 Git 凭据管理器

如果你在 Linux 上遇到 Git 身份验证问题,可安装 Git 凭据管理器:

  1. #!/usr/bin/env bash
  2. set -e
  3. echo "正在下载 Git 凭据管理器 v2.6.1..."
  4. wget https://github.com/git-ecosystem/git-credential-manager/releases/download/v2.6.1/gcm-linux_amd64.2.6.1.deb
  5. echo "正在安装 Git 凭据管理器..."
  6. sudo dpkg -i gcm-linux_amd64.2.6.1.deb
  7. echo "正在配置 Git 以使用 GCM..."
  8. git config --global credential.helper manager
  9. echo "清理中..."
  10. rm gcm-linux_amd64.2.6.1.deb