git-worktree

A workflow for creating and managing separate Git worktrees, which are extra working folders linked to one repository. It supports new branches, listing worktrees, removing owned worktrees, and identifying possible cleanup candidates after approval.

In plain words
What is it for?
Use it to inspect the repository setup, plan and create a worktree for a new branch, list existing worktrees, remove a worktree it owns, or review worktrees that may be pruned.
Why use it?
It keeps branch work isolated while following one repository folder convention. It also checks that the worktree folder is excluded from Git before creating it.

Skill for Claude CodeCodex

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/bahayonghang/my-ai-cli-toolkit/git-worktree
Any agent
npx skills add bahayonghang/my-ai-cli-toolkit --skill git-worktree
Clone the repo
git clone --depth 1 https://github.com/bahayonghang/my-ai-cli-toolkit

Made for: Claude Code, Codex.

Per session 135 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,175 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.00135 $0.01175
Opus 5 $0.00068 $0.00588
Sonnet 5 $0.00027 $0.00235
Haiku 4.5 $0.00014 $0.00118

Measured 2d ago against content hash bb853ea9f67b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

git-worktree 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 2d ago.

The scan reads SKILL.md. This mod also ships 2 executable files (scripts/worktree_convention.py, tests/worktree-convention.test.mjs), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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/git-github-collaboration/git-worktree/SKILL.md · 92 lines

How it starts

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

In the commands below, <skill-dir> is this skill's base directory, announced when the skill loads. Substitute the literal path. On Windows, py -3 may replace python.

Use this workflow: inspect -> plan-create (ensures ignore) -> authorized execute -> record.

Routing

  • Isolation worktree create / list / owned remove / authorized prune: this skill.
  • Commit, split, checkpoint: git-commit.
  • PR, review, merge, CI, Release, tag-build detached worktree: gh-pr-release.
  • GitHub template bootstrap: gh-bootstrap.
  • Adopt an existing foreign worktree, or add a worktree for an existing branch: refuse. MVP is --mode new-branch only.

If a native harness worktree tool exists, run the helper first. Call the native tool only when inspect/plan JSON already contains worktree_path and ok_to_create=true. Do not let the native tool pick an unchecked path.

1. Inspect

From the repository root:

python "<skill-dir>/scripts/worktree_convention.py" inspect --repo-root <abs-repo> [--explicit-root <rel>] [--branch <name>]

Read resolved_root, resolution_reason, registered_in_repo_roots, already_linked, gitignore_covers, and write_required.

If already_linked is true and the user asked to create: report the current tree and stop. Do not nest worktrees.

This repository may already have a registered root such as .claude/worktrees. Do not invent a second default root.

2. Ignore gate (before any add)

Matching authority is git check-ignore -v -z --stdin. The helper already runs that.

A create request authorizes appending one planned <resolved_root>/ line to the repository .gitignore. plan-create does that when write_required is true. Do not wait for a second confirmation. Do not git add or git commit the ignore line.

  • After plan-create, gitignore_covers must be true before executing argv.
  • If write_required is still true (ignore_gate in refusals), stop.
  • Global excludes or .git/info/exclude alone are not enough.

Read the full file on GitHub · 92 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. 2d ago First seen · 92 lines · 135 tokens per session scan A bb853ea9f67b

Subscribe to this mod's changes

git-worktree is a skill published in the GitHub repository bahayonghang/my-ai-cli-toolkit (16 stars, last pushed 3d ago), licensed MIT. It adds 135 tokens to every session and 1,175 once invoked, about $0.0007 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

using-git-worktrees

Isolates each task in its own git worktree off main.

andreaswasita/copilot-agents-dojo · 20 tokens

repository-manager-lane-lifecycle

Run one unit of work — one agent session or one person — as an isolated lane in a repository many other lanes are editing at the same time. Covers opening a lane (worktree + partitioned build/test/hook state), staying isolated while working, diagnosing a lane that is behaving impossibly, and closing it out. Use…

Knuckles-Team/repository-manager · 156 tokens

trace-and-isolate

Applies systematic tracing and isolation techniques to pinpoint exactly where a bug originates in code. Use when a bug is hard to locate, code is not working as expected, an error or crash appears with unclear cause, a regression was introduced between recent commits, or you need to narrow down which component…

rohitg00/skillkit · 120 tokens

git-worktree-workspaces

Sets up and uses Git worktrees for parallel task workspaces in the same repository clone, including safe cleanup of local worktrees. Invoked when the user asks to work on multiple branches at once, isolate tasks without extra clones, or create/remove worktrees.

soulcodex/agentic · 58 tokens

containment

Provides structured incident containment strategies mapped to NIST SP 800-61 Rev 2 and MITRE ATT&CK techniques. Auto-invoked when a confirmed incident requires isolation decisions, credential revocation, network segmentation, or DNS sinkholing. Produces a containment plan with short-term and long-term actions…

UnitOneAI/SecuritySkills · 80 tokens

spawnpoint

This skill should be used when an agent needs to create, list, extend, or remove multi-repo git worktree workspaces using the spawnpoint CLI (binary spawnpoint, shell wrapper sp). Use it when a task involves spinning up isolated worktrees for a feature branch across one or more repos, finding existing workspaces…

mihirgupta0900/spawnpoint · 118 tokens