using-git-worktrees

using-git-worktrees is a skill for Claude Code, Codex 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 CodeCodex

Part of the Aegis plugin — 22 skills, 3 commands, 1 hook shipped together

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/ganyuanran/aegis/using-git-worktrees
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, Codex.

Or install Aegis, the plugin that ships this one along with the rest of its 22 skills, 3 commands, 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.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.svg" alt="Measured on agentmods" 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. 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.00035 $0.01643
Opus 5 $0.00017 $0.00822
Sonnet 5 $0.00007 $0.00329
Haiku 4.5 $0.00003 $0.00164

Measured 4d ago against content hash 23e832a61b1b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 4d 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. 4d 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,154 stars, last pushed 5d ago), licensed MIT. It adds 35 tokens to every session and 1,643 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-08-30.

Related

Other skills, from other repositories

rulesync

Generates and syncs AI rule configuration files (.cursorrules, CLAUDE.md, copilot-instructions.md) across 20+ coding tools from a single source. Use when syncing AI rules, running rulesync commands, importing or generating rule files, or managing shared AI coding configurations.

dyoshikawa/rulesync · 64 tokens

autoprompt

Explicit-only useful-first orchestration. Invoke /autoprompt to turn a mission into one executable roadmap, build dependency-safe lanes, and verify the result with independent reviewers. Never infer invocation from ordinary requests. Never resume from leftover artifacts without an explicit resume instruction.

Spielewoy/autoprompt-skill · 56 tokens

loongsuite-pilot-insight

基于 LoongSuite Pilot / AI Coding Agent 日志生成事件洞察、组织洞察、数据质量、研发效能和 AI Native 使用类 SLS 报表时使用;包含 AI Coding 事件表语义,以及团队报表可选的部门维表、deptuser 组织关系、指标口径和公共 CTE,通常与 sls-dashboard-builder 一起使用。.

alibaba/loongsuite-pilot · 91 tokens

map-fast

Minimal workflow for small, low-risk changes — no planning, no learning.

azalio/map-framework · 17 tokens

alipay-webhooks

Receive and verify Alipay (Antom / Alipay+) webhook notifications. Use when setting up Alipay webhook handlers, debugging RSA256 Signature header verification, or handling payment events like notifyPayment, notifyCapture, notifyRefund, notifyAuthorization, and notifyDispute.

hookdeck/webhook-skills · 58 tokens

clio-webhooks

Receive and verify Clio (Clio Manage) webhooks. Use when setting up Clio webhook handlers, debugging X-Hook-Signature verification, completing the X-Hook-Secret handshake, or handling legal practice events like matter.created, contact.updated, activity.created, or bill events.

hookdeck/webhook-skills · 64 tokens