Manage Git worktrees: create, list, reuse, repair, or remove linked checkouts; integrate their task branches; prune stale registrations. Use when tasks need separate working directories sharing one repository.
85
91%
Does it follow best practices?
Impact
100%
1.44x2 of 3 eval scenarios. Add 1 more for a full score.
Passed
No findings from the security scan
When a live checkout has moved and its registration is stale, repair it before other Git operations: git -C "<surviving-repo>" worktree repair "<current-absolute-worktree-path>", or its manager's supported repair tool. If the surviving repository or current path is unknown, establish those paths first. A reorganization alone does not prove a checkout moved; an unavailable mount calls for retention, not repair at an invented path.
Follow user instructions and repository conventions; keep ownership and the integration target explicit.
Apply only task-relevant phases and their safety checks; listing or repair alone does not require development, integration, or cleanup.
| Term | Meaning |
|---|---|
| Worktree / checkout | A directory of checked-out files with its own HEAD and index (staging area). Here, the noun checkout means this workspace. |
| Main (primary) / linked worktree | The main worktree is the original checkout; all others are linked. <primary-root> is the main worktree's directory regardless of branch name. A bare repository has no main worktree. |
| Base / integration target | The commit or ref a task starts from, versus the branch intended to receive it; they may differ. |
| Registration | Git's administrative record connecting a linked worktree's path to the repository. Repair reconnects a live checkout; prune removes obsolete registrations. |
Removing a worktree leaves its branch. Name the checkout path and branch/ref separately when communicating about them.
git worktree list --porcelain -z; inspect changes and ongoing Git operations.Worktrees separate working files and indexes, but share objects, most refs, remotes, and much Git configuration. HEAD, refs/bisect/*, refs/worktree/*, and refs/rewritten/* are per-worktree. Coordinate shared mutations. They provide no security boundary; concurrent services may also need distinct ports, databases, and output locations.
<primary-root>/.worktrees/<task>, or a sibling of the repository directory for a bare repository. Do not place a worktree inside another disposable worktree. Use a unique, descriptive task name and an unused path..gitignore or a local exclusion. Locate the exclude file with git rev-parse --path-format=absolute --git-path info/exclude; .git may be a file. Run git check-ignore -q from the enclosing checkout, with a trailing / on the destination's relative path, and require exit 0. Verify again after creation.Keep the checkout path, branch, starting commit, integration target, and manager in the existing task context.
main, master, origin, or the current HEAD is correct.Before creating a worktree with raw Git, read Creation commands. <repo> denotes an existing checkout or bare repository; <worktree> is the task's exact absolute path.
Evaluate checkout removal and branch deletion separately. Routine cleanup of this task's disposable resources is part of finishing; ask only when authority, ownership, or possible data loss is unresolved.
worktree list or the harness inventory. Exclude the primary checkout, the current working directory, the worktree's parent directory, and sibling tasks. Remove only the exact task checkout through its manager or git worktree remove.Before raw Git worktree removal, task-branch deletion, or registration pruning, read Cleanup commands. Apply the decision tree above to each requested operation.
For batch scripts, existence and a directory-name prefix are filters, not removal authorization. Parse complete NUL-delimited records, including lock and detached state; remove only individually reviewed task-owned paths. Default to reporting candidates until preservation and ownership checks pass. Never add --force merely to make the loop finish; stop on refusal. Pruning affects the repository inventory, so review every dry-run entry, including entries outside the script's selected directory.
branch -d may check the branch's upstream rather than the intended integration target; success is not integration evidence.branch -d refuses, retain the branch until its obsolete history is verified safe and authorized to delete; only then consider branch -D.Before reporting a retained task checkout ready, verify its absolute path, branch (or intended detached commit), current registration, and any required ignore coverage.
Report completed work and checks, integration/review status, and removed or retained checkouts, branches, or archives. Include paths/refs useful for locating remaining work.
git worktree list --porcelain -z.git worktree add -B unless resetting the named branch to the selected commit is authorized; use -b for creation..git and contents. Repair from the current main/bare repository with new absolute linked-worktree paths, and verify inventory. git worktree move cannot move main or submodule-containing worktrees.git worktree remove after the cleanup checks.gc.worktreePruneExpire): repair relocated worktrees promptly and lock intermittently mounted worktrees before storage goes offline (git -C "<repo>" worktree lock --reason "<why>" "<worktree>"; read the reason before unlocking, never prune or unlock a merely unavailable checkout). See Registration commands.git config --worktree isolation unless extensions.worktreeConfig is enabled. Before enabling it, migrate existing core.worktree and core.bare from shared configuration to config.worktree, resolved with git rev-parse --git-path config.worktree from the main checkout or bare repository. Never share core.worktree or core.bare=true. Share core.sparseCheckout only when all worktrees use sparse checkout.extensions.worktreeConfig or relative worktree paths unless all required Git installations support the resulting extensions.git rev-parse --git-path from the target worktree.LuminairPrime/git-worktrees-prime
49d6ae2
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.