worktree-isolation

worktree-isolation is a skill for Claude Code, Codex from ccoalm/ccl-skills. It costs 315 tokens per session (11,445 once invoked), scanned C, original, Apache-2.0.

A Git workflow that gives each coding task its own worktree, which is a separate working directory connected to the same repository.

In plain words
What is it for?
Use it before making code changes, especially when multiple tasks run at once; it also covers separating shared databases, ports, build files, and configuration where needed.
Why use it?
It keeps parallel changes and unfinished work from interfering with the main branch or with one another.

Skill for Claude CodeCodex

Written for Claude Code and Codex: PreToolUse hook event, but also agents/openai.yaml present. Also seen: reads .claude/ paths; mentions Claude Code; mentions Codex.

Part of the ccl-skills plugin — 33 skills, 4 commands, 7 hooks shipped together

Good fit Use it before making code changes, especially when multiple tasks run at once; it also covers separating shared databases, ports, build files, and configuration where needed.

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

Made for: Claude Code, Codex.

Or install ccl-skills, the plugin that ships this one along with the rest of its 33 skills, 4 commands, 7 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-isolation

README.md
[![agentmods](https://agentmods.dev/badge/skills/ccoalm/ccl-skills/worktree-isolation.svg)](https://agentmods.dev/skills/ccoalm/ccl-skills/worktree-isolation)
Your own site
<a href="https://agentmods.dev/skills/ccoalm/ccl-skills/worktree-isolation"><img src="https://agentmods.dev/badge/skills/ccoalm/ccl-skills/worktree-isolation.svg" alt="Measured on agentmods" height="20"></a>
Per session 315 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 11,445 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.00315 $0.11445
Opus 5 $0.00158 $0.05722
Sonnet 5 $0.00063 $0.02289
Haiku 4.5 $0.00032 $0.01145

Measured 7d ago against content hash 37fcf770f9ee, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade C, and why

worktree-isolation 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 7d ago.

The scan reads SKILL.md. This mod also ships 4 executable files (scripts/test_worktree_status.sh, scripts/test_worktree_sweep.sh, scripts/worktree-status.sh, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

**删 worktree 前先救 gitignored 产物**:`git worktree remove`(不带 `--force`)会拒绝脏树/未跟踪文件,但 **gitignored 文件不算"脏"**——worktree 里生成的 gitignored 内容**会随目录一起被删且 git 不会拒绝**,删后不可恢复。绝大多数(依赖目录、构建/测试产物、缓存、日志)本就该删;要救的是其中**重算代价高的数据产物**(data/、o
skills/worktree-isolation/SKILL.md · 180 lines

How it starts

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

Worktree Isolation(编辑隔离)

核心心法

主检出(main 那个工作树)是干净的基线/集成点,不是开发现场。每个迭代/任务在自己的 worktree 里做。并行的两个迭代 = 两个 worktree,互不碰主检出 → 天生不会 clobber。

「天生不会 clobber」只覆盖 git 工作树 / 索引 / 分支——不覆盖仓外的共享运行时状态。 独立 worktree 让并行 lane 互不碰彼此的 tracked 文件和 index,但不隔离仓外共享面,大致三类:①共享服务/端口——同一本机的测试库 / 消息队列 / 缓存服务、监听端口(如 :3000)、docker compose 工程名与卷;②共享文件状态——共享的 .env、跨 worktree 共享的可变 node_modules / .venv / build 输出 / 生成物目录、固定 /tmp 路径;③主机全局配置与凭据——$HOME 下的工具配置与 auth profile、KUBECONFIG / gcloud·kubectl 当前 context / cloud·registry 凭据、~/.npmrc、浏览器/设备 profile(切错 context 会让另一条 lane 的 migration/deploy/install 打到错误目标——是权限/目标级 clobber,不止数据)。两个 worktree 同时跑 pytest / migration / dev server / deploy 会在这些面互踩——一方的 migration 或 fixture 清库毁掉另一方、端口占用失败、缓存串写、或打到错误集群。所以并行前先隔离:每条 lane 独立的 DB/schema/namespace、不同端口、独立 compose project 与卷、每 worktree 自己的可变依赖安装/构建/输出目录、独立的 KUBECONFIG/配置 profile 并显式传 context 而非依赖全局当前值(并发安全的内容寻址/只读缓存可共享,不必强拆——如 pnpm store、Go module cache;cargo 仅指依赖下载缓存,不含 $CARGO_HOME 的 config/凭据/bin/registry index/target;只拆会被并发写坏的可变面);隔离不了的共享面就把那部分工作串行(呼应 multi-agent-delegation 的「共享 state / migration / 生成物就串行或留本地」)。单人单线顺序跑通常不触发,但共享库残留脏数据或残留的全局 context 仍可能跨 lane 串——按需重置。

绝不在 main 上开发:main(主检出 / main 分支)永远是干净基线/集成点,不是开发现场——任何迭代/功能、哪怕一行修改,都先建分支 + worktree 再改,不论单人单线还是并发、不论是不是技能仓库(worktree 很便宜,没有例外)。并发只是让这条更刚性,不是它的前提。

绝不依赖 ambient cwd(机械纪律,与上条并列):多 worktree 下 shell 的 cwd 可能在两次工具调用之间被 harness 静默重置(常见回显 Shell cwd was reset to <某路径>;被重置的是 cd 出来的 shell cwd——宿主原生 EnterWorktree/--worktree 设的持久工作上下文不受此影响,对它 git -C 是双保险)。所以凡必须落到某个特定检出的操作都不靠"当前恰好 cd 在哪":git 变更add/commit/merge/branch 等)一律显式 git -C "<abs-worktree-path>" …-C 等价于在该目录里起 git,pathspec 也按 -C 目录解析,故配绝对文件路径);文件写入用绝对路径(宿主原生 Write/Edit 本就要求绝对路径,自动满足);确实需要工作目录的命令(在 worktree 内跑 pytest/build/dev server,或本技能自己的 cwd 相关操作——Step 0 的 worktree-status.sh、收尾「在主检出里跑」的 git worktree remove/pruneworktree-sweep.sh)用单条 cd <abs> && <cmd>调用当刻设好工作目录,绝不假设它存活到下一次工具调用。为什么"cd 前先确认 cwd"不够:确认之后、下次调用之前 cwd 仍可能被重置,裸 git commit/相对路径就落到 cwd 当时指向的检出——多 worktree 下常是主检出,把提交落到错的分支,到 ff-only 合并才暴露(即收尾节「合并方向」条的"站错分支就会合进 B、信息却写着 C")。命令若落到非 git 目录或空索引会显式报错,真正危险的是 add+commit 都静默落进主检出那种。诱因不止重置——删除已用 worktree 后路径复用同样让 cwd 失效(见收尾节「已删 worktree 的路径从此作废」),两者都是本条实例。

Read the full file on GitHub · 180 lines

Files

What ships with it

7 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. 7d ago First seen · 180 lines · 315 tokens per session scan C 37fcf770f9ee

Subscribe to this mod's changes

worktree-isolation is a skill published in the GitHub repository ccoalm/ccl-skills (6 stars, last pushed today), licensed Apache-2.0. It adds 315 tokens to every session and 11,445 once invoked, about $0.0016 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-31.

Related

Other skills, from other repositories

security-pipeline

Use when security verification is needed - pre-commit security checks, vulnerability scanning, STRIDE threat analysis. Integrates with /handoff-verify --security and /commit-push-pr. CWE Top 25 based.

sangrokjung/claude-forge · 48 tokens

memstack-security-git-guard

Use when the user says 'git-guard', 'check git protection', 'is this repo protected', 'verify gitleaks', 'set up git hooks', 'install git-guard', or wants to confirm a repo blocks secrets and internal files before commit. This is an installer and verifier, NOT a scanner (gitleaks does the actual scanning). Do NOT use…

cwinvestments/memstack · 92 tokens

memstack-development-changelog-generator

Use when the user says 'generate changelog', 'update changelog', 'what changed', 'release notes', 'write changelog', or needs a formatted CHANGELOG.md from git commit history. Do NOT use for diary entries, git log viewing, or commit message writing.

cwinvestments/memstack · 63 tokens

ln-63-release-publisher

Prepares and publishes an explicitly requested tagged GitHub release. Not for ordinary commits, package publication, or announcements.

levnikolaevich/claude-code-skills · 30 tokens

ln-64-community-announcer

Drafts or publishes fact-checked GitHub Discussions announcements for project updates. Not for release creation or issue responses.

levnikolaevich/claude-code-skills · 30 tokens

aiwg-pr

AIWG-specific pull request delivery workflow for AIWG product/workspace changes; not the generic repository PR process.

jmagly/aiwg · 25 tokens