worktree

A command for creating a Git worktree, which is a second working directory linked to the same repository. It also creates or switches to a branch for that directory.

In plain words
What is it for?
Use it to create an isolated branch workspace, choose a base branch, fetch the repository, and get the command for starting a separate Claude Code session.
Why use it?
It lets developers work on another branch in parallel without changing the files in their current working directory.

Command

Part of the holocron plugin — 11 skills, 24 commands, 14 agents, 6 hooks 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 commands/atuljha23/holocron/worktree
Clone the repo
git clone --depth 1 https://github.com/atuljha23/holocron

Or install holocron, the plugin that ships this one along with the rest of its 11 skills, 24 commands, 14 agents, 6 hooks.

Per session 40 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 491 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.00040 $0.00491
Opus 5 $0.00020 $0.00246
Sonnet 5 $0.00008 $0.00098
Haiku 4.5 $0.00004 $0.00049

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

Security

Grade A, and why

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.

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.

commands/worktree.md · 39 lines

What it actually says

/holocron:worktree

Set up a parallel worktree so you can work on a new branch without disturbing the current session.

Branch: $ARGUMENTS

Steps

  1. Detect the current repo root (git rev-parse --show-toplevel). If not inside a git repo, ask the user to cd into one first.
  2. Decide the base branch: parse --base <ref> from $ARGUMENTS; default to main if present, else master, else the current branch.
  3. Fetch: git fetch origin.
  4. Decide the worktree path: sibling directory at <repo-parent>/<repo-name>-<branch> (keep the original folder clean).
  5. List existing worktrees (git worktree list). If the target branch or path already has a worktree, warn and exit — don't overwrite.
  6. Create:
    • If the branch exists locally: git worktree add <path> <branch>.
    • If it exists only on origin: git worktree add --track -b <branch> <path> origin/<branch>.
    • If it doesn't exist anywhere: git worktree add -b <branch> <path> <base>.
  7. Print the launch line the user should run:
    cd <path> && claude
    
  8. Remind them: when the branch is merged and the work is done, clean up with
    git worktree remove <path>
    git branch -d <branch>   # or -D if it was force-pushed
    

Do not

  • Do not cd into the new worktree from this session — the current session stays put.
  • Do not force-remove an existing worktree.
  • Do not commit or push in this command; worktree creation is the whole job.
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 · 39 lines · 40 tokens per session scan A a06084fcb7fd

Subscribe to this mod's changes

worktree is a command published in the GitHub repository atuljha23/holocron (2 stars, last pushed 4mo ago), licensed MIT. It adds 40 tokens to every session and 491 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-31.