worktree

worktree is a skill for Claude Code, Codex from oprogramadorreal/optimus-claude. It costs 52 tokens per session (664 once invoked), scanned A, original, MIT.

A way to create a separate Git working directory and branch for an isolated development task.

In plain words
What is it for?
Use it to prepare an independent worktree, install the project dependencies, and record a baseline test result before development.
Why use it?
It lets multiple tasks or coding sessions proceed without changing the main workspace or interfering with one another.

Skill for Claude CodeCodex

Installs and runs on its own, but its text points at files inside its plugin — anything it tells you to read at a ${CLAUDE_PLUGIN_ROOT} path is only there once the plugin is installed. Installing the plugin gets both.

Part of the optimus plugin — 19 skills, 15 agents, 3 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 skills/oprogramadorreal/optimus-claude/worktree
Any agent
npx skills add oprogramadorreal/optimus-claude --skill worktree
Clone the repo
git clone --depth 1 https://github.com/oprogramadorreal/optimus-claude

Made for: Claude Code, Codex.

Or install optimus, the plugin that ships this one along with the rest of its 19 skills, 15 agents, 3 hooks.

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/oprogramadorreal/optimus-claude/worktree.svg)](https://agentmods.dev/skills/oprogramadorreal/optimus-claude/worktree)
Your own site
<a href="https://agentmods.dev/skills/oprogramadorreal/optimus-claude/worktree"><img src="https://agentmods.dev/badge/skills/oprogramadorreal/optimus-claude/worktree.svg" alt="Measured on agentmods" height="20"></a>
Per session 52 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 664 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.00052 $0.00664
Opus 5 $0.00026 $0.00332
Sonnet 5 $0.00010 $0.00133
Haiku 4.5 $0.00005 $0.00066

Measured 4d ago against content hash 81b1893c688f, 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 4d 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.

skills/worktree/SKILL.md · 59 lines

How it starts

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

Worktree

Create a git worktree under .worktrees/ on a new branch, with project setup and a test baseline. The main workspace stays on its original branch, so each worktree can host an independent Claude Code session.

Workflow

1. Target repo

If the current directory has no .git/ directory, read $CLAUDE_PLUGIN_ROOT/skills/init/references/multi-repo-detection.md and apply it. In a multi-repo workspace, run all git commands inside the target child repo: use the repo the user specified; if ambiguous, use AskUserQuestion — header "Target repo", question "Which repo should the worktree be created for?", one option per repo.

2. Detection guard

Read $CLAUDE_PLUGIN_ROOT/skills/worktree/references/worktree-setup.md and run its worktree detection guard. If already inside a linked worktree, tell the user:

Already running inside a worktree (`<worktree-path>`).
To create another worktree, run this skill from the main workspace instead.

Then stop — never create nested worktrees.

3. Branch

Note the current branch as <original-branch>. Derive the task description from the invocation argument or the conversation; if neither gives enough signal, ask what the user will work on — follow up until you have a concrete description, not a category. Read $CLAUDE_PLUGIN_ROOT/skills/commit/references/branch-naming.md for the <type>/<slug> convention and collision handling, then create the branch without switching:

git branch <branch-name>

4. Create worktree

Follow the Setup procedure from worktree-setup.md with <branch-name> and <original-branch>. On failure, follow its Failure handling, then stop.

5. Report

## Worktree Created

Working directory: `.worktrees/<worktree-dir>`
Branch: `<branch-name>` (from `<original-branch>`)
Main workspace: `<original-branch>` (unchanged)
Tests: passing / failing (pre-existing — N failures) / no test command detected

Open it: `code .worktrees/<worktree-dir>` (VSCode) or `cd .worktrees/<worktree-dir> && claude`
Cleanup when done: `git worktree remove .worktrees/<worktree-dir>`

Read the full file on GitHub · 59 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 4d ago First seen · 59 lines · 52 tokens per session scan A 81b1893c688f

Subscribe to this mod's changes

worktree is a skill published in the GitHub repository oprogramadorreal/optimus-claude (73 stars, last pushed yesterday), licensed MIT. It adds 52 tokens to every session and 664 once invoked, about $0.0003 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.