From shipshitdev-library
Creates an isolated git worktree on the correct base branch in a gitignored directory. Use for parallel/isolated workspaces without disturbing the current checkout, or running multiple agents on the same repo.
How this skill is triggered — by the user, by Claude, or both
Slash command
/shipshitdev-library:worktreeWhen to use
make a worktree, create a worktree, new worktree, isolated workspace, parallel workspace, work on this separately, branch off current work, spin up a sibling checkout, run another agent on this repo
This skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Create a git worktree off the **right base branch**, in a clean gitignored
Create a git worktree off the right base branch, in a clean gitignored
directory, with the safety checks that keep the main checkout and .gitignore
correct. This skill only creates and lists worktrees. Removing and
pruning merged worktrees is release-cleanup's job — do not delete here.
Inputs:
from <base> / --base <base>)--fetch flag to refresh the base from origin before branchingOutputs:
.worktrees/<name> checked out on a new branchcd into, ready for a parallel sessionCreates/Modifies:
.worktrees/ to .gitignore and commits that change if not already ignoredExternal Side Effects:
--fetch: a single git fetch origin <base> to refresh the base refConfirmation Required:
.gitignore and committing it (one-time, only if .worktrees/ is not yet ignored)Delegates To:
release-cleanup to verify promotion and prune merged worktrees and branchesgit-safety if a branch about to live in a worktree may contain secretsThe base is resolved in this order. Local tips only — no automatic fetch.
/worktree fix-auth from develop
or --base release/1.4), use it verbatim.master or main, or HEAD is detached, fork from
the repository's default branch (auto-detected). Never use develop or
staging as a long-lived integration base in a trunk-based workflow.current branch -> base the worktree forks from
---------------------- ----------------------------
feat/foo (feature) -> feat/foo (continue current work)
bugfix/x (feature) -> bugfix/x (continue current work)
master / main -> default branch (trunk)
detached HEAD -> default branch (trunk)
explicit "from <base>" -> <base> (always wins)
Protected/trunk set (never used as a "feature" base in step 2):
master main
git rev-parse --is-inside-work-tree # must be true; else STOP
TOPLEVEL="$(git rev-parse --show-toplevel)"
CURRENT="$(git symbolic-ref --quiet --short HEAD || echo DETACHED)"
git worktree list # show what already exists
Resolve the new branch name:
feat/foo
becomes directory .worktrees/feat-foo while the branch stays feat/foo).PROTECTED='master|main'
# Default/trunk branch fallback — resolved to a ref that actually exists locally.
# Auto-detect the repo's default branch; never hardcode develop or staging.
DEF="$(git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null | sed 's#^origin/##')"
DEF="${DEF:-$(git symbolic-ref --quiet --short HEAD 2>/dev/null)}"
DEF="${DEF:-master}"
git show-ref --verify --quiet "refs/heads/$DEF" && FALLBACK="$DEF" || FALLBACK="origin/$DEF"
# Apply the precedence. BASE is the start-point ref passed to `git worktree add`.
if [ -n "$EXPLICIT_BASE" ]; then
BASE="$EXPLICIT_BASE"
elif printf '%s\n' "$CURRENT" | grep -qxE "$PROTECTED" || [ "$CURRENT" = DETACHED ]; then
BASE="$FALLBACK" # on trunk or detached HEAD -> default/trunk branch
else
BASE="$CURRENT" # on a feature branch -> continue current work
fi
echo "Base: $BASE (current: $CURRENT)"
BASE is always a concrete start-point (a local branch like master, a
remote-tracking ref like origin/main, or the user's explicit base). Report
the resolved base and the reason before creating anything.
Local mode is the default: branch from the local tip of $BASE. If the base has
an upstream and is behind it, warn — do not silently fetch.
if git rev-parse --verify --quiet "$BASE@{upstream}" >/dev/null; then
BEHIND="$(git rev-list --count "$BASE..$BASE@{upstream}" 2>/dev/null || echo 0)"
[ "$BEHIND" -gt 0 ] && echo "WARNING: local $BASE is $BEHIND commit(s) behind its remote. Using local tip. Pass --fetch to update first."
fi
Only if the user passed --fetch:
git fetch origin "$BASE"
git update-ref "refs/heads/$BASE" "origin/$BASE" # only when safe / fast-forward
Do not fetch by default. Do not rewrite a base branch that has local commits not on the remote — warn and use the local tip instead.
.worktrees/ Is GitignoredThe worktree directory must never be tracked. Verify, and fix once if needed.
if ! git -C "$TOPLEVEL" check-ignore -q .worktrees; then
# .worktrees/ is not ignored yet — confirm, then add and commit
printf '\n# Local git worktrees (created by the worktree skill)\n.worktrees/\n' >> "$TOPLEVEL/.gitignore"
git -C "$TOPLEVEL" add .gitignore
git -C "$TOPLEVEL" commit -m "chore: ignore .worktrees/ directory"
fi
This is the only commit the skill makes, and only the first time in a repo. Confirm before committing in a shared repo.
NAME="<sanitized-name>"
BRANCH="<new-branch-name>"
DEST="$TOPLEVEL/.worktrees/$NAME"
# Guard: destination must not already exist
[ -e "$DEST" ] && { echo "Path exists: $DEST — choose another name or remove it first."; exit 1; }
if git show-ref --verify --quiet "refs/heads/$BRANCH"; then
# Branch already exists: confirm, then attach it (no -b, no new branch)
git worktree add "$DEST" "$BRANCH"
else
# New branch off the resolved local base tip
git worktree add -b "$BRANCH" "$DEST" "$BASE"
fi
git worktree list
Rules:
-b only when creating a new branch. If the branch exists, attach it and
say so — never silently reset an existing branch.$BRANCH is
already checked out elsewhere, report where and stop.--force. If git refuses, surface the reason and let the user decide.Report:
.worktrees/<name>cd .worktrees/<name> and open a parallel session in
that directory. Each worktree is an independent checkout sharing one .git.node_modules).worktree <name> — create a worktree named <name> on a new branch <name>,
base resolved by the smart rules above. (Default.)worktree <name> from <base> / worktree <name> --base <base> — force the base.worktree <name> --fetch — refresh the base from origin before branching.worktree list — list existing worktrees and their branches; create nothing.When the user scopes it differently ("off master", "use my current branch", "don't touch gitignore"), honor the scope but keep the safety checks that prevent tracking the worktree dir or clobbering an existing branch/path.
.worktrees/ is verified ignored first.--fetch.--force, never reset an existing branch, never overwrite an existing
path. On conflict, report and stop.release-cleanup.npx claudepluginhub shipshitdev/skillsCreates isolated git worktrees for working on branches without switching. Provides smart directory selection (project-local or global) and safety verification to prevent committing worktree contents.
Creates isolated git worktrees for parallel development without disrupting the main workspace. Includes safety verification to prevent accidental commits of worktree contents.
Creates isolated git worktrees for parallel feature development with smart directory selection and safety verification. Use before starting work that needs workspace isolation.