git-worktree

Commands for creating separate Git worktrees, which are extra working directories for branches in the same repository.

In plain words
What is it for?
Use them to create, check, remove, or clean worktrees, while optionally reusing dependencies and running type checks or tests.
Why use it?
They let you develop a feature in isolation without changing the branch in your main directory.

Command

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 commands/florianbruniaux/claude-code-plugins/git-worktree
Clone the repo
git clone --depth 1 https://github.com/FlorianBruniaux/claude-code-plugins
Per session 15 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,979 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 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.00015 $0.01979
Opus 5 $0.00008 $0.00989
Sonnet 5 $0.00003 $0.00396
Haiku 4.5 $0.00002 $0.00198

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

Security

Grade B, and why

git-worktree scanned grade B 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 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.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

**/.claude/settings.local.json
plugins/devops-pipeline/commands/git-worktree.md · 270 lines

How it starts

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

Git Worktree Setup

Create isolated git worktrees for feature development without switching branches.

Core principle: Smart directory selection + symlink optimization + background verification = fast, reliable isolation.

Requires: Git 2.5.0+ (July 2015)

Companion commands: /git-worktree-status | /git-worktree-remove | /git-worktree-clean

Process

  1. Validate Branch Name: Check naming convention and conflicts
  2. Check Existing Directories: .worktrees/ or worktrees/
  3. Verify .gitignore: Ensure worktree dir is ignored
  4. Create Worktree: git worktree add
  5. Symlink Dependencies: Reuse node_modules/ from main worktree
  6. Detect Database Provider: Check for DB branching capability
  7. Install Dependencies: Auto-detect package manager (if not symlinking)
  8. Run Background Verification: Type check + tests in background
  9. Report Location: Confirm ready with status

Flags

Flag Effect
--fast Skip dependency install and baseline tests
--isolated Fresh node_modules install (no symlink)
--skip-install Skip dependency install, keep baseline tests

Branch Name Validation

# Auto-prefix based on naming convention
# "auth" → "feat/auth" (default prefix)
# "fix/login-bug" → kept as-is
# "refactor/db-layer" → kept as-is

# Accepted prefixes: feat/, fix/, refactor/, chore/, docs/, test/, perf/
# If no prefix → default to feat/

# Reject invalid characters
echo "$BRANCH_NAME" | grep -qE '^[a-zA-Z0-9/_-]+$' || exit 1

# Check branch doesn't already exist
git show-ref --verify --quiet "refs/heads/$BRANCH_NAME" && echo "Branch already exists" && exit 1

Directory Selection

Priority Order

# 1. Check existing directories
ls -d .worktrees 2>/dev/null     # Preferred (hidden)
ls -d worktrees 2>/dev/null      # Alternative

# 2. Check CLAUDE.md for preference
grep -i "worktree.*director" CLAUDE.md 2>/dev/null

# 3. Ask user if neither exists

Read the full file on GitHub · 270 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. 2d ago First seen · 270 lines · 15 tokens per session scan B 19d02fc0b7d4

Subscribe to this mod's changes

git-worktree is a command published in the GitHub repository FlorianBruniaux/claude-code-plugins (40 stars, last pushed 2mo ago), licensed MIT. It adds 15 tokens to every session and 1,979 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.