using-git-worktrees

A Git feature for creating separate working directories for different branches of the same repository. These directories are called worktrees.

In plain words
What is it for?
Use it to develop parallel features, run long tests in one branch while coding in another, isolate experiments, or handle a production fix alongside ongoing work.
Why use it?
It lets developers work on several features, experiments, tests, or hotfixes at once without mixing their files or repeatedly stashing changes.

Skill for Claude CodeCodex

Part of the claude-pilot plugin — 32 skills, 11 commands, 14 agents, 2 MCP servers shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/changoo89/claude-pilot/using-git-worktrees
Any agent
npx skills add changoo89/claude-pilot --skill using-git-worktrees
Clone the repo
git clone --depth 1 https://github.com/changoo89/claude-pilot

Made for: Claude Code, Codex.

Or install claude-pilot, the plugin that ships this one along with the rest of its 32 skills, 11 commands, 14 agents, 2 MCP servers.

Per session 25 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,014 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00025 $0.01014
Opus 5 $0.00013 $0.00507
Sonnet 5 $0.00005 $0.00203
Haiku 4.5 $0.00003 $0.00101

Measured 3d ago against content hash c4496f27f91a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade C, and why

using-git-worktrees scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

rm -rf ../myproject-feature
.claude/skills/using-git-worktrees/SKILL.md · 194 lines

How it starts

The opening of the file, as written. The whole thing — 194 lines — stays where its author put it; the contents beside it link to each section on GitHub.

SKILL: Using Git Worktrees

Purpose: Parallel development using isolated workspaces for concurrent feature branches Target: Developers working on multiple features simultaneously


Quick Start

When to Use This Skill

  • Developing multiple features concurrently
  • Running long-running tests on one branch while working on another
  • Isolating experimental changes without stash/commit dance
  • Hotfix production while continuing feature work

Quick Reference

# Create new worktree
git worktree add ../project-feature-1 feature-1
git worktree add ../project-feature-2 feature-2

# List worktrees
git worktree list

# Remove worktree after merge
git worktree remove ../project-feature-1

Core Concepts

Worktree Creation

Basic Syntax:

git worktree add <path> <branch> [<start-point>]

Examples:

# Create worktree for existing branch
git worktree add ../myproject-feature feature-x

# Create worktree for new branch
git worktree add ../myproject-experiment -b experiment-branch

# Create worktree at specific commit
git worktree add ../myproject-v1.0 -b v1.0-fixes a1b2c3d

Worktree Management

List worktrees:

git worktree list
# Output:
# /path/to/main              abc1234 [main]
# /path/to/feature-1         def5678 [feature-1]
# /path/to/hotfix            ghi9012 [hotfix/security-fix]

Remove worktree:

# Prune after deleting directory manually
rm -rf ../myproject-feature
git worktree prune

# Remove directly
git worktree remove ../myproject-feature

Lock worktree (prevent cleanup):

git worktree lock ../myproject-critical
git worktree unlock ../myproject-critical

Workflow Integration

Parallel Development Pattern:

# Main workspace: feature work
cd ~/project-main
git checkout -b feature-auth

# Worktree 1: Hotfix
git worktree add ../project-hotfix -b hotfix-login
cd ../project-hotfix
# Fix hotfix, test, commit, push

# Worktree 2: Experiment
git worktree add ../project-experiment -b experiment-ui
cd ../project-experiment
# Try new UI approach, discard if fails

# Return to main workspace
cd ~/project-main
# Continue feature work, merge hotfix when ready

Read the full file on GitHub · 194 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 194 lines · 25 tokens per session scan C c4496f27f91a

Subscribe to this mod's changes

using-git-worktrees is a skill published in the GitHub repository changoo89/claude-pilot (20 stars, last pushed 6mo ago), licensed MIT. It adds 25 tokens to every session and 1,014 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.