Install any skill in seconds. Free to start, no credit card required.
Get Started Free →ganyuanran/using-git-worktrees
Use when a coding task needs a concurrent checkout, unrelated dirty state blocks safe branch switching, or the user or repository explicitly requires a worktree.
Passed 11 of 17 test cases with the skill, and 7 of 17 without it.
and 8 more in the full report
6 fixed8 passed either way7 still failing1 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 6 test cases the skill fixed. Same model, same prompt, with and without the skill.
We are done with a secondary worktree at `/tmp/worktree-123`, but it contains untracked diagnostic files created during testing. Should we force delete or `git clean -fd` those files during cleanup?
| Checked | Without skill | With skill |
|---|---|---|
| Prohibits automatic deletion or resetting of untracked files without user authorization. | Missed | Passed |
| Requires preserving user-owned or ownership-unknown state. | Missed | Passed |
The instructions your model reads when the skill loads.
A worktree is an exception for simultaneously checking out another Git history, not a general safety badge. Prefer the current workspace and reuse an existing suitable worktree. A branch decision and a worktree decision are separate.
Core principle: create only with necessity and ownership evidence; pair every created worktree with a cleanup path.
Announce at start: explain which concrete checkout conflict requires a worktree.
Before mutation, record the repository root, HEAD, branch/detached state,
staged/unstaged/untracked paths, active Git operations, and:
git worktree list --porcelain
Classify the current host surface's task/chat-bound managed workspace semantics
as managed, non-managed, or unknown. Use trusted host/session context, an
explicit host contract, or a host-native lifecycle result; do not infer the
classification from a product name, directory prefix, command-level workdir,
missing tool, or absent metadata. non-managed requires positive evidence that
the current surface lacks task-bound managed semantics. When the host exposes
workspace fields, record the task workspace and the command's default cwd
without a per-command directory override.
Stop on unresolved conflicts, an active merge/rebase/cherry-pick/revert/bisect, or an unexplained detached HEAD. A detached HEAD is acceptable only when trusted host binding evidence identifies it as the intended state of the current managed worktree; Codex-managed worktrees, for example, start detached by default. Preserve user state: no automatic stash, reset, clean, broad staging, or commit.
Before deciding necessity or placement, read the smallest relevant project
test cases passed, vs 7 / 17 without
Published skills whose descriptions closely match this one, with their headline benchmark lift.
More skills from the same source and nearby in the registry, with their headline benchmark lift.