git-worktrees

git-worktrees is a skill for Claude Code, Codex from Zfinix/aster. It costs 49 tokens per session (776 once invoked), scanned C, original, Apache-2.0.

A workflow for using a Git worktree, which is a separate working directory linked to the same repository and branches. It keeps another branch isolated from the checkout currently in use.

In plain words
What is it for?
Use it to prepare a separate directory for a fix, feature, build, or test when the current checkout must remain unchanged.
Why use it?
It prevents unfinished edits, a dirty working tree, or a running build from being disturbed while different work is checked out. It also helps avoid branch conflicts and untracked files in the repository.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to prepare a separate directory for a fix, feature, build, or test when the current checkout must remain unchanged.

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

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/zfinix/aster/git-worktrees.svg)](https://agentmods.dev/skills/zfinix/aster/git-worktrees)
Your own site
<a href="https://agentmods.dev/skills/zfinix/aster/git-worktrees"><img src="https://agentmods.dev/badge/skills/zfinix/aster/git-worktrees.svg" alt="Measured on agentmods" height="20"></a>
Per session 49 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 776 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. 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.00049 $0.00776
Opus 5 $0.00024 $0.00388
Sonnet 5 $0.00010 $0.00155
Haiku 4.5 $0.00005 $0.00078

Measured today against content hash cc1854759174, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade C, and why

git-worktrees scanned grade C with 1 finding 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 today.

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.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

agreed outcome. `rm -rf` by hand leaves a `prunable` entry; repair with
crates/aster-skills/builtins/internal/git-worktrees/SKILL.md · 48 lines

What it actually says

Git worktrees

  1. Reach for a worktree only when the current checkout must stay put. The user is mid-edit, the tree is dirty, or a long build is running and the task needs a different branch. A clean idle tree does not need one: git stash or a plain git checkout is simpler.
  2. List before creating. git worktree list first; pick a path and branch that are not already taken.
  3. Create with an explicit branch. New branch: git worktree add <path> -b <branch>. Existing branch: git worktree add <path> <branch>. A branch checked out in one worktree cannot be checked out in another: fatal: '<branch>' is already used by worktree at '<path>'. Pick a new branch name instead of forcing it.
  4. Put the worktree where the sandbox can write and git will not sweep it. Inside the repo under a gitignored path (<repo>/target/wt/<name>) or in /tmp. A sibling directory outside the repo fails the filesystem write policy, and an untracked directory inside the repo pollutes git status and git add sweeps. Verify the path is actually ignored with git check-ignore -q <path>; if it is not, add it to .git/info/exclude rather than editing the user's .gitignore.
  5. Know what is shared. Commits and branches are shared through the one object store: a commit made in the worktree is immediately visible from the main checkout. HEAD, the index, and untracked files are per-worktree. Build artifacts (target/, node_modules/) are not shared either: the first build in a fresh worktree is a full cold build. Budget for it and say so if it will be slow.
  6. Run checks inside the worktree. cd <path> first, then the project's own verbs (make test, cargo test -p <crate>). Running them from the main repo tests the wrong tree.
  7. Remove with git, not with rm. git worktree remove <path> when the work is done. It refuses a dirty tree: contains modified or untracked files, use --force to delete it. Reset or clean the tree first, or use --force only when losing the changes is the agreed outcome. rm -rf by hand leaves a prunable entry; repair with git worktree prune -v.
  8. The branch outlives the worktree. Removing the worktree keeps its branch. Delete it too when the work was abandoned (git branch -D counts as destructive: say what is being deleted and why).
  9. Never mv a worktree directory. It breaks the gitdir link. Use git worktree move <path> <new-path>.
  10. Leave no worktrees behind. A worktree created for one task is removed in the same session once its check ran, unless the user asked to keep it. git worktree list at the end of the task proves the cleanup.
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. today First seen · 48 lines · 49 tokens per session scan C cc1854759174

Subscribe to this mod's changes

git-worktrees is a skill published in the GitHub repository Zfinix/aster (57 stars, last pushed today), licensed Apache-2.0. It adds 49 tokens to every session and 776 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-07.