Skip to content
Skill

using-git-worktrees

by obra

AI Summary

Helps developers create isolated git worktrees for parallel feature development without disrupting their current workspace. Essential for teams managing multiple branches simultaneously.

Install

Copy this and paste it into Claude Code, Cursor, or any AI assistant:

I want to install the "using-git-worktrees" skill in my project.

Please run this command in my terminal:
# Install skill into your project
mkdir -p .claude/skills/using-git-worktrees && curl --retry 3 --retry-delay 2 --retry-all-errors -o .claude/skills/using-git-worktrees/SKILL.md "https://raw.githubusercontent.com/obra/superpowers/main/skills/using-git-worktrees/SKILL.md"

Then restart Claude Code (or reload the window in Cursor) so the skill is picked up.

Description

Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback

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."

1a. Native Worktree Tools (preferred)

The user has asked for an isolated workspace (Step 0 consent). Do you already have a way to create a worktree? It might be a tool with a name like EnterWorktree, WorktreeCreate, a /worktree command, or a --worktree flag. If you do, use it and skip to Step 2. Native tools handle directory placement, branch creation, and cleanup automatically. Using git worktree add when you have a native tool creates phantom state your harness can't see or manage. Only proceed to Step 1b if you have no native worktree tool available.

Step 0: Detect Existing Isolation

Before creating anything, check if you are already in an isolated workspace. `bash 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: `bash

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 ` If GIT_DIR != GIT_COMMON (and not a submodule): You are already in a linked worktree. Skip to Step 2 (Project Setup). Do NOT create another worktree. Report with branch state: • On a branch: "Already in isolated workspace at <path> on branch <name>." • Detached HEAD: "Already in isolated workspace at <path> (detached HEAD, externally managed). Branch creation needed at finish time." If GIT_DIR == GIT_COMMON (or in a submodule): You are in a normal repo checkout. Has the user already indicated their worktree preference in your instructions? If not, ask for consent before creating a worktree: > "Would you like me to set up an isolated worktree? It protects your current branch from changes." Honor any existing declared preference without asking. If the user declines consent, work in place and skip to Step 2.

Discussion

0/2000
Loading comments...

Health Signals

MaintenanceCommitted 29d ago
Active
Adoption1K+ stars on GitHub
234.0k ★ · Popular
DocsREADME + description
Well-documented

GitHub Signals

Stars234.0k
Forks20.8k
Issues274
Updated29d ago
View on GitHub
MIT License

My Fox Den

Community Rating

Sign in to rate this booster

Works With

Claude Code