bundles/dev-workflow/skills/worktree/SKILL.md
Create an isolated git worktree from the correct base branch and check it out into a clean, gitignored directory. Use when the user asks to make a worktree, spin up a parallel/isolated workspace, work on something without disturbing the current checkout, branch off the current work, or run multiple agents on the same repo at once. Picks the base branch smartly — the current feature branch when you are on one, otherwise the repository's default/trunk branch — so worktrees continue your in-progress work by default instead of forking from the wrong place.
npx skillsauth add shipshitdev/library worktreeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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.development
TypeScript refactoring and modernization guidelines from a principal specialist perspective. This skill should be used when refactoring, reviewing, or modernizing TypeScript code to ensure type safety, compiler performance, and idiomatic patterns. Triggers on tasks involving TypeScript type architecture, narrowing, generics, error handling, or migration to modern TypeScript features.
tools
Resolves TypeScript and JavaScript problems across type-level programming, performance, monorepo management, migration, and modern tooling. Invoke when diagnosing "type instantiation excessively deep" errors, migrating JS to TS, configuring strict tsconfig, debugging module resolution, or choosing between Biome/ESLint/Turborepo/Nx.
tools
Turborepo monorepo build system guidance. Triggers on: `turbo.json`, task pipelines, `dependsOn`, caching, remote cache, the `turbo` CLI, `--filter`, `--affected`, CI optimization, environment variables, internal packages, monorepo structure, and package boundaries. Use when the user configures tasks or workflows, creates packages, sets up a monorepo, shares code between apps, runs changed packages, debugs cache behavior, or works in an `apps/` plus `packages/` workspace.
tools
Provides Tailwind CSS v4 performance optimization and best practices guidelines. Triggers when writing, reviewing, or refactoring Tailwind CSS v4 code; when working with Tailwind configuration, @theme directive, utility classes, responsive design, dark mode, container queries, or CSS generation optimization.