git-worktrees

git-worktrees is a skill for Claude Code, Codex from ayberkcansever/ai-skills. It costs 83 tokens per session (1,096 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.

Good fit Use it when a task needs its own Git worktree, including checking…

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.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.svg" alt="Measured on agentmods" height="20"></a>
Per session 83 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,096 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.00083 $0.01096
Opus 5 $0.00042 $0.00548
Sonnet 5 $0.00017 $0.00219
Haiku 4.5 $0.00008 $0.00110

Measured 6d ago against content hash 1e798baa4348, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, 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 6d 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/cursor/git-worktrees/SKILL.md · 112 lines

How it starts

The opening of the file, as written. The whole thing — 112 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.

If your harness offers a native worktree tool, use it and skip the manual steps. Otherwise:

# .worktrees/ must be ignored — check before creating
git check-ignore -q .worktrees || echo ".worktrees/" >> .gitignore

Then pick the mode by what the branch already is — a branch can be checked out in only one worktree at a time, so this is a git constraint, not a preference:

Read the full file on GitHub · 112 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. 6d 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 2d ago), licensed MIT. It adds 83 tokens to every session and 1,096 once invoked, about $0.0004 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-31.

Related

Other skills, from other repositories

pr-review

Use when opening, reviewing, or merging a pull request. Covers pre-PR checks (linting, tests, branch naming), PR description requirements, and post-merge cleanup. Not for code review commentary or architecture decisions — use the relevant role guidelines for those.

desikai-lab/Marrow · 59 tokens

deployment-patterns

Deployment workflows, CI/CD pipeline patterns, Docker containerization, health checks, rollback strategies, and production readiness checklists for web applications. Use when setting up deployment infrastructure or planning releases.

affaan-m/ECC · 41 tokens

contextual-commit

Write contextual commits that capture intent, decisions, and constraints alongside code changes. Use when committing code, finishing a task, or when the user asks to commit. Extends Conventional Commits with structured action lines in the commit body that preserve WHY code was written, not just WHAT changed.

yamadashy/repomix · 62 tokens

gentle-ai-collab-perfect

Trigger: contributing to Gentleman-Programming/gentle-ai as an external collaborator. Strict issue-first workflow, honest PR bodies, contributor-vs-maintainer scope, chained-PR strategy, verification protocol, docstring coverage. Load whenever the active repo is Gentleman-Programming/gentle-ai and any part of the…

Gentleman-Programming/gentle-ai · 106 tokens

branch-pr

Create Gentle AI pull requests with issue-first checks. Trigger: creating, opening, or preparing PRs for review.

Gentleman-Programming/gentle-ai · 26 tokens

work-unit-commits

Plan commits as reviewable work units. Trigger: implementation, commit splitting, chained PRs, or keeping tests and docs with code.

Gentleman-Programming/gentle-ai · 33 tokens