obra avatar

Using Git Worktrees

Creates isolated git worktrees with systematic safety checks and project setup automation. Follows a clear directory priority (existing .worktrees, then worktrees, then CLAUDE.md preferences, finally asks), automatically verifies directories are gitignored to prevent accidentally committing worktree contents, and runs appropriate dependency installation (npm install, cargo build, etc.) based on project files. Always establishes a clean test baseline before reporting ready. The safety verification is the real value here since worktree pollution is a common gotcha that breaks git status output. Designed to be called by other skills like brainstorming and executing-plans when they need workspace isolation.

skills.sh installs
230.2K
GitHub stars
315.2K
last updated
Aug 21, 2026

Install

$ npx -y skills add obra/superpowers --skill using-git-worktrees --agent claude-code

Installs into .claude/skills of the current project.

Files

Using Git Worktrees

Overview

Ensure work happens in an isolated workspace. Prefer your platform's native worktree tools. Fall back to manual git worktrees only when no native tool is available.

Core principle: Detect existing isolation first. Then use native tools. Then fall back to git. Never fight the harness.

Announce at start: "I'm using the using-git-worktrees skill to set up an isolated workspace."

Step 0: Detect Existing Isolation

Before creating anything, check if you are already in an isolated workspace.

GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P)
GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P)
BRANCH=$(git branch --show-current)

Submodule guard: GIT_DIR != GIT_COMMON is also true inside git submodules. Before concluding "already in a worktree," verify you are not in a submodule:

# If this returns a path, you're in a submodule, not a worktree — treat as normal repo
git rev-parse --show-superproject-working-tree 2>/dev/null

Sponsors

Details

Repository
github.com/obra/superpowers
Category
Git & Pull Requests

More from obra/superpowers

All 14
1juliusbrussee avatarcaveman-evidence-reviewjuliusbrussee/cavemanRead-only review of Caveman Cloud evidence: cost, Cave Score, workflows, traces, latency, errors, routing, savings. Use when asked what Caveman found or where L119Kskills.sh installs
22dmurali avatarreview-loop2dmurali/review-loop-skillIterative worker-reviewer cycle that spawns a critic subagent to score work 1-10 and provide actionable feedback, then revises until a quality gate is met. Use 110.9Kskills.sh installs
3DietrichGebert avatarponytail-reviewDietrichGebert/ponytailCode review focused exclusively on over-engineering. Finds what to delete: reinvented standard library, unneeded dependencies, speculative abstractions, dead fl67.7Kskills.sh installs
4heygen-com avatarchangelog-videoheygen-com/hyperframesTurn a weekly changelog .md into a finished branded changelog video (square 1080, ~45-60s, Annie VO, animated brand background, mock-UI visualizations, lowkey c60.6Kskills.sh installs
5wshobson avatarcode-review-excellencewshobson/agentsMaster effective code review practices to provide constructive feedback, catch bugs early, and foster knowledge sharing while maintaining team morale. Use when 30.9Kskills.sh installs
6googleworkspace avatarrecipe-review-overdue-tasksgoogleworkspace/cliFind Google Tasks that are past due and need attention.30.8Kskills.sh installs