worktree
Installation
SKILL.md
Worktree Isolation
Put the work in an isolated workspace without disturbing the user's checkout. Reuse existing isolation first, then the harness's native worktree tool, then plain git, so every worktree you create is one the harness can see.
Two modes:
- New work (default): a fresh branch from the base branch.
- Existing ref: the caller names a PR, branch, tag, or commit, and the worktree attaches to it. Git checks a branch out in one worktree at a time. If the ref is already checked out, often in the primary checkout, report where and let the caller choose between working there and a detached worktree at the same commit.
1. Detect existing isolation
git rev-parse --absolute-git-dir
(cd "$(git rev-parse --git-common-dir)" && pwd -P)
Compare these two absolute paths. Raw git rev-parse output mixes relative and absolute forms and can give a false match.