git-worktrees

git-worktrees is a skill for Claude Code, Codex from ayberkcansever/ai-skills. It costs 53 tokens per session (1,195 once invoked), scanned A, original, MIT.

An isolated copy of a Git repository for working on one ticket without changing the main checkout. It can detect and reuse an existing worktree or create one under `.worktrees/`.

In plain words
What is it for?
Use it when a task needs its own Git worktree, including checking whether isolation already exists, creating or attaching a worktree, and verifying the setup.
Why use it?
It prevents unfinished or conflicting changes from affecting the checkout you are already using. It also lets several tickets be worked on at the same time in one repository.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: mentions Claude Code.

Good fit Use it when a task needs its own Git worktree, including checking whether isolation already exists, creating or attaching a worktree, and verifying the setup.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/ayberkcansever/ai-skills/git-worktrees
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 ayberkcansever/ai-skills --skill git-worktrees
Clone the repo
git clone --depth 1 https://github.com/ayberkcansever/ai-skills

Made for: Claude Code, Codex.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/ayberkcansever/ai-skills/git-worktrees/github.svg)](https://agentmods.dev/skills/ayberkcansever/ai-skills/git-worktrees)
Your own site
<a href="https://agentmods.dev/skills/ayberkcansever/ai-skills/git-worktrees"><img src="https://agentmods.dev/badge/skills/ayberkcansever/ai-skills/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 git-worktrees

Your own site · 80×15
<a href="https://agentmods.dev/skills/ayberkcansever/ai-skills/git-worktrees"><img src="https://agentmods.dev/badge/skills/ayberkcansever/ai-skills/git-worktrees.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 53 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,195 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.00053 $0.01195
Opus 5.5 $0.00021 $0.00478
Sonnet 5.5 $0.00011 $0.00239
Haiku 4.5 $0.00005 $0.00120

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

Security

Grade A, and why

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.

sdlc/git-worktrees/SKILL.md · 117 lines

How it starts

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

Git Worktrees

Ensure work happens in an isolated workspace without disturbing the current checkout. Detect first. Consent only when the user invoked this skill directly; execute-plan skips the consent question, not this skill.

Announce at start: "I'm using the git-worktrees skill to set up an isolated workspace."

Step 1: Detect existing isolation

GIT_DIR=$(cd "$(git rev-parse --git-dir)" && pwd -P)
GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" && pwd -P)
git worktree list
  • GIT_DIR != GIT_COMMON → already in a linked worktree. Report path + branch, skip to Step 3. Exception: if git rev-parse --show-superproject-working-tree prints a path, you are in a submodule, not a worktree — treat as normal repo.
  • git worktree list already shows a worktree for this ticket → cd into it and skip to Step 3. Never create a second one for the same ticket.
  • Current branch already matches this ticket (git branch --show-current contains the ticket key) → this checkout is the venue. Skip Step 2. Go to Step 3.
  • GIT_DIR == GIT_COMMON and no ticket worktree → normal checkout, continue.

Step 2: Create the worktree

Consent: ask once, unless the user already told you their preference —

"Set up an isolated worktree? It protects your current branch and uncommitted work."

If declined, stop. Do not execute in the current checkout. Invoked from execute-plan, consent is implied and this question is skipped: execute-plan only reaches this skill when the checkout is not already on the ticket branch.

Path is .worktrees/<branch-name>; branch name follows repo conventions — ticket key first, e.g. PROJ-123-short-description.

Native worktree tools never create the worktree. Harness tools such as Claude Code's EnterWorktree pick their own path (.claude/worktrees/<name>) and branch (worktree-<name>), which breaks the .worktrees/<branch> and <TICKET-ID>-<slug> contract execute-plan depends on. Always create with the git worktree commands below. After creating, a harness that can enter an existing worktree by path (Claude Code: EnterWorktree with path: .worktrees/<branch>) may do so to bind the session's cwd and isolation to the venue — that is optional; cd is sufficient.

Read the full file on GitHub · 117 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 Changed · +6 lines 1760e1a16a69
  2. 1mo ago Changed · -1 lines · -30 tokens per session 86f8b7bd3c48
  3. 1mo ago First seen · 112 lines · 83 tokens per session scan A 1e798baa4348

Subscribe to this mod's changes

git-worktrees is a skill published in the GitHub repository ayberkcansever/ai-skills (2 stars, last pushed 25d ago), licensed MIT. It adds 53 tokens to every session and 1,195 once invoked, about $0.0002 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-31.

Related

Other skills, from other repositories