worktree

worktree is a skill for Claude Code from TechDufus/oh-my-claude. It costs 39 tokens per session (3,713 once invoked), scanned C, original, MIT.

Git worktree automation for creating separate working directories and branches for feature development. A Git worktree lets you work on another branch without changing the files in your current directory.

In plain words
What is it for?
Use it to create, list, inspect, or remove worktrees with commands such as /worktree create and /worktree list.
Why use it?
It isolates feature work and can copy environment settings, install dependencies, update Git ignore rules, and verify the new directory.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: positional $N argument.

Part of the oh-my-claude plugin — 12 skills, 1 command, 7 agents, 8 hooks, 2 MCP servers 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 skills/techdufus/oh-my-claude/worktree
Any agent
npx skills add TechDufus/oh-my-claude --skill worktree
Clone the repo
git clone --depth 1 https://github.com/TechDufus/oh-my-claude

Made for: Claude Code.

Or install oh-my-claude, the plugin that ships this one along with the rest of its 12 skills, 1 command, 7 agents, 8 hooks, 2 MCP servers.

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 worktree

README.md
[![agentmods](https://agentmods.dev/badge/skills/techdufus/oh-my-claude/worktree.svg)](https://agentmods.dev/skills/techdufus/oh-my-claude/worktree)
Your own site
<a href="https://agentmods.dev/skills/techdufus/oh-my-claude/worktree"><img src="https://agentmods.dev/badge/skills/techdufus/oh-my-claude/worktree.svg" alt="Measured on agentmods" height="20"></a>
Per session 39 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,713 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. 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.1 $0.00039 $0.03713
Opus 5 $0.00019 $0.01857
Sonnet 5 $0.00008 $0.00743
Haiku 4.5 $0.00004 $0.00371

Measured 6d ago against content hash 291ee1b5e437, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade C, and why

worktree 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 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.

Recursive force deletehighDestructive command

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

$ rm -rf .worktrees/auth-feature
plugins/oh-my-claude/skills/worktree/SKILL.md · 537 lines

How it starts

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

Worktree Skill

Git worktree automation for isolated feature development.

When This Skill Activates

Category Trigger Phrases
Create worktree /worktree create <name>, /worktree new <name>
List worktrees /worktree list, /worktree ls
Remove worktree /worktree remove <name>, /worktree rm <name>
Status /worktree status

Commands

Create Worktree

/worktree create <feature-name>

Creates an isolated worktree for feature development.

Workflow:

  1. Generate branch name: feat/<feature-name>
  2. Create worktree: git worktree add .worktrees/<feature-name> -b feat/<feature-name>
  3. Copy environment files (if they exist):
    • .env, .env.local, .env.development
    • .nvmrc, .node-version
    • .npmrc
  4. Detect and run package manager install:
    • If package-lock.jsonnpm install
    • If yarn.lockyarn install
    • If pnpm-lock.yamlpnpm install
    • If bun.lockbbun install
  5. Add .worktrees/ to .gitignore if not present
  6. Verify worktree creation:
    • Run git -C .worktrees/<name> status to confirm clean state
    • Run git worktree list to confirm worktree is registered
    • If verification fails, run cleanup and report error
  7. Report path and instructions

Example:

git worktree add .worktrees/auth-feature -b feat/auth-feature
cp .env .worktrees/auth-feature/ 2>/dev/null || true
cp .nvmrc .worktrees/auth-feature/ 2>/dev/null || true
cd .worktrees/auth-feature && npm install

List Worktrees

/worktree list

Shows all active worktrees:

git worktree list

Remove Worktree

/worktree remove <name>

Removes a worktree and optionally its branch:

Workflow:

  1. Confirm removal with user
  2. Remove worktree: git worktree remove .worktrees/<name> --force
  3. Ask if branch should be deleted
  4. If yes: git branch -D feat/<name>

Status

/worktree status

Read the full file on GitHub · 537 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 · 537 lines · 39 tokens per session scan C 291ee1b5e437

Subscribe to this mod's changes

worktree is a skill published in the GitHub repository TechDufus/oh-my-claude (176 stars, last pushed 1mo ago), licensed MIT. It adds 39 tokens to every session and 3,713 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-08-30.