一键导入
using-git-worktrees
Use when starting feature work that needs isolation from current workspace or before executing implementation plans
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when starting feature work that needs isolation from current workspace or before executing implementation plans
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.
Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies
Use when you have a written implementation plan to execute in a separate session with review checkpoints
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work
Use when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable
Use when completing tasks, implementing major features, or before merging to verify work meets requirements
| name | using-git-worktrees |
| description | Use when starting feature work that needs isolation from current workspace or before executing implementation plans |
Git worktrees create isolated workspaces sharing the same repository, allowing work on multiple branches simultaneously without switching.
Core principle: Systematic directory selection + safety verification = reliable isolation.
Announce at start: "I'm using the using-git-worktrees skill to set up an isolated workspace."
Follow this priority order:
# Check in priority order
ls -d .worktrees 2>/dev/null # Preferred (hidden)
ls -d worktrees 2>/dev/null # Alternative
If found: Use that directory. If both exist, .worktrees wins.
grep -i "worktree.*director" copilot-instructions.md 2>/dev/null
grep -i "worktree.*director" .github/copilot-instructions.md 2>/dev/null
If preference specified: Use it without asking.
If no directory exists and no preference found:
No worktree directory found. Where should I create worktrees?
1. .worktrees/ (project-local, hidden)
2. ~/.config/copilot/worktrees/<project-name>/ (global location)
Which would you prefer?
MUST verify directory is ignored before creating worktree:
git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null
If NOT ignored:
Why critical: Prevents accidentally committing worktree contents to repository.
project=$(basename "$(git rev-parse --show-toplevel)")
# Create worktree with new branch
git worktree add "$path" -b "$BRANCH_NAME"
cd "$path"
Auto-detect and run appropriate setup:
# Node.js
if [ -f package.json ]; then npm install; fi
# Rust
if [ -f Cargo.toml ]; then cargo build; fi
# Python
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f pyproject.toml ]; then poetry install; fi
# Go
if [ -f go.mod ]; then go mod download; fi
Run tests to ensure worktree starts clean:
npm test / cargo test / pytest / go test ./...
If tests fail: Report failures, ask whether to proceed or investigate.
If tests pass: Report ready.
Worktree ready at <full-path>
Tests passing (<N> tests, 0 failures)
Ready to implement <feature-name>
| Situation | Action |
|---|---|
.worktrees/ exists | Use it (verify ignored) |
worktrees/ exists | Use it (verify ignored) |
| Both exist | Use .worktrees/ |
| Neither exists | Check instructions → Ask user |
| Directory not ignored | Add to .gitignore + commit |
| Tests fail during baseline | Report failures + ask |
Never:
Always:
Called by:
Pairs with: