安装指南
前置条件
- Linux/macOS(或 Windows;现支持 PowerShell 脚本,无需 WSL)
- AI 编码代理:Claude Code、GitHub Copilot 或 Gemini CLI
- uv 用于包管理
- Python 3.11+
- Git
安装
初始化新项目
最简单的入门方式是初始化一个新项目:
uvx --from git+https://github.com/github/spec-kit.git specify init <PROJECT_NAME>
或在当前目录初始化:
uvx --from git+https://github.com/github/spec-kit.git specify init .
# 或使用 --here 标志
uvx --from git+https://github.com/github/spec-kit.git specify init --here
指定 AI 代理
你可以在初始化期间主动指定 AI 代理:
uvx --from git+https://github.com/github/spec-kit.git specify init <project_name> --ai claude
uvx --from git+https://github.com/github/spec-kit.git specify init <project_name> --ai gemini
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
强制指定脚本类型:
uvx --from git+https://github.com/github/spec-kit.git specify init <project_name> --script sh
uvx --from git+https://github.com/github/spec-kit.git specify init <project_name> --script ps
忽略代理工具检查
如果你希望在不检查工具的情况下获取模板:
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 凭据管理器:
#!/usr/bin/env bash
set -e
echo "正在下载 Git 凭据管理器 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 "正在安装 Git 凭据管理器..."
sudo dpkg -i gcm-linux_amd64.2.6.1.deb
echo "正在配置 Git 以使用 GCM..."
git config --global credential.helper manager
echo "清理中..."
rm gcm-linux_amd64.2.6.1.deb