Create, switch to, or delete a git worktree under ~/.worktrees/<path-key>/<branch>, then rebase the agent session onto that directory. Use when asked to make, enter, or remove a worktree for a branch, when work needs an isolated checkout, or when invoked as /git:worktree.
100%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Announce at start: "Using git-worktree skill to the worktree for ."
This skill never re-derives worktree paths in prose. wt on PATH is the single agent-side implementation. Layout and constraint questions belong to the using-git-worktrees skill.
| Invocation | Effect |
|---|---|
wt path <branch> [--allow-home] | prints the path that would be used; mutates nothing |
wt resolve <branch> [--allow-home] | prints the registered worktree path, or exits 3 |
wt switch <branch> [--allow-home] | resolve, else create; prints the path |
wt create <branch> [--allow-home] | create only; exits 4 if already registered |
wt remove <branch> [--allow-home] [--force] | git worktree remove + prune; never touches the branch |
wt list | one <path>\t<branch> line per worktree (agents cannot use wt's fzf picker) |
wt verify <branch> | just check with HOME remapped (implies --allow-home) |
The load-bearing part. Three parts, in this order:
Capture the path:
wt_path=$(wt switch "$branch" ${allow_home:+--allow-home})From this point in the session:
git -C "$wt_path" …, or the bash tool's cwd parameter (omp resolves an absolute cwd outside the session directory fine; verified)read/grep/glob/edit) uses absolute paths under $wt_pathtask subagent prompt states $wt_path and requires absolute paths under it. Subagents inherit the parent's cwd and the task tool has no cwd field, so a subagent given relative paths silently works in the wrong tree$wt_path verbatim, so the binding survives context compactionDetect the harness — order matters, omp sets both OMPCODE=1 and CLAUDECODE=1:
if [ -n "${OMPCODE:-}" ]; then harness=omp
elif [ -n "${CLAUDECODE:-}" ]; then harness=claude
else harness=other; fiThen print exactly one line for the user to run:
| Harness | Line to print | Truth to state alongside it |
|---|---|---|
omp | /move <wt_path> | a real cwd change that keeps this conversation, and reloads project-scoped settings/plugins/commands for the worktree. The agent cannot self-invoke slash commands, so the user runs it. Offer /add-dir <wt_path> instead when they want both roots live, and /dirs to inspect. |
claude | /add-dir <wt_path> | Claude Code has no cwd-change command; this only grants access, so pwd stays put and part A remains the working mechanism |
other | omp --cwd <wt_path> | starts a fresh session rooted at the worktree; loses this conversation. --cwd also bypasses omp's ~→temp-dir auto-switch |
Never suggest omp worktree/omp wt here: that CLI manages omp's own agent worktrees under ~/.omp/wt and has nothing to do with ~/.worktrees/.
Continue the task under part A whether or not the user runs the line. Do not use AskUserQuestion to wait for it.
wt remove refuses in three cases; the skill explains each rather than reaching for --force:
$PWD) is inside the target worktree → tell the user to /move out (omp) or work from another root firstgit -C <path> status --porcelain=v1 and ask before re-running with --forceBranch deletion is out of scope and stays with git-cleanup / branch-finish. After a successful remove, print git -C <repo_root> branch -d <branch> as the follow-up the user may want, and do not run it.
sed/tr pipeline — call wt path.wt shell session as proof that live terminals picked up .config/zsh/** or .config/nushell/** (see using-git-worktrees).git worktree add a path whose leaf differs from the branch name.omp worktree / omp wt, and never describe them as related: they manage omp's own agent worktrees under ~/.omp/wt, not ~/.worktrees/.Pairs with: using-git-worktrees (layout/constraints), branch-finish (post-merge cleanup), git-stack (already creates worktrees under the same convention).
phatblat/dotfiles
4d65cab
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.