Agent skill

Git Worktree Isolation

by EveryInc in EveryInc/compound-engineering-plugin

Puts the current task in an isolated git worktree, either a fresh branch from trunk or an existing branch, PR head or commit, without disturbing your main checkout.

MITAuto-check passedDevelopment

Install Git Worktree Isolation

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

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install EveryInc/compound-engineering-plugin ce-worktree --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/EveryInc/compound-engineering-plugin.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/ce-worktree .claude/skills/ce-worktree && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
ce-worktree
GitHub stars
25k
Token cost
~1.5k tokens
SKILL.md length
867 words
Files
1
Skills in repo
37
Repo updated
First seen
Licence
MIT

At a glance

Puts the current task in an isolated git worktree, either a fresh branch from trunk or an existing branch, PR head or commit, without disturbing your main checkout.

  • Works in 3 steps: Detect existing isolation → Prefer the harness's native worktree tool → Git fallback
  • Starting a feature that should not touch the main checkout
  • SKILL.md covers Step 0: Detect existing…, Step 1: Prefer the harness's… and Step 2: Git fallback
  • Calls git and gh

What it does

This skill makes sure work happens in an isolated tree before the agent edits anything. Its first step checks whether isolation already exists by comparing the resolved absolute git directory with the resolved absolute common git directory, then telling a linked worktree from a submodule with a superproject check. Many coding harnesses create a worktree at session start, so existing isolation is the common case.

When a new tree is needed, the order is a native worktree tool from the harness first and plain git as the fallback, and it never creates a worktree the harness cannot see. New-work mode branches fresh from trunk. Existing-ref mode attaches to a named PR head, branch or commit. Git allows a branch in only one worktree at a time, so a ref that is already checked out is reported with its path and the caller decides what to do. The skill ends by reporting the tree's path and branch, or the blocker.

When your agent uses it

  • Starting a feature that should not touch the main checkout
  • Reviewing a pull request in its own working tree
  • Checking whether the session already runs inside a linked worktree

Example prompts

  • “Set up an isolated worktree for the billing refactor, branching from main.”
  • “Create a worktree for the open pull request on the search-filters branch so I can review it.”
  • “Check whether this session is already in a worktree and tell me the path and branch.”

Requirements

  • A git repository

Workflow steps

3 steps, taken from the step headings in SKILL.md.

  1. Detect existing isolation
  2. Prefer the harness's native worktree tool
  3. Git fallback

What it can do on your machine

Read from SKILL.md and the folder at commit cef001f. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • git
    • gh

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git and gh, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Git Worktree Isolation loads about 1.5k tokens when it runs. Until then it costs about 50 tokens; SKILL.md has 867 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~50
When it runs · the whole SKILL.md, loaded when a task matches
~1.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from EveryInc/compound-engineering-plugin at commit cef001f, republished under its MIT licence (© EveryInc). 867 words, ~1,544 tokens.

Download SKILL.mdSave it as .claude/skills/ce-worktree/SKILL.md (or your agent's skills folder).
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.

Show full SKILL.md (440 more words)Show less

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. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/ce-worktree of EveryInc/compound-engineering-plugin.

Open the folder on GitHubat commit cef001f

Compare with similar skills

Git Worktree Isolation next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Git Worktree Isolation compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Git Worktree Isolation this skillEveryInc/compound-engineering-plugin25k—~1.5kAutomated safety check: PassMIT
Finishing a Development Branchobra/superpowers296k5 repos~1.9kAutomated safety check: PassMIT
Git Worktree Cleanuplobehub/lobehub83k—~2.8kAutomated safety check: PassCustom licence
Ccmanager Configkbwo/ccmanager1.3k—~1.5kAutomated safety check: PassMIT
Git Worktree Managermicrosoft/WindowsAppSDK4.7k—~2kAutomated safety check: PassMIT
Git Worktree IsolationjnMetaCode/superpowers-zh8.3k1 repos~982Automated safety check: PassMIT

Similar skills

  • Walks the last step of a branch: confirm tests pass, detect the git environment, ask how to integrate, carry out your choice and clean up the worktree.

    296k GitHub starsUsed in 5 repos~1.9k tokens
    DevelopmentAuto-check passed
  • Git Worktree Cleanup

    lobehub/lobehub

    Audits stale Git worktrees and branches with a bundled script, classifies each one, and deletes only after you approve the exact candidates.

    83k GitHub stars~2.8k tokensUpdated today
    DevelopmentAuto-check passed
  • Ccmanager Config

    kbwo/ccmanager

    Set up, review, or repair a CCManager config — .ccmanager.json at a git repository root, or the global ~/.config/ccmanager/config.json.

    1.3k GitHub stars~1.5k tokensUpdated 10 days ago
    DevelopmentAuto-check passed
  • Git Worktree Manager

    microsoft/WindowsAppSDK

    Official

    Creates and manages Git worktrees with PowerShell scripts so separate issues and Copilot sessions each get an isolated branch, build and test environment.

    4.7k GitHub stars~2k tokensUpdated today
    DevelopmentAuto-check passed
  • Git Worktree Isolation

    jnMetaCode/superpowers-zh

    Sets up an isolated workspace before feature work or plan execution, preferring native worktree tools and falling back to git worktree, with instructions in Chinese.

    8.3k GitHub starsUsed in 1 repo~982 tokens
    DevelopmentAuto-check passed
  • Git Commit

    tisfeng/Easydict

    起草、创建或汇报 Angular-style 本地 Git 提交。用于明确的提交交付;分支集成使用 worktree-rebase-merge,不 push。

    15k GitHub stars~535 tokensUpdated yesterday
    DevelopmentAuto-check passed

More from EveryInc/compound-engineering-plugin

All 37 skills in this repo
  • Compound Learning Writer

    EveryInc/compound-engineering-plugin

    Records one solved and verified problem as a durable learning in the repository, but only when the reasoning is not already clear from the final code, tests or docs.

    25k GitHub stars~2k tokensUpdated today
    Auto-check passed
  • Compound Learnings Refresh

    EveryInc/compound-engineering-plugin

    Audits a repo's stored learnings against the current codebase, fixes stale, overlapping or superseded docs and reports on every document.

    25k GitHub stars~2k tokensUpdated today
    Auto-check passed
  • Compound Engineering Prototype

    EveryInc/compound-engineering-plugin

    Builds a throwaway prototype at just the fidelity needed to settle a specific how-it-should-work-or-feel question, before committing to an approach other work will treat as fixed.

    25k GitHub stars~1.9k tokensUpdated today
    Auto-check passed
  • Compound Engineering Setup

    EveryInc/compound-engineering-plugin

    Checks Compound Engineering plugin health and repo-local config, or scaffolds a Compound Pack when you ask for one by id.

    25k GitHub stars~1.9k tokensUpdated today
    Auto-check passed
  • PR Babysitter

    EveryInc/compound-engineering-plugin

    Watches an open GitHub pull request over time, routing review comments and CI failures to other skills until the PR is ready to merge.

    25k GitHub stars~2k tokensUpdated today
    Auto-check passed
  • CE Brainstorm

    EveryInc/compound-engineering-plugin

    Turns a vague or ambitious feature idea into a requirements-only plan through dialogue with you, sized to the work, before any code is written.

    25k GitHub stars~1.9k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about Git Worktree Isolation

What does Git Worktree Isolation do?

Puts the current task in an isolated git worktree, either a fresh branch from trunk or an existing branch, PR head or commit, without disturbing your main checkout. This skill makes sure work happens in an isolated tree before the agent edits anything. Its first step checks whether isolation already exists by comparing the resolved absolute git directory with the resolved absolute common git directory, then telling a linked worktree from a submodule with a superproject check.

When should I use Git Worktree Isolation?

Git Worktree Isolation fits situations like: starting a feature that should not touch the main checkout; reviewing a pull request in its own working tree; checking whether the session already runs inside a linked worktree.

How do I install Git Worktree Isolation in Claude Code?

Run `npx skills add EveryInc/compound-engineering-plugin --skill ce-worktree -a claude-code`. Or copy the skill folder (skills/ce-worktree in EveryInc/compound-engineering-plugin) into .claude/skills/ce-worktree in your project. Claude Code loads it when a task matches its description.

How do I install Git Worktree Isolation in Codex?

Run `npx skills add EveryInc/compound-engineering-plugin --skill ce-worktree -a codex`. Or copy the skill folder (skills/ce-worktree in EveryInc/compound-engineering-plugin) into .agents/skills/ce-worktree in your project. Codex loads it when a task matches its description.

Can I use Git Worktree Isolation in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add EveryInc/compound-engineering-plugin --skill ce-worktree -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/ce-worktree, .gemini/skills/ce-worktree, .github/skills/ce-worktree and .opencode/skills/ce-worktree in your project.

What does Git Worktree Isolation need to run?

Going by SKILL.md and its folder, Git Worktree Isolation needs the command-line tools its instructions call (git and gh). Our summary lists: A git repository.

Does Git Worktree Isolation access the network?

SKILL.md contains no URLs. Its commands use git and gh, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Git Worktree Isolation safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Git Worktree Isolation use?

Git Worktree Isolation is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Git Worktree Isolation use?

About 1.5k tokens (SKILL.md is roughly 6.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Git Worktree Isolation?

Skills that share tags, products or a category with Git Worktree Isolation: Finishing a Development Branch (obra/superpowers, 296k stars), Git Worktree Cleanup (lobehub/lobehub, 83k stars), Ccmanager Config (kbwo/ccmanager, 1.3k stars) and Git Worktree Manager (microsoft/WindowsAppSDK, 4.7k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Git Worktree Isolation?

EveryInc (a GitHub organization) maintains it in EveryInc/compound-engineering-plugin, which has 25,412 GitHub stars. The repository holds 37 skills in this directory. The repository was last updated on October 7, 2026.

Source: EveryInc/compound-engineering-plugin on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.