worktree-isolation
БесплатноБез исполняемых скриптовНе проверенUse when about to make code changes while other work is in flight, when working in a repo's primary clone with live git worktrees, when starting a parallel…
от schuettc★ 15 звёзд на GitHubОб этом скилле
Worktree isolation
The rule
The primary clone is a coordination point, not a workspace. Every distinct line of work — a feature, a fix, a "quick change," an agent's task — runs in its own git worktree on its own branch. Two lines of work never share one checked-out tree.
This is non-negotiable when any parallel work is live: an autopilot running, another Claude session open, a long task mid-flight. The moment two actors touch one tree on different branches, you get clobbered uncommitted changes, "branch already checked out" errors, and "wait, what branch am I even on" — the classic shared-tree collision.
Why
The failure mode: Feature B has an uncommitted implementation in the working tree, and then Feature C's branch gets checked out in the same tree on top of it. You get overlaid changes, "branch already checked out" errors when something else tries to use B's branch, and confusion about which branch is even live. The autopilot already isolates its own subagents (see feature-workflow), so the exposure is everything else that can reach the same checkout — a change made directly in the primary clone, or a second Claude session opened against the repo, while parallel work is live. Nothing structural stops any of those from landing on top of in-flight work.
The fix is structural, not willpower: make isolation the easy path, so "just make the change" lands in a worktree instead of the shared tree.
How to apply (this is guidance for you, the agent)
When the user asks for a change and there is — or might be — parallel work live, don't edit the primary clone. Isolate first:
- Check where you are. If the repo has linked worktrees (
git worktree listshows more than one) and you're in the primary clone, you're on the shared tree. (In a tmux setup the status bar flags this as⚠ primary.) - Isolate the work by the cheapest sufficient means:
- Dispatch an
isolation: "worktree"subagent (the Agent tool) to do the change — the harness gives it a clean worktree. Best for a self-contained task. - Or create a worktree and work there at the target repo's
.worktrees/<branch>, resolved from that repo's root (not your cwd) and as a real path (pwd -P):ROOT="$(cd "$TARGET" && git rev-parse --show-toplevel)"; ROOT="$(cd "$ROOT" && pwd -P)" git -C "$ROOT" worktree add "$ROOT/.worktrees/<branch>" -b <branch> origin/dev$TARGETis the repo this line of work targets (base offdevif it exists). Then operate inside it. Best when you'll iterate interactively. - Use worktree-relative paths; never reconstruct primary-clone absolute paths inside a worktree (that's how agents drift back out and re-collide).
- Dispatch an
- Only edit the primary clone directly when nothing else is live and the change is on the clone's own checked-out branch (e.g. a
devdoc tweak you're about to commit immediately).
Where worktrees go (the location rule)
Always <target-repo-root>/.worktrees/<branch> — resolved from the repo the work targets, not your current directory, and as a real path (pwd -P). Two reasons this exact form matters:
- Multi-repo workspaces. When several repos sit under one coordination root and you may be launched from the root or from a member, deriving the path from the target repo's root (
git -C "$TARGET" rev-parse --show-toplevel) makes it identical either way. Don't build cwd-relative or primary-clone-absolute paths. - Never
/tmp. On macOS/tmpis a symlink to/private/tmp; worktrees under it break tooling that resolves modules in worker threads — vite-node/vitest dies withCannot find package …before a single test runs, so suites silently never run and regressions only surface in CI. A worktree under the repo root is already a real path;pwd -Pis the backstop.
The exception: a bare primary clone
When the primary clone is bare, <repo-root>/.worktrees/ is inside the git
directory itself — and that breaks build tooling. Use a sibling instead:
git -C "$BARE" worktree add "${BARE}-wt/<branch>" -b <branch> origin/dev
A bare repo has no working tree, so git status there is fatal (exit 128). Any
tool that walks up from your package directory to find the repository root can
land on the bare repo rather than on your worktree, run git there, and fail —
reporting something that names neither worktrees nor bareness:
error obtaining VCS status: exit status 128
Use -buildvcs=false to disable VCS stamping.
That is Go's -buildvcs stamping, and it fails every go build in every
worktree nested under a bare primary. It cost an hour to trace, because the error
points at VCS stamping and the actual cause is a directory layout chosen weeks
earlier. Anything else that resolves a repo root by walking upward — coverage
tools, release stampers, monorepo task runners — can hit the same wall.
-buildvcs=false silences it, at the cost
Установить worktree-isolation в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл worktree-isolation?
Use when about to make code changes while other work is in flight, when working in a repo's primary clone with live git worktrees, when starting a parallel line of work, or when dispatching agents that write to the tree. The rule — the primary clone is a coordination point, not a workspace; isolate every line of work (yours and agents') in its own git worktree so parallel lines never collide in one tree.
Как установить скилл worktree-isolation?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл worktree-isolation запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic