Agent skill
using-git-worktrees
Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/using-git-worktrees-jlaws-dotfiles
SKILL.md
Using Git Worktrees
Announce at start: "I'm using the using-git-worktrees skill to set up an isolated workspace."
Directory Selection (Priority Order)
1. Check Existing Directories
ls -d .worktrees 2>/dev/null # Preferred (hidden)
ls -d worktrees 2>/dev/null # Alternative
If both exist, .worktrees wins.
2. Check CLAUDE.md
grep -i "worktree.*director" CLAUDE.md 2>/dev/null
If preference specified, use it.
3. Ask User
No worktree directory found. Where should I create worktrees?
1. .worktrees/ (project-local, hidden)
2. ~/.config/superpowers/worktrees/<project-name>/ (global)
Safety Verification
For project-local directories: MUST verify ignored before creating.
git check-ignore -q .worktrees 2>/dev/null
If NOT ignored: Add to .gitignore, commit, then proceed.
For global directory (~/.config/superpowers/worktrees): No verification needed.
Creation Steps
# 1. Detect project
project=$(basename "$(git rev-parse --show-toplevel)")
# 2. Create worktree
git worktree add "$path" -b "$BRANCH_NAME"
cd "$path"
# 3. Auto-detect and run setup
[ -f package.json ] && npm install
[ -f Cargo.toml ] && cargo build
[ -f requirements.txt ] && pip install -r requirements.txt
[ -f pyproject.toml ] && poetry install
[ -f go.mod ] && go mod download
# 4. Verify clean baseline
# Run project-appropriate test command
# If tests fail: report failures, ask whether to proceed
# 5. Report
# "Worktree ready at <path>, tests passing (N tests, 0 failures)"
Quick Reference
| Situation | Action |
|---|---|
.worktrees/ exists |
Use it (verify ignored) |
worktrees/ exists |
Use it (verify ignored) |
| Both exist | Use .worktrees/ |
| Neither exists | Check CLAUDE.md, then ask user |
| Directory not ignored | Add to .gitignore + commit |
| Tests fail in baseline | Report failures + ask |
Integration
- Called by: brainstorming (after design approved), any skill needing isolation
- Pairs with: finishing-a-development-branch (cleanup after), executing-plans / subagent-driven-development (work happens here)
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?