Git Worktrees

Manage git worktrees for working on multiple branches simultaneously.

Install

skills CLI (Claude Code, Cursor, Codex and more)
npx skills add obra/superpowers --skill using-git-worktrees
Manual install
git clone --depth 1 https://github.com/obra/superpowers.git /tmp/superpowers
mkdir -p ~/.claude/skills
cp -r /tmp/superpowers/skills/using-git-worktrees ~/.claude/skills/using-git-worktrees

Personal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.

What this skill does

Creates isolated git worktrees with safety checks. Manage multiple working directories for the same repository.

Trigger phrases

Claude loads this skill automatically when you say things like:

“git worktree”“multiple branches”“isolated workspace”

How it works

  1. Create isolated worktrees
  2. Manage branch switching
  3. Clean up completed work

When to use it

  • When working on multiple features
  • For parallel development
  • When reviewing PRs

From the SKILL.md

# 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.**

```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."
Read the full skill on GitHub

Details

Skill name
using-git-worktrees
Path
skills/using-git-worktrees/SKILL.md

FAQ

What does the Git Worktrees skill do?

Creates isolated git worktrees with safety checks. Manage multiple working directories for the same repository.

How do I install the Git Worktrees skill?

skills CLI (Claude Code, Cursor, Codex and more): npx skills add obra/superpowers --skill using-git-worktrees. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.

Related skills

Browse the most popular Claude skills, all git & code review skills, or write your own with the skills generator.