Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via…
Isolated git worktrees with smart directory selection and safety verification. Automatically detects worktree directory location by checking existing directories, CLAUDE.md preferences, or asking the user; supports both project-local (.worktrees) and global (~/.config/superpowers/worktrees) storage Verifies project-local directories are git-ignored before creation to prevent accidentally committing worktree contents Auto-detects and runs project setup (npm install, cargo build, pip install, go mod download) based on detected project files Runs baseline tests to ensure a clean starting state before proceeding with feature work Integrates with brainstorming, subagent-driven-development, and plan execution workflows to provide isolated workspaces Using Git Worktrees Overview Ensure work happens in an isolated workspace. Prefer your platform's native worktree tools. Fall back to manual git worktrees only when no native tool is available. Core principle: Detect existing isolation first. Then use native tools. Then fall back to git. Never fight the harness. Announce at start: "I'm using the using-git-worktrees skill to set up an isolated workspace." Step 0: Detect Existing Isolation Before creating anything, check if you are already in an isolated workspace. GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P) GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P) BRANCH=$(git branch --show-current)
don't have the plugin yet? install it then click "run inline in claude" again.
expanded decision points into explicit if-else branches, added external connection requirements and error handling for network timeouts and git failures, structured procedure into numbered steps with explicit inputs and outputs per step, clarified output contract with both success and failure states, added comprehensive outcome signals and red flags.
use git worktrees to spin up isolated workspaces that share your repository but let you work on multiple branches simultaneously without constant switching. when you need to context-switch between features, bugs, or experiments without losing your current work state, worktrees eliminate the friction of stashing, switching, and unstashing. worktrees are your go-to when you're juggling parallel work streams in the same project.
required
git rev-parse --show-toplevel)feature/auth, bugfix/login)external connections
environment context
1. announce the skill log to user: "i'm using the using-git-worktrees skill to set up an isolated workspace."
inputs: user request, project context outputs: user acknowledgment logged
2. detect project name
run: project=$(basename "$(git rev-parse --show-toplevel)")
inputs: git repository state
outputs: $project variable set (e.g. "myproject")
3. select worktree directory follow this priority order:
a) check for existing .worktrees directory: ls -d .worktrees 2>/dev/null
b) check for existing worktrees directory: ls -d worktrees 2>/dev/null
c) check CLAUDE.md for preference: grep -i "worktree.*director" CLAUDE.md 2>/dev/null
d) if none found, ask user to choose between .worktrees/ (hidden, project-local) or ~/.config/superpowers/worktrees/<project-name>/ (global)
inputs: filesystem state, CLAUDE.md (optional), user input (conditional)
outputs: $LOCATION variable set to selected directory
4. verify directory safety (project-local only)
if location is .worktrees or worktrees:
git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/nullif location is global (~/.config/superpowers/worktrees/):
inputs: filesystem state, .gitignore content outputs: .gitignore updated if needed, directory confirmed safe
5. construct full worktree path
if location is .worktrees or worktrees: path="$LOCATION/$BRANCH_NAME"
if location is global: path="~/.config/superpowers/worktrees/$project/$BRANCH_NAME"
inputs: $LOCATION, $BRANCH_NAME, $project
outputs: $path variable set to full worktree directory path
6. create the worktree
run: git worktree add "$path" -b "$BRANCH_NAME"
run: cd "$path"
inputs: $path, $BRANCH_NAME
outputs: new git worktree directory created, current directory changed to worktree root
7. auto-detect and install dependencies check for project manifest files in order and run appropriate install:
package.json exists: npm installCargo.toml exists: cargo buildrequirements.txt exists: pip install -r requirements.txtpyproject.toml exists: poetry installgo.mod exists: go mod downloadskip if no manifest found (bare project).
inputs: project root files outputs: dependencies installed in worktree
8. run baseline test suite detect and execute project tests:
npm testcargo testpytestgo test ./...skip if no test runner detected.
inputs: project test configuration outputs: test results (pass/fail counts, output log)
9. report worktree ready or failure
if tests pass: report Worktree ready at <full-path> / Tests passing (<N> tests, 0 failures) / Ready to implement <feature-name>
if tests fail: report failure details, ask user whether to proceed or investigate before continuing.
inputs: test results, $path, feature name
outputs: status message to user, proceed/abort decision
directory location selection
.worktrees exists: use it (skip .worktrees/ check, verify ignored)worktrees exists: use it (verify ignored).worktrees/) or global (~/.config/superpowers/worktrees/<project-name>/)ignore verification (project-local only)
git check-ignore: proceed to worktree creationdependency installation
test baseline verification
error handling on worktree creation
network or timeout issues
on success
<full-path> (e.g. /Users/jesse/myproject/.worktrees/feature/auth or ~/.config/superpowers/worktrees/myproject/feature/auth)npm install, cargo build, etc.on failure
file locations
.git/worktrees/ (git-managed, auto-created)$path (user-specified directory)user knows it worked when
~/.../myproject/.worktrees/feature/auth $)pwd confirms location is the new worktree pathgit status shows clean working tree (or expected branch state)red flags (did not work)