using-git-worktrees
Create isolated git worktrees with safety checks and setup guidance. Use when starting feature work that needs separation from the main checkout.
- License 许可
- Apache-2.0
- 所属仓库
- r3dlex/skills
- 最近更新
- 2026-10-29
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- using-git-worktrees
- description
- Create isolated git worktrees with safety checks and setup guidance. Use when starting feature work that needs separation from the main checkout.
02 资源文件 1
- 参考文档REFERENCE.md3.8 KB
03 SKILL.md 正文
Using Git Worktrees
Quick Start
- Check for existing worktree directory (
.worktreesorworktrees) - Verify directory is git-ignored (for project-local)
- Create worktree with new branch:
git worktree add <path> -b <branch> - Run project setup (auto-detect: npm install, cargo build, etc.)
- Verify clean test baseline
Announce at start: "I'm using the using-git-worktrees skill to set up an isolated workspace."
Directory Selection Priority
.worktrees/(preferred, hidden)worktrees/(alternative)- CLAUDE.md preference (if specified)
- Ask user
Safety Verification
For project-local directories, MUST verify is git-ignored:
git check-ignore -q .worktrees || git check-ignore -q worktrees
If NOT ignored: Add to .gitignore, commit, then proceed. Prevents accidentally committing worktree contents.
No verification needed for global directories (outside project).
Creation Steps
1. Detect project name
project=$(basename "$(git rev-parse --show-toplevel)")
2. Create worktree
git worktree add "$path" -b "$BRANCH_NAME"
cd "$path"
3. Auto-setup
# Node.js: [ -f package.json ] && npm install
# Rust: [ -f Cargo.toml ] && cargo build
# Python: [ -f requirements.txt ] && pip install -r requirements.txt
# Go: [ -f go.mod ] && go mod download
4. Verify baseline
Run project tests. If they fail: report failures, ask whether to proceed.
5. Report
Worktree ready at <path>
Tests passing (<N> tests, 0 failures)
Ready to implement <feature>
Common Mistakes
| Mistake | Fix |
|---|---|
| Skipping ignore verification | Always git check-ignore before creating project-local worktree |
| Assuming directory location | Follow priority: existing > CLAUDE.md > ask |
| Proceeding with failing tests | Report, get explicit permission |
| Hardcoding setup commands | Auto-detect from project files |
Integration
Called by: brainstorm (Phase 4), subagent-driven-development, executing-plans — REQUIRED before executing tasks.
For detailed examples and reference material, see REFERENCE.md.
04 同仓库更多 Skills
skill
Fixture.
stable-skill
Fixture stable-skill.
experimental-skill
Fixture experimental-skill.
deprecated-skill
Fixture deprecated-skill.
karpathy-guidelines
Apply think-before-coding, simplicity, surgical-change, and goal-driven engineering rules. Use when planning, implementing, or reviewing code.
karpathy-guidelines
Apply think-before-coding, simplicity, surgical-change, and goal-driven engineering rules. Use when planning, implementing, or reviewing code.