Skip to content
Skill Authoring
Skill

/git-worktrees

Manage Git worktrees for parallel Claude Code development. Use this skill when engineers ask to "create a worktree", "run parallel Claude sessions", "work on multiple features simultaneously", or need help with worktree management.

From plugin
jamesrochabrun-skills
19424 skills
Install
$ npx -y skills add jamesrochabrun/skills --skill git-worktrees --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/git-worktrees

Context preview

The summary Claude sees to decide when to auto-load this skill.

Manage Git worktrees for parallel Claude Code development. Use this skill when engineers ask to "create a worktree", "run parallel Claude sessions", "work on multiple features simultaneously", or need help with worktree management.

SKILL.md

git-worktrees.SKILL.md
name: git-worktrees
description: Manage Git worktrees for parallel Claude Code development. Use this skill when engineers ask to "create a worktree", "run parallel Claude sessions", "work on multiple features simultaneously", or need help with worktree management.

Git Worktrees for Claude Code

Overview

Run multiple Claude Code sessions in parallel on different branches using Git worktrees. This skill provides simple scripts and workflows to set up, manage, and clean up worktrees, enabling true parallel development without conflicts.

**Why Worktrees?**

  • **Parallel Development**: Run multiple Claude Code instances simultaneously
  • **Zero Conflicts**: Each worktree has independent file state
  • **Fast Context Switching**: No need to stash/commit when switching tasks
  • **Isolated Experiments**: Try different approaches without affecting main work
  • **Long-Running Tasks**: Let Claude work in background while you continue in main

---

Quick Start

1. Create a New Worktree (Super Easy!)

Just run the interactive script:

scripts/create_worktree.sh

This will:

  • ✅ Prompt for feature name
  • ✅ Create a new branch
  • ✅ Set up the worktree
  • ✅ Open in VS Code / editor
  • ✅ Give you the Claude Code setup command

**That's it!** The script handles all complexity.

---

2. View All Worktrees

scripts/list_worktrees.sh

Shows a clean, formatted list of all your worktrees with their branches and status.

---

3. Clean Up Old Worktrees

scripts/cleanup_worktrees.sh

Interactive removal of merged or abandoned worktrees.

---

Core Workflow

Pattern 1: Parallel Feature Development

**Scenario:** You want Claude to build feature A while you work on feature B.

**Steps:**

1. **Create worktree for feature A:**

   scripts/create_worktree.sh
   # Enter: feature-a
   # Script creates: ../repo-feature-a/

2. **Open Claude Code in the new worktree:**

  • The script outputs the path
  • Open Claude Code and navigate to that directory
  • Run `/init` to orient Claude

3. **Give Claude the task:**

   "Build the user authentication feature with OAuth support"

4. **Continue your work in main:**

  • Your original directory is unchanged
  • No conflicts, no waiting
  • Claude works in parallel

5. **When both are done, merge:**

   # Review Claude's work
   cd ../repo-feature-a
   git log

   # If good, merge back
   git checkout main
   git merge feature-a

   # Clean up
   scripts/cleanup_worktrees.sh

---

Pattern 2: Long-Running Refactor

**Scenario:** You want Claude to refactor a large module while you continue development.

**Steps:**

1. **Create refactor worktree:**

   scripts/create_worktree.sh
   # Enter: refactor-auth-module

2. **Start Claude in refactor worktree:**

   "Refactor the authentication module to use dependency injection"

3. **Continue your daily work in main:**

  • No interruption
  • No merge conflicts
  • Check progress periodically

4. **Review and integrate when ready:**

   cd ../repo-refactor-auth-module
   git log --oneline
   # Review changes

   # Merge when satisfied
   git checkout main
   git merge refactor-auth-module

---

Pattern 3: Multiple AI Agents (Advanced)

**Scenario:** You want 3 Claude instances working on different features simultaneously.

**Steps:**

1. **Create 3 worktrees:**

   scripts/create_worktree.sh  # feature-api-endpoints
   scripts/create_worktree.sh  # feature-ui-dashboard
   scripts/create_worktree.sh  # feature-email-notifications

2. **Open 3 Claude Code sessions:**

  • Session 1: `../repo-feature-api-endpoints/`
  • Session 2: `../repo-feature-ui-dashboard/`
  • Session 3: `../repo-feature-email-notifications/`

3. **Assign tasks to each Claude:**

  • Claude 1: "Build REST API endpoints for user management"
  • Claude 2: "Create admin dashboard UI"
  • Claude 3: "Implement email notification system"

4. **Monitor progress:**

   scripts/list_worktrees.sh

5. **Merge features as they complete:**

   # Feature by feature
   git checkout main
   git merge feature-api-endpoints
   git merge feature-ui-dashboard
   git merge feature-email-notifications

   # Clean up
   scripts/cleanup_worktrees.sh

---

Pattern 4: Hotfix While Development Continues

**Scenario:** Production bug needs immediate fix while Claude is working on a feature.

**Steps:**

1. **Claude is already working in a feature worktree**

  • Let it continue, don't interrupt

2. **Create hotfix worktree from main:**

   scripts/create_worktree.sh
   # Enter: hotfix-login-bug
   # Choose base branch: main

3. **Fix the bug yourself or with another Claude session:**

   cd ../repo-hotfix-login-bug
   # Make fixes
   git add .
   git commit -m "Fix login redirect bug"

4. **Merge hotfix to main:**

   git checkout main
   git merge hotfix-login-bug
   git push origin main

5. **Sync feature worktree with latest main:**

   cd ../repo-feature-xyz
   scripts/sync_worktree.sh
   # Merges latest main into feature branch

---

Essential Scripts

scripts/create_worktree.sh

**Interactive worktree creation with all the right defaults.**

**What it does:** 1. Prompts for feature name 2. Validates git repo 3. Creates branch from main (or specified base) 4. Sets up worktree in parallel directory 5. Outputs setup instructions

**Usage:**

scripts/create_worktree.sh

# Prompts:
# Feature name: my-feature
# Base branch (default: main):
#
# Creates: ../repo-my-feature/
# Branch: my-feature

**Advanced usage:**

# Create from specific branch
scripts/create_worktree.sh --base develop

# Specify location
scripts/create_worktree.sh --dir ~/worktrees/my-feature

---

scripts/list_worktrees.sh

**Shows all active worktrees with status.**

**Output:**

╔═══════════════
Read more
Ships withjamesrochabrun-skills

A comprehensive plugin and marketplace for Claude Code containing 24 custom skills across engineering, Apple development, product management, design, content, trading, database, QA, educational, and AI architecture domains.

Get the whole plugin