leodorareluctant259/superpowers-zh/using-git-worktrees
Trust tier 3
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
当需要开始与当前工作区隔离的功能开发或执行实现计划之前使用——创建具有智能目录选择和安全验证的隔离 git 工作树
Install
npx vskill@latest install leodorareluctant259/superpowers-zh/using-git-worktreesSKILL.md
使用 Git 工作树
概述
Git 工作树创建共享同一仓库的隔离工作区,允许同时在多个分支上工作而无需切换。
核心原则: 系统化的目录选择 + 安全验证 = 可靠的隔离。
开始时宣布: "我正在使用 using-git-worktrees 技能来建立一个隔离的工作区。"
目录选择流程
按以下优先顺序执行:
1. 检查现有目录
如果找到: 使用该目录。如果两者都存在,.worktrees 优先。
2. 检查 CLAUDE.md
如果指定了偏好: 直接使用,无需询问。
3. 询问用户
如果没有现有目录且 CLAUDE.md 中无偏好设置:
安全验证
项目本地目录(.worktrees 或 worktrees)
创建工作树前必须验证目录已被忽略:
如果未被忽略:
根据 Jesse 的规则"立即修复坏掉的东西":
- 在 .gitignore 中添加相应条目
- 提交更改
- 继续创建工作树
为什么这很关键: 防止意外将工作树内容提交到仓库。
全局目录(~/.config/superpowers/worktrees)
无需 .gitignore 验证——完全在项目之外。
创建步骤
1. 检测项目名称
2. 创建工作树
3. 运行项目设置
自动检测并运行相应的设置命令:
4. 验证基线正常
运行测试确保工作树初始状态干净:
如果测试失败: 报告失败情况,询问是否继续或排查。
如果测试通过: 报告就绪。
5. 报告位置
快速参考
| 情况 | 操作 | |
|---|---|---|
.worktrees/ 存在 | 使用它(验证已忽略) | |
worktrees/ 存在 | 使用它(验证已忽略) | |
| 两者都存在 | 使用 .worktrees/ | |
| 都不存在 | 检查 CLAUDE.md → 询问用户 | |
| 目录未被忽略 | 添加到 .gitignore + 提交 | |
| 基线测试失败 | 报告失败 + 询问 | |
| 无 package.json/Cargo.toml | 跳过依赖安装 |
常见错误
跳过忽略验证
- 问题: 工作树内容被跟踪,污染 git status
- 修复: 创建项目本地工作树前始终使用
git check-ignore
假设目录位置
- 问题: 造成不一致,违反项目约定
- 修复: 遵循优先级:现有目录 > CLAUDE.md > 询问
带着失败的测试继续
- 问题: 无法区分新 bug 和已有问题
- 修复: 报告失败,获得明确许可后再继续
硬编码设置命令
- 问题: 在使用不同工具的项目上会出错
- 修复: 从项目文件自动检测(package.json 等)
示例工作流
红线
绝不:
- 创建项目本地工作树时不验证是否已忽略
- 跳过基线测试验证
- 不询问就带着失败的测试继续
- 在有歧义时假设目录位置
- 跳过 CLAUDE.md 检查
始终:
- 遵循目录优先级:现有目录 > CLAUDE.md > 询问
- 对项目本地目录验证是否已忽略
- 自动检测并运行项目设置
- 验证测试基线干净
集成
被以下技能调用:
- brainstorming(阶段 4)- 设计通过且需要实现时必需
- subagent-driven-development - 执行任何任务前必需
- executing-plans - 执行任何任务前必需
- 任何需要隔离工作区的技能
配合使用:
- finishing-a-development-branch - 工作完成后清理时必需
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/using-git-worktrees/SKILL.md
Popularity
- Repository stars
- 5
- Repository forks
- 1
- 7-day trend score
- 9
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/leodorareluctant259/superpowers-zh/using-git-worktrees)