using-git-worktrees

using-git-worktrees is a skill for Claude Code from phuonghx/aim-cli. It costs 77 tokens per session (1,111 once invoked), scanned A, original, MIT.

A guide to Git worktrees, which are separate working folders connected to the same Git repository, each with its own branch and files.

In plain words
What is it for?
Use it for parallel feature work, urgent hotfixes, side-by-side branch reviews, or long-running builds that should not interrupt another checkout.
Why use it?
They let developers work on branches side by side without stashing unfinished changes or cloning the repository again. This reduces collisions when tasks, agents, or builds run in parallel.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is git worktree add ../proj-feature -b feature/login.

Good fit Use it for parallel feature work, urgent hotfixes, side-by-side branch reviews, or long-running builds that should not interrupt another checkout.

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/phuonghx/aim-cli
agentmods
npx agentmods add skills/phuonghx/aim-cli/using-git-worktrees

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 using-git-worktrees

README.md
[![agentmods](https://agentmods.dev/badge/skills/phuonghx/aim-cli/using-git-worktrees/github.svg)](https://agentmods.dev/skills/phuonghx/aim-cli/using-git-worktrees)
Your own site
<a href="https://agentmods.dev/skills/phuonghx/aim-cli/using-git-worktrees"><img src="https://agentmods.dev/badge/skills/phuonghx/aim-cli/using-git-worktrees/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for using-git-worktrees

Your own site · 80×15
<a href="https://agentmods.dev/skills/phuonghx/aim-cli/using-git-worktrees"><img src="https://agentmods.dev/badge/skills/phuonghx/aim-cli/using-git-worktrees.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 77 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,111 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.00077 $0.01111
Opus 5.5 $0.00031 $0.00444
Sonnet 5.5 $0.00015 $0.00222
Haiku 4.5 $0.00008 $0.00111

Measured 1mo ago against content hash 741f1099ad7b, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

using-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 1mo 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.

aim/templates/aim-agents/skills/using-git-worktrees/SKILL.md · 127 lines

How it starts

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

Using Git Worktrees

One repo, many checkouts — parallel branches without stashing or cloning.

A worktree is a second working directory backed by the same .git. Each tree has its own branch, index, and files, so agents never fight over one checkout.


When to Use

✅ Good for:

  • Parallel agents each owning a branch (build, refactor, docs at once)
  • Urgent hotfix while a feature is half-done — no git stash dance
  • Reviewing/testing branch B without disturbing branch A
  • Long builds: keep working in tree A while tree B compiles

❌ Not for:

  • A single linear branch (just use the main checkout)
  • Editing the same branch from two trees (Git forbids it anyway)
  • Throwaway one-liners where switching is faster

Core Commands

# Create a new tree + branch in one step (sibling dir, NOT nested in repo)
git worktree add ../proj-feature -b feature/login

# Attach an existing branch
git worktree add ../proj-hotfix hotfix/crash

# Detached checkout of a tag/commit for inspection
git worktree add --detach ../proj-v1 v1.2.0

# See every tree, its branch, and HEAD
git worktree list

# Remove a tree when done (must be clean, or add --force)
git worktree remove ../proj-feature

# Drop bookkeeping for trees deleted manually from disk
git worktree prune

Conventions

Rule Why
Put trees as siblings (../proj-feature), never inside the repo A nested tree gets swept into Git status and ignore rules
One branch per tree Git refuses to check out the same branch twice; keeps ownership clear
Name the dir after the branch (proj-<slug>) git worktree list becomes self-documenting
One agent ↔ one tree Isolates state; merge happens only at the end
Branch off the same base (-b feat origin/main) Predictable, conflict-light merges

Workflow Example

# 0. Start from an up-to-date main
git -C ./proj fetch origin

# 1. Spin up two isolated trees for two agents
git -C ./proj worktree add ../proj-api   -b feat/api   origin/main
git -C ./proj worktree add ../proj-ui    -b feat/ui    origin/main

# 2. Each tree installs its OWN deps (not shared — see pitfalls)
( cd ../proj-api && npm ci )
( cd ../proj-ui  && npm ci )

# 3. Agents work in parallel, commit on their branches...

# 4. Merge back from the canonical tree
git -C ./proj merge --no-ff feat/api
git -C ./proj merge --no-ff feat/ui      # resolve conflicts once, here

# 5. Tear down
git -C ./proj worktree remove ../proj-api
git -C ./proj worktree remove ../proj-ui
git -C ./proj worktree prune

Read the full file on GitHub · 127 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. 1mo ago First seen · 127 lines · 77 tokens per session scan A 741f1099ad7b

Subscribe to this mod's changes

using-git-worktrees is a skill published in the GitHub repository phuonghx/aim-cli (1 stars, last pushed 3mo ago), licensed MIT. It adds 77 tokens to every session and 1,111 once invoked, about $0.0003 per session on Opus 5.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.

Related

Other skills, from other repositories

session-wrap

Wrap up the current coding session by creating PRs, updating the session log, preparing the next session md, and updating the claude md with learnings.

mattmre/EVOKORE-MCP-PUBLIC · 35 tokens

session-checkpoint

Use when you want to save a timestamped snapshot of current session state (tasks, evidence, purpose) to docs/session-logs/ for crash recovery or handoff.

mattmre/EVOKORE-MCP-PUBLIC · 38 tokens

todos

Use when the user asks for a shared plan, a task needs at least three substantive execution steps, or a loose TODO is pending. Without an explicit plan request, not for one-shot answers or checks, or one- to two-step work that is not already in the list.

JetBrains/thinkrail · 58 tokens

shipping-a-pr

Use when finished work needs to ship as a pull request, or when creating, syncing, updating metadata, checking status, monitoring CI, or addressing review comments on a PR. Not for reviewing a PR you are not shipping.

JetBrains/thinkrail · 49 tokens

git-flow

Use this skill when committing, branching, opening a pull request, resolving conflicts, or recovering from a git mistake in any repository. Triggers: user mentions "commit", "branch", "PR", "pull request", "merge", "rebase", "conflict", "stash", "cherry-pick", "revert", "bisect", "reflog", "force push".

WrongStack/WrongStack · 83 tokens

codebase-navigation

Use this skill when starting work in an unfamiliar codebase or area — finding where something is implemented, how a request flows, what depends on a piece of code, or where a change should go — before reading files one by one. Triggers: user says "where is", "how does this work", "find the code that", "explain this…

WrongStack/WrongStack · 103 tokens