ce-worktree
Set up isolated git worktrees. Use when starting isolated work, or when ce-work/ce-code-review offers a worktree option; detect existing isolation first.
Security Assessment
About ce-worktree
Worktree Isolation handles the setup of isolated git worktrees so that work can proceed without disturbing the user's main checkout. Because most coding harnesses already create a worktree at session start, the skill's primary job is to detect existing isolation before creating anything redundant. It follows a strict order of operations: detect existing isolation, prefer a native worktree tool, then fall back to plain git only when neither applies.
Detection works by comparing the resolved absolute git directory against the resolved absolute common git directory. Because git mixes absolute and relative path forms depending on the current directory, the skill resolves each to an absolute path first rather than doing a raw string compare, which would otherwise yield a false "already isolated" result. When the two paths differ, it distinguishes a linked worktree from a submodule using the superproject working tree check, and works in place when it is already inside an isolated worktree. When a native worktree primitive exists (such as an EnterWorktree tool, a /worktree command, or a --worktree flag), it uses that and stops, because a behind-the-back git worktree add creates phantom state the harness cannot see or clean up.
The git fallback runs from the repo root, chooses a meaningful branch name derived from the work description, ensures .worktrees/ is gitignored (checking with a trailing slash so directory-only rules are honored), does a best-effort non-fatal fetch of the base branch, creates the worktree under .worktrees/<branch-name>, and switches into it. If creation fails with a sandbox or permission error, the skill treats it as a blocking decision and asks the user via the platform's question tool rather than silently working in the main checkout. It also documents other worktree operations (list, remove, switch) and integrates with the ce-work and ce-code-review flows, which offer it as a worktree option.
FAQ
Why does the skill check for existing isolation before creating a worktree?
Most coding harnesses already create a worktree by default at session start, so the common case is that isolation already exists. Creating another worktree from inside one lands in the wrong tree and is invisible to the harness that made the current one.
How does it avoid a false "already isolated" result during detection?
It resolves both the git dir and the common git dir to absolute paths first and compares those, rather than doing a raw string compare. Git returns mixed absolute and relative forms depending on the current directory, which would otherwise produce a false positive.
When should the native worktree tool be used instead of plain git?
Whenever the harness provides a native primitive such as an EnterWorktree/WorktreeCreate tool, a /worktree command, or a --worktree flag, the skill uses it and stops. 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.
What happens if git worktree add fails with a permission or sandbox error?
The failure requires a blocking user decision before touching the current checkout. The skill reports it and asks via the platform's question tool (for example AskUserQuestion in Claude Code), offering options such as working in the current checkout or stopping to resolve the issue, and only continues in the main checkout on explicit confirmation.
How does the skill keep worktree contents from being committed?
Before creating anything it verifies .worktrees/ is gitignored by running git check-ignore with a trailing slash, so an existing directory-only rule is honored even before the directory exists, and adds a .worktrees/ line to .gitignore if needed.
Install ce-worktree
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
everyinc/compound-engineering-plugin