Manage Git worktrees for isolated or parallel software development. Use when creating, reusing, integrating, or cleaning up task checkouts and branches. Use when experimental or parallel agent work must be done without stepping on others' toes.
94%
Does it follow best practices?
Impact
100%
1.20x1 of 3 eval scenarios. Add 2 more for a full score.
Passed
No findings from the security scan
The canonical home for this skill is git-worktrees-prime in LuminairPrime/git-worktrees-prime
Create, choose, use, integrate, and retire task worktrees. Follow user instructions and repository conventions; keep ownership and the integration target explicit.
| Term | Meaning |
|---|---|
| Repository | The shared commit history and named references used by its worktrees. |
| Worktree / checkout | A directory of checked-out files with its own HEAD and index (staging area). Here, the noun checkout means this workspace. |
| Branch | A named reference to the latest commit in a line of development. A commit records a project snapshot and its history links. A branch can exist without a checkout. |
HEAD / detached HEAD | Each worktree's HEAD normally names its checked-out branch. A detached HEAD points directly to a commit, so new commits do not advance a branch. |
| Main (primary) / linked worktree | The main worktree is the repository's original checkout; additional worktrees are linked worktrees. <primary-root> means the main worktree's directory, regardless of its branch name. A bare repository has no main worktree. |
| Base / integration target | The base is the commit or ref used to start the task. The integration target is the branch intended to receive the result. 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. |
One repository can have several worktrees on different branches or detached commits. Removing a worktree leaves its branch. Name the checkout path and branch/ref separately when communicating about them.
git worktree list --porcelain; inspect changes and ongoing Git operations.Worktrees separate working files and indexes, but share objects, refs, remotes, and much Git configuration. Coordinate shared mutations. They provide no security boundary; concurrent services may also need distinct ports, databases, and output locations.
git -C "<repo>" worktree repair "<worktree>" using its current absolute path. Re-list worktrees to verify the new registration. Do not prune the live checkout's registration.<primary-root>/.worktrees/<task>. 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.Substitute all placeholders. Run only the selected alternative. <repo> is an existing checkout; <worktree> is the task's exact absolute path.
git -C "<repo>" worktree list --porcelain
git -C "<repo>" status --short --branch
git -C "<repo>" rev-parse --verify "<base-ref>^{commit}"
# Only for a destination inside another checkout; require exit 0 before creation.
git -C "<enclosing-checkout>" check-ignore -q -- "<selected-relative-path>/"
# New branch, explicitly based on the selected commit/ref.
git -C "<repo>" worktree add -b "<task-branch>" "<worktree>" "<base-ref>"
# Alternative: continue an existing branch that is not checked out elsewhere.
git -C "<repo>" worktree add "<worktree>" "<task-branch>"
# Alternative: disposable inspection of a specific commit.
git -C "<repo>" worktree add --detach "<worktree>" "<commit>"
git -C "<worktree>" rev-parse --show-toplevel
git -C "<worktree>" status --short --branch
git -C "<worktree>" rev-parse HEADEvaluate 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.# A clean tracked-file status does not account for ignored local state.
git -C "<worktree>" status --short --branch --untracked-files=all
git -C "<worktree>" status --short --ignored
git -C "<worktree>" rev-parse HEAD
# Exit 0 proves this tip is an ancestor of this target. Other outcomes need review.
git -C "<repo>" merge-base --is-ancestor "<task-tip>" "<integration-ref>"
# Run from a surviving checkout after the checks above.
git -C "<repo>" worktree remove "<worktree>"
git -C "<repo>" branch -d "<task-branch>"
git -C "<repo>" worktree list --porcelain
# Only for intentionally removed worktrees; review every dry-run entry before pruning.
git -C "<repo>" worktree prune --dry-run --verbose
git -C "<repo>" worktree prune --verbosebranch -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.--force, reset changes, unlock a worktree, or recursively delete its directory merely to overcome a refusal. Resolve the cause; submodules and managed checkouts may require another supported removal method.Before reporting a retained task checkout ready, verify its absolute path, branch (or intended detached commit), current registration, and any required ignore coverage.
State the work and checks completed, the integration or review status, and which checkout, branches, or archives were removed or retained. Include paths or refs only where they help locate remaining work.
LuminairPrime/git-worktrees-prime
49d6ae2
Canonical home
since Oct 3, 2026
Also appears in
last in sync Oct 3, 2026
last in sync Oct 3, 2026
last in sync Oct 3, 2026
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.