worktree

worktree is a skill for Claude Code, Codex from murray17/rovai-ai. It costs 66 tokens per session (1,806 once invoked), scanned A, original, MIT.

A Git feature for creating separate working folders linked to different branches of the same repository. Each folder can hold an independent piece of development work.

In plain words
What is it for?
Use it to create, inspect, reuse, hand over, or clean up an isolated development folder for a specific task.
Why use it?
It lets developers work on separate changes without repeatedly switching branches or mixing unfinished edits. Existing worktrees and branches can also be found and reused.

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

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 worktree

README.md
[![agentmods](https://agentmods.dev/badge/skills/murray17/rovai-ai/worktree.svg)](https://agentmods.dev/skills/murray17/rovai-ai/worktree)
Your own site
<a href="https://agentmods.dev/skills/murray17/rovai-ai/worktree"><img src="https://agentmods.dev/badge/skills/murray17/rovai-ai/worktree.svg" alt="Measured on agentmods" height="20"></a>
Per session 66 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,806 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.1 $0.00066 $0.01806
Opus 5 $0.00033 $0.00903
Sonnet 5 $0.00013 $0.00361
Haiku 4.5 $0.00007 $0.00181

Measured 5d ago against content hash 46f70637dd64, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, 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 5d 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 · 182 lines

How it starts

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

Git Worktree

为一个逻辑改动准备独立、可复用的 Git worktree,使它与主工作目录和其它并行改动彼此隔离。

原则

  • 一个逻辑改动使用一个分支和一个 worktree。
  • 创建前先查找并复用已有 worktree 或分支。
  • 仓库自己的开发说明、分支规则和目录约定始终优先。
  • 需要先落地主线的版本、ADR 等治理文档时,先提交文档,再建立编码基线。
  • 不自动 stash、移动未提交改动或执行破坏性清理。
  • 不覆盖已有目录,不强制删除分支或 worktree。
  • 后续命令和文件修改都在选定的 worktree 中执行。

1. 检查现状

确认当前目录属于 Git 仓库,并查看现有工作区:

git rev-parse --show-toplevel
git status --short --branch
git worktree list --porcelain
git branch --list

读取实际存在的仓库说明,例如 AGENTS.mdCONTRIBUTING.mdCLAUDE.mdREADME.md 或相关 docs/

先判断:

  • 当前目录是否已经是这项改动的正确 worktree;
  • 目标分支是否已在其它 worktree 中;
  • 是否存在可复用的分支或目录;
  • 当前工作是否依赖未提交改动;
  • 本次改动是否要求先新增或更新 version、ADR、implementation plan、contract、changelog 等治理文档。

若需要携带未提交改动,不要静默 stash、复制或移动;先让用户选择提交、生成 patch,或留在当前工作区。

2. 先处理主线治理文档

如果仓库规则或用户要求本次改动先新增或更新版本、ADR 等治理文档,并要求这些文档先进入主线,则在开始编码前完成:

  1. 确认仓库的主线分支;在以 main 为主线的仓库中使用 main
  2. 使用当前已经检出该主线分支的干净工作目录,按仓库规则同步它,不覆盖其它未提交工作。
  3. 只创建或更新本次改动所需的治理文档。
  4. 运行仓库规定的文档检查。
  5. 把治理文档作为独立提交提交到主线。
  6. 记录该提交的不可变 SHA,并将它作为编码 worktree 的基线。
git rev-parse HEAD

完成主线文档提交后,才创建新的编码 worktree。这样编码分支从一开始就包含已经落地的版本范围和架构决定,不需要在编码开始后再补合并。

如果编码 worktree 已经创建但尚未产生代码改动,先把其分支快进或按仓库规则更新到治理文档提交,再开始编码。

如果编码 worktree 已经存在代码提交或未提交改动,不要自动重写历史或强制移动分支。先按仓库规则把主线治理文档提交合入该分支,确认工作区和基线正确后再继续。

如果当前没有权限提交主线,或主线工作目录不干净且不能安全处理,停止编码并明确报告阻塞,不要把要求主线先行的治理文档只留在功能分支中。

3. 确定分支、基线和目录

名称优先使用用户指定值、Issue/PR/任务编号,或由改动目标生成的简短 slug。

分支名遵循仓库约定。没有约定时使用合适的:

feat/<slug>
fix/<slug>
docs/<slug>
chore/<slug>
work/<slug>

基线优先级:

  1. 已提交的主线治理文档提交;
  2. 用户明确指定的 commit、tag 或分支;
  3. 仓库说明指定的基线;
  4. 与当前工作直接相关的当前分支或提交;
  5. 当前 HEAD

不要默认假设 mainmaster 或远端默认分支就是正确基线。不同选择会改变结果时,先向用户确认。

记录不可变基线:

git rev-parse <base-ref>

目录优先使用仓库或用户指定位置;否则优先放在主工作目录旁边,例如:

<repository-name>-<slug>

只有仓库已经约定并忽略内部目录时,才使用 .worktrees/<slug>。不要擅自修改项目 .gitignore

4. 复用或创建

按以下顺序处理:

  • 当前目录就是目标 worktree:直接使用;
  • 目标分支已在某个 worktree 中:使用该路径;
  • 目标分支存在但未被其它 worktree 使用:为它添加 worktree;
  • 没有对应分支和 worktree:创建新分支和 worktree。

复用已有分支:

git worktree add "$WORKTREE_PATH" "$BRANCH"

Read the full file on GitHub · 182 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. 5d ago First seen · 182 lines · 66 tokens per session scan A 46f70637dd64

Subscribe to this mod's changes

worktree is a skill published in the GitHub repository murray17/rovai-ai (46 stars, last pushed today), licensed MIT. It adds 66 tokens to every session and 1,806 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.