Using Git Worktrees

Create isolated git worktrees with smart directory selection and safety verification

43 stars 26 forksGit & Code Review

Install

skills CLI (Claude Code, Cursor, Codex and more)
npx skills add obra/clank --skill Using Git Worktrees
Manual install
git clone --depth 1 https://github.com/obra/clank.git /tmp/clank
mkdir -p ~/.claude/skills
cp -r /tmp/clank/skills/collaboration/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.

From the SKILL.md

# Using Git Worktrees

## Overview

Git worktrees create isolated workspaces sharing the same repository, allowing work on multiple branches simultaneously without switching.

**Core principle:** Systematic directory selection + safety verification = reliable isolation.

**Announce at start:** "I'm using the Using Git Worktrees skill to set up an isolated workspace."

## Directory Selection Process

Follow this priority order:

### 1. Check Existing Directories

```bash
# Check in priority order
ls -d .worktrees 2>/dev/null     # Preferred (hidden)
ls -d worktrees 2>/dev/null      # Alternative
```

**If found:** Use that directory. If both exist, `.worktrees` wins.

### 2. Check CLAUDE.md

```bash
grep -i "worktree.*director" CLAUDE.md 2>/dev/null
```

**If preference specified:** Use it without asking.

### 3. Ask User

If no directory exists and no CLAUDE.md preference:

```
No worktree directory found. Where should I create worktrees?

1. .worktrees/ (project-local, hidden)
2. ~/.clank-worktrees/<project-name>/ (global location)

Which would you prefer?
```

## Safety Verification

### For Project-Local Directories (.worktrees or worktrees)

**MUST verify .gitignore before creating worktree:**

```bash
# Check if directory pattern in .gitignore
grep -q "^\.worktrees/$" .gitignore || grep -q "^worktrees/$" .gitignore
```

**If NOT in .gitignore:**

Per Jesse's rule "Fix broken things immediately":
1. Add appropriate line to .gitignore
2. Commit the change
Read the full skill on GitHub

Details

Skill name
Using Git Worktrees
Repository
obra/clank
Path
skills/collaboration/using-git-worktrees/SKILL.md
Repo updated
9 October 2025

FAQ

What does the Using Git Worktrees skill do?

Create isolated git worktrees with smart directory selection and safety verification

How do I install the Using Git Worktrees skill?

skills CLI (Claude Code, Cursor, Codex and more): npx skills add obra/clank --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.

Is Using Git Worktrees popular?

It lives in obra/clank, which has 43 GitHub stars and 26 forks.

Related skills

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