К основному содержанию
скилл CX Codex

ce-worktree — скилл для Claude Code: изолированные git worktree

Скилл заводит отдельное рабочее дерево git, чтобы правки не трогали основной чекаут. Пригодится, когда нужно поработать в стороне от текущей ветки.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add EveryInc/compound-engineering-plugin --skill ce-worktree -a claude-code
Открыть на GitHub

Что делает ce-worktree

Скилл определяет, есть ли уже изоляция, и только потом что-то создаёт. Сначала он сравнивает абсолютные пути git-каталога и общего каталога: если они совпадают, это обычный чекаут, если различаются — связанное дерево или подмодуль. Подмодуль считается обычным чекаутом, а вот в готовом worktree скилл просто работает на месте: дерево из дерева попадёт не туда и останется невидимым для харнесса, который создал текущее.

Дальше порядок такой: сначала родной инструмент харнесса — EnterWorktree, WorktreeCreate, команда /worktree или флаг --worktree. Только если такого нет, в дело идёт обычный git. Фолбэк запускается из корня репозитория, проверяет через git check-ignore -q .worktrees/, что каталог .worktrees/ в .gitignore, и обновляет базу командой git fetch origin <from-branch>. Отсутствие origin или другое имя удалённого репозитория — не повод останавливаться, работа продолжается с локальной ссылкой.

Режимов два. Для новой работы ветка создаётся от базы, для существующей ссылки — PR, ветки или коммита — дерево привязывается к ней. Ветка может быть вычекаучена только в одном дереве: если ссылка уже занята, скилл сообщает путь и не делает второе дерево. PR вычекаутивается в локальную ветку, а не в оторванный FETCH_HEAD, иначе коммиты цикла правок осиротеют. Если git worktree add падает из-за песочницы или прав, скилл не продолжает в текущем чекауте, а спрашивает, что делать.

Какие задачи решает

  • завести отдельное дерево под новую задачу, не трогая текущую ветку
  • привязать worktree к существующей ветке, PR или коммиту
  • не создать второе дерево для ветки, которая уже вычекаучена
  • вычекаутить PR в локальную ветку, чтобы коммиты не осиротели
  • проверить, не работаешь ли ты уже внутри изолированного дерева

Примеры запросов агенту

  • Заведи worktree под новую задачу и скажи путь с веткой
  • Привяжи worktree к ветке fix/email-validation
  • Вычекауть PR в отдельное дерево

Как установить ce-worktree

1Через Skills CLI (Vercel)

npx skills add EveryInc/compound-engineering-plugin --skill ce-worktree -a claude-code

2Вручную: положить файлы

~/.claude/skills/ce-worktree/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/ce-worktree/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о ce-worktree

Как установить ce-worktree в Claude Code?

Выполните npx skills add EveryInc/compound-engineering-plugin --skill ce-worktree -a claude-code. Файл скилла появится по пути ~/.claude/skills/ce-worktree/SKILL.md.

Что делает ce-worktree?

Настраивает изолированное дерево git: создаёт новую ветку от базы или привязывает дерево к существующей ветке, PR либо коммиту. Сначала проверяет, нет ли уже готовой изоляции.

Почему скилл не создаёт второе дерево для той же ветки?

Ветку можно вычекаутить только в одном дереве за раз. Если ссылка уже занята, скилл сообщает путь, где она вычекаучена, и оставляет решение за вами.

Исходный текст

SKILL.md · MIT
---
name: ce-worktree
description: Set up isolated git worktrees — create a new branch for fresh work, or attach a worktree to an existing branch, PR, or commit. Use when starting isolated work or isolating an existing ref.
---

# Worktree Isolation

Ensure the current work happens in an isolated workspace, without disturbing the user's main checkout. Most coding harnesses now create a worktree by default at session start, so the common case is that **isolation already exists**.

**Done when:** the caller is working in an isolated tree — existing or newly created — and its path and branch have been reported, or a blocker has been reported instead.

**Order of operations: detect existing isolation -> prefer a native worktree tool -> fall back to plain git.** Never create a worktree the harness cannot see.

**Two modes, set by the caller's need:**

- **New work (default).** No ref named — create a fresh branch from a base (trunk). This is what `ce-work` and `ce-code-review` use when the user picks the worktree option.
- **Isolate an existing ref.** The caller names a PR head, branch, or commit — attach the worktree to that ref instead of creating a new branch. **A branch can be checked out in only one worktree at a time.** If the named ref is already checked out anywhere (most commonly as the primary checkout's current branch), do **not** create a second worktree — report that it is already checked out at `<path>` and let the caller act (work there in place; or, only if a clean separate tree is essential, create a *detached* worktree at the same commit).

## Step 0: Detect existing isolation

Compare the **resolved absolute** git dir against the **resolved absolute** common git dir. Git mixes absolute and relative forms depending on the current directory (from a subdirectory of a normal checkout, `--git-dir` comes back absolute while `--git-common-dir` may be relative), so a raw string compare yields a false "already isolated":

```bash
git rev-parse --absolute-git-dir                     # absolute git dir for this worktree
(cd "$(git rev-parse --git-common-dir)" && pwd -P)   # absolute shared (common) git dir
```

**Equal** -> normal checkout; continue to Step 1.

**Different** -> a linked worktree *or* a submodule. Distinguish with `git rev-parse --show-superproject-working-tree`:

- **Non-empty** -> submodule; treat it as a normal checkout and continue to Step 1.
- **Empty** -> **already isolated**. Report the worktree path (`git rev-parse --show-toplevel`) and current branch, then **work in place** — a worktree-from-worktree lands in the wrong tree and is invisible to the harness that made the current one. In isolate-an-existing-ref mode, check that ref out here (unless it is already current) rather than nesting a worktree.

## Step 1: Prefer the harness's native worktree tool

If the harness provides a native worktree primitive — for example an `EnterWorktree` / `WorktreeCreate` tool, a `/worktree` command, or a `--worktree` flag — use it and stop. Native tools place, track, and clean up the worktree so the harness can manage it. A behind-the-back `git worktree add` creates phantom state the harness cannot see, navigate to, or clean up.

## Step 2: Git fallback

Only when there is no native tool **and** Step 0 found no existing isolation.

1. **Run from the repo root:** `cd "$(git rev-parse --show-toplevel)"`. The paths below are repo-root-relative, but the skill runs from the user's current directory — without this, `.worktrees/<branch>` and the `.gitignore` edit land in a subdirectory (e.g. `src/.worktrees/...`).
2. Choose a meaningful branch name from the work description (e.g. `feat/login`, `fix/email-validation`) — never an opaque auto-generated one. Base: origin's default branch, else `main`.
3. **Ensure `.worktrees/` is gitignored before creating anything:** `git check-ignore -q .worktrees/` — **with the trailing slash**, so an existing directory-only `.worktrees/` rule is honored even before the directory exists (without the slash the probe misses it and dirties a correctly-configured repo). Not ignored -> add a `.worktrees/` line to `.gitignore`.
4. Refresh the base with `git fetch origin <from-branch>`. This is **non-fatal** — no `origin` remote, a differently-named remote, or a local-only branch is not an abort; continue with the local ref.
5. Create the worktree, per mode:
   - **New work:** `git worktree add -b <branch-name> .worktrees/<branch-name> origin/<from-branch>` (use the local `<from-branch>` ref if `origin/<from-branch>` does not exist).
   - **Existing branch or tag:** `git worktree add .worktrees/<slug> <target-ref>`.
   - **PR:** check it out on a **local branch** — `git fetch origin pull/<n>/head:pr-<n>` then `git worktree add .worktrees/pr-<n> pr-<n>`. Never a detached `FETCH_HEAD`: that orphans the fix loop's commits instead of updating the PR. (For push-tracking back to the PR, create it detached — `git worktree add --detach .worktrees/pr-<n>` — then `cd` in and run `gh pr checkout <n>`, which is fork-safe.)
   - If git reports the ref is already checked out elsewhere, apply the one-branch-one-worktree rule above — do not force a second worktree.
6. `cd` into it, then report the path and branch.

If `git worktree add` fails with a sandbox or permission error, the requested isolation does not exist. Do **not** proceed in the current checkout — the user chose isolation specifically to avoid it. Report the failure and ask, offering options such as "work in the current checkout" vs "stop and resolve the permission issue", using the host's blocking question tool already in the current tool list (match by capability, not by a host-specific name). Presence in the current tool list is proof the tool exists; never call a user-facing question tool to discover whether it exists. If a matching tool is listed but unloaded, use the host's tool-discovery primitive to load that capability — do not search for another host's tool name. Only when no such tool is in the list or a real question call errors, present the numbered options in chat and wait for the reply. Never skip the confirmation, and do not retry alternative paths automatically.

© EveryInc · MIT · EveryInc/compound-engineering-plugin

Похожие скиллы

Все скиллы по теме «Git и GitHub» →
triage Matt Pocock Скилл проводит issue и внешние PR через роли триажа, проверку и подготовку брифа для агента. Подойдёт мейнтейнеру, который разбирает очередь задач. 990 453установок code-review Matt Pocock Проверяет изменения от выбранной точки по стандартам репозитория и требованиям задачи. Нужен для ревью ветки, PR или незавершённой работы. 789 521установок implement Matt Pocock Выполняет задачу по спецификации или тикетам, ведёт работу через тесты и завершает её ревью с коммитом. Подходит для задач, где нужен дисциплинированный цикл разработки. 774 700установок git-guardrails-claude-code Matt Pocock Скилл ставит хук Claude Code, который останавливает опасные Git-команды до их запуска. Нужен, если агент не должен делать push или удалять изменения. 499 069установок setup-pre-commit Matt Pocock Скилл настраивает pre-commit для JavaScript-репозитория: Husky запускает форматирование, проверку типов и тесты перед коммитом. 489 289установок scaffold-exercises Matt Pocock Скилл создаёт структуру учебных упражнений с секциями, задачами, решениями и пояснениями. Пригодится при запуске нового раздела курса. 480 196установок

Из того же набора34

ce-compound-refresh Сверяет накопленную базу знаний в solutions/ с реальным кодом репозитория. Помогает вовремя убрать устаревшие и противоречивые заметки. CX Codex +1 3 300установок ce-commit-push-pr Скилл ведёт изменения от коммита до pull request: проверяет состояние ветки, отправляет изменения и собирает описание PR. Нужен для публикации готовой работы. CX Codex +1 3 300установок ce-setup Проверяет окружение Compound Engineering, валидирует конфиг репозитория и создаёт новые Pack'и. Нужен, если вы уже используете Compound Engineering или хотите начать. CX Codex +1 3 400установок ce-resolve-pr-feedback Скилл разбирает комментарии ревьюеров в пул-реквесте, вносит правки и закрывает обсуждения. Пригодится, когда на PR уже накопились замечания. CX Codex +1 3 200установок ce-strategy Скилл создаёт или обновляет STRATEGY.md с описанием продукта, его пользователей, метрик и направлений работы. Пригодится при запуске продукта или смене курса. CX Codex +1 3 000установок ce-proof Публикует локальные markdown-файлы в Proof — редактор для совместной работы над спеками, планами и черновиками. CX Codex +1 3 000установок ce-test-browser Запускает браузерные тесты для страниц, затронутых текущей веткой или pull request. Определяет порт dev-сервера и проверяет интерактивность интерфейса. CX Codex +1 3 000установок ce-product-pulse Собирает одностраничный отчёт о продукте за заданный интервал: использование, производительность, ошибки. Полезен, когда нужно быстро понять, что происходит в проекте. CX Codex +1 2 900установок

Спонсоры проекта

Компании, которые помогают держать аналитику открытой