git-worktrees

git-worktrees is a skill for Claude Code from christopherlouet/claude-base. It costs 33 tokens per session (542 once invoked), scanned A, original, MIT.

A guide for Git worktrees, which let you check out multiple branches in separate directories at the same time.

In plain words
What is it for?
Use it to create, configure, list, remove, and clean up worktrees, including isolated background work and monorepo file selection.
Why use it?
It keeps parallel tasks isolated so different branches or agents can be worked on without constantly switching the main working directory.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: reads .claude/ paths; mentions CLAUDE.md; mentions Claude Code.

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/christopherlouet/claude-base/git-worktrees
Any agent
npx skills add christopherlouet/claude-base --skill git-worktrees
Clone the repo
git clone --depth 1 https://github.com/christopherlouet/claude-base

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for git-worktrees

README.md
[![agentmods](https://agentmods.dev/badge/skills/christopherlouet/claude-base/git-worktrees.svg)](https://agentmods.dev/skills/christopherlouet/claude-base/git-worktrees)
Your own site
<a href="https://agentmods.dev/skills/christopherlouet/claude-base/git-worktrees"><img src="https://agentmods.dev/badge/skills/christopherlouet/claude-base/git-worktrees.svg" alt="Measured on agentmods" height="20"></a>
Per session 33 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 542 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. 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.1 $0.00033 $0.00542
Opus 5 $0.00016 $0.00271
Sonnet 5 $0.00007 $0.00108
Haiku 4.5 $0.00003 $0.00054

Measured 2d ago against content hash b427b014845c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

git-worktrees scanned grade A with 0 findings 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 2d 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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/git-worktrees/SKILL.md · 47 lines

What it actually says

Git Worktrees (pointer)

"The single biggest productivity unlock." — Boris Cherny, creator of Claude Code

Generic worktree mechanics (git worktree add/list/remove/prune, branch isolation, hooks sharing) are canonical at git-scm.com/docs/git-worktree. This skill scopes to Claude-Code-specific worktree integration — what isn't in the git docs.

Claude Code worktree settings (CLI 2.1.76+ / 2.1.141+)

Three settings in .claude/settings.json shape how Claude Code uses worktrees:

Setting Values Purpose
worktree.sparsePaths array of globs Limit which files a worktree includes — speeds up monorepo operations and narrows Claude's exploration context
worktree.bgIsolation "auto" (default) / "none" Background sessions/agents default to writing into .claude/worktrees/; "none" lets them edit the working copy directly
worktree.baseRef "fresh" / "head" "fresh" branches new worktrees from origin/<default>, "head" from local HEAD (inherits in-progress local commits)

Both bgIsolation and baseRef apply to --worktree, the EnterWorktree tool, and agent-isolation worktrees.

Named-session pairing pattern

The foundation-specific workflow is 1 worktree = 1 branch = 1 named Claude session:

git worktree add ../myapp-feature-auth -b feature/auth
cd ../myapp-feature-auth && claude -n "auth"

The --name/-n flag tags the session for logs and terminal identification. Combined with worktrees this lets you run 5+ Claude Code sessions in parallel without state collision — see the "Parallel Sessions" section in CLAUDE.md.

See also

  • /work:work-explore — dedicate an analysis worktree to read-only exploration
  • session-handoff skill — transfer context across worktrees
  • parallel-agents / agent-teams skills — orchestration on top of multi-worktree setups
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. 2d ago First seen · 47 lines · 33 tokens per session scan A b427b014845c

Subscribe to this mod's changes

git-worktrees is a skill published in the GitHub repository christopherlouet/claude-base (5 stars, last pushed yesterday), licensed MIT. It adds 33 tokens to every session and 542 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.