using-git-worktrees

using-git-worktrees is a skill for Claude Code from GanyuanRan/Aegis. It costs 35 tokens per session (1,643 once invoked), scanned A, original, MIT.

A guide to using Git worktrees, which are separate working folders connected to the same Git repository and different branches or commits.

In plain words
What is it for?
Use it to decide when a second checkout is necessary, inspect the repository state before creating one, and plan its cleanup afterward.
Why use it?
It helps avoid unsafe branch switching when the current folder has unfinished changes or another task needs a concurrent checkout.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: mentions CLAUDE.md; mentions subagents; mentions AGENTS.md.

Part of the aegis plugin — 23 skills, 1 hook shipped together

Good fit Use it to decide when a second checkout is necessary, inspect the repository state before creating one, and plan its cleanup afterward.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/ganyuanran/aegis/using-git-worktrees
About the project

Aegis is a method pack that guides coding agents to inspect a project's baseline, make bounded changes, and verify their work with fresh evidence. It is for people using coding-agent hosts who want fewer unverified changes and less unnecessary process. The catalogue add-ons implement this method through skills, instructions, commands, a hook, and a plugin.

GanyuanRan/Aegis · 1,460 stars · on GitHub · autoloom.codes

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.

Any agent
npx skills add GanyuanRan/Aegis --skill using-git-worktrees
Clone the repo
git clone --depth 1 https://github.com/GanyuanRan/Aegis

Made for: Claude Code.

Or install aegis, the plugin that ships this one along with the rest of its 23 skills, 1 hook.

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/ganyuanran/aegis/using-git-worktrees/github.svg)](https://agentmods.dev/skills/ganyuanran/aegis/using-git-worktrees)
Your own site
<a href="https://agentmods.dev/skills/ganyuanran/aegis/using-git-worktrees"><img src="https://agentmods.dev/badge/skills/ganyuanran/aegis/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/ganyuanran/aegis/using-git-worktrees"><img src="https://agentmods.dev/badge/skills/ganyuanran/aegis/using-git-worktrees.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 35 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,643 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. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.00035 $0.01643
Opus 5.5 $0.00014 $0.00657
Sonnet 5.5 $0.00007 $0.00329
Haiku 4.5 $0.00003 $0.00164

Measured 3mo ago against content hash 23e832a61b1b, 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 3mo 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.

skills/using-git-worktrees/SKILL.md · 173 lines

How it starts

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

Using Git Worktrees

Overview

A worktree is an exception for simultaneously checking out another Git history, not a general safety badge. Prefer the current workspace and reuse an existing suitable worktree. A branch decision and a worktree decision are separate.

Core principle: create only with necessity and ownership evidence; pair every created worktree with a cleanup path.

Announce at start: explain which concrete checkout conflict requires a worktree.

Step 0: Environment Detection

Before mutation, record the repository root, HEAD, branch/detached state, staged/unstaged/untracked paths, active Git operations, and:

git worktree list --porcelain

Classify the current host surface's task/chat-bound managed workspace semantics as managed, non-managed, or unknown. Use trusted host/session context, an explicit host contract, or a host-native lifecycle result; do not infer the classification from a product name, directory prefix, command-level workdir, missing tool, or absent metadata. non-managed requires positive evidence that the current surface lacks task-bound managed semantics. When the host exposes workspace fields, record the task workspace and the command's default cwd without a per-command directory override.

Stop on unresolved conflicts, an active merge/rebase/cherry-pick/revert/bisect, or an unexplained detached HEAD. A detached HEAD is acceptable only when trusted host binding evidence identifies it as the intended state of the current managed worktree; Codex-managed worktrees, for example, start detached by default. Preserve user state: no automatic stash, reset, clean, broad staging, or commit.

Before deciding necessity or placement, read the smallest relevant project AGENTS.md, CLAUDE.md, current authority, and existing worktree convention. Repository policy may require or forbid isolation and owns any approved in-repo location; do not discover that policy after creating the checkout.

Step 1: Necessity Decision

Read the full file on GitHub · 173 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. 3mo ago First seen · 173 lines · 35 tokens per session scan A 23e832a61b1b

Subscribe to this mod's changes

using-git-worktrees is a skill published in the GitHub repository GanyuanRan/Aegis (1,460 stars, last pushed yesterday), licensed MIT. It adds 35 tokens to every session and 1,643 once invoked, about $0.0001 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-08-30.

Related

using-git-worktrees compared with skills from other repositories

using-git-worktrees next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
using-git-worktreesGanyuanRan/AegisSkill1.5kyesterdayMITA35Claude Code
repo-hygieneQwenLM/qwen-codeSkill31ktodayApache-2.0A48Claude Code, Codex
chinese-git-workflowjnMetaCode/superpowers-zhSkill8.7k2d agoMITA69Claude Code
chinese-commit-conventionsjnMetaCode/superpowers-zhSkill8.7k2d agoMITA65Claude Code
about-thinkrailJetBrains/thinkrailSkill8.5ktodayApache-2.0A153Claude Code, Codex
review-deltatirth8205/code-review-graphSkill33k16d agoMITA24Claude Code
fanouthashgraph-online/awesome-codex-pluginsSkill1.6ktodayApache-2.0A68Claude Code, Codex