git-worktree

git-worktree is a skill for Claude Code from KunanonJ/ai-skills-hub. It costs 15 tokens per session (2,008 once invoked), scanned B, a copy of git-worktree, MIT.

A workflow for creating isolated Git worktrees for feature development. A worktree is a separate working directory connected to the same Git repository, so another branch can be used without switching the current one.

In plain words
What is it for?
Use it to create a separate feature directory, reuse or install dependencies, validate branch names, run initial checks, and report the worktree's location.
Why use it?
It lets developers work on a feature without disrupting their current files or branch, while checking dependencies and baseline tests.

Skill for Claude Code

Written for Claude Code: disable-model-invocation in frontmatter. Also seen: mentions CLAUDE.md; installed under .agents/ (shared by several agents).

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is if [ -d "../../node_modules" ] && [ ! "$ISOLATED" = true ]; then.

Good fit Use it to create a separate feature directory, reuse or install dependencies, validate branch names, run initial checks, and report the worktree's location.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/KunanonJ/ai-skills-hub
agentmods
npx agentmods add skills/kunanonj/ai-skills-hub/git-worktree

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-worktree

README.md
[![agentmods](https://agentmods.dev/badge/skills/kunanonj/ai-skills-hub/git-worktree.svg)](https://agentmods.dev/skills/kunanonj/ai-skills-hub/git-worktree)
Your own site
<a href="https://agentmods.dev/skills/kunanonj/ai-skills-hub/git-worktree"><img src="https://agentmods.dev/badge/skills/kunanonj/ai-skills-hub/git-worktree.svg" alt="Measured on agentmods" height="20"></a>
Per session 15 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,008 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin 100% copy Near-identical to another mod 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.00015 $0.02008
Opus 5 $0.00008 $0.01004
Sonnet 5 $0.00003 $0.00402
Haiku 4.5 $0.00002 $0.00201

Measured 8d ago against content hash ea118092d5f4, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, 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 8d 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
Origin

This is a copy

100% identical to git-worktree — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.agents/skills/git-worktree/SKILL.md · 273 lines

How it starts

The opening of the file, as written. The whole thing — 273 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 · 273 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. 8d ago First seen · 273 lines · 15 tokens per session scan B ea118092d5f4

Subscribe to this mod's changes

git-worktree is a skill published in the GitHub repository KunanonJ/ai-skills-hub (5 stars, last pushed 1mo ago), licensed MIT. It adds 15 tokens to every session and 2,008 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it B with 1 finding (reads agent configuration directories). It is 100% identical to git-worktree, differing in 0 lines, and is treated as a copy.

Related

Other skills, from other repositories

safe-extraction

Apply when extracting code from a large monolith file into submodules. Covers barrel re-exports, internals DI seam proxy patterns, CI invariant allowlist updates, and cross-file test verification. Prevents CI failures, broken imports, and test regressions from code extraction.

ZaxbyHub/opencode-swarm · 60 tokens

git-revert-safety

Apply when reverting commits, undoing merges, or recovering from branch contamination. Covers collateral damage verification (manifest, package.json, CHANGELOG, lockfiles), cherry-pick vs revert decision matrix, partial-revert detection, merge-parent handling, and post-revert CI verification. Prevents the most common…

ZaxbyHub/opencode-swarm · 79 tokens

commit-pr

Mandatory Codex/Copilot publication adapter for opencode-swarm. Use for every GitHub issue assignment that results in code changes, commits, pushes, draft PRs, PR body edits, PR readying, release notes, or CI closeout. Must be loaded before git push, gh pr create, gh pr edit, or gh pr ready. Routes to the single…

ZaxbyHub/opencode-swarm · 100 tokens

fork-pr-operations

Operational patterns for fork PRs (head repo differs from base repo). Covers GitHub workflow approval after push, force-push protocol, remote naming conventions, stale CI verification, and bot review multi-round awareness. Load when working with fork PRs, cross-repo contributions, or workflow approval issues.

ZaxbyHub/opencode-swarm · 65 tokens

parallel-work-check

Apply before starting work on an existing branch. Checks for parallel work by other agents or developers that may supersede or conflict with your planned changes. Prevents wasted effort on stale branches.

ZaxbyHub/opencode-swarm · 41 tokens

merge-queue-readiness

Pre-queue merge-group CI simulation. Triggered before adding a PR to a GitHub merge queue. Prevents merge-queue kick-outs from integration test failures.

ZaxbyHub/opencode-swarm · 39 tokens