Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Create isolated git worktrees for feature development without switching branches
.claude/skills/kunanonj-git-worktree/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-04 | ✗→✓ | ▲ Improved | 97% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 156% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 228% | 0% |
| case-12 | ✗→✓ | ▲ Improved | 53% | 0% |
| case-13 | ✗→✓ | ▲ Improved | 69% | 0% |
Create isolated git worktrees for feature development without switching branches.
Core principle: Smart directory selection + symlink optimization + background verification = fast, reliable isolation.
Requires: Git 2.5.0+ (July 2015)
Companion commands: /git-worktree-status | /git-worktree-remove | /git-worktree-clean
.worktrees/ or worktrees/git worktree addnode_modules/ from main worktree| Flag | Effect | |------|--------| | --fast | Skip dependency install and baseline tests | | --isolated | Fresh node_modules install (no symlink) | | --skip-install | Skip dependency install, keep baseline tests |
bash# Auto-prefix based on naming convention # "auth" → "feat/auth" (default prefix) # "fix/login-bug" → kept as-is # "refactor/db-layer" → kept as-is # Accepted prefixes: feat/, fix/, refactor/, chore/, docs/, test/, perf/ # If no prefix → default to feat/ # Reject invalid characters echo "$BRANCH_NAME" | grep -qE '^[a-zA-Z0-9/_-]+$' || exit 1 # Check branch doesn't already exist git show-ref --verify --quiet "refs/heads/$BRANCH_NAME" && echo "Branch already exists" && exit 1
bash# 1. Check existing directories ls -d .worktrees 2>/dev/null # Preferred (hidden) ls -d worktrees 2>/dev/null # Alternative # 2. Check CLAUDE.md for preference grep -i "worktree.*director" CLAUDE.md 2>/dev/null # 3. Ask user if neither exists
If both exist: .worktrees/ wins.
For project-local directories:
bash# Check if directory in .gitignore grep -q "^\.worktrees/$" .gitignore || grep -q "^worktrees/$" .gitignore
If NOT in .gitignore:
Why critical: Prevents accidentally committing worktree contents.
bash# 1. Detect project name project=$(basename "$(git rev-parse --show-toplevel)") # 2. Create worktree with new branch git worktree add .worktrees/$BRANCH_NAME -b $BRANCH_NAME # 3. Navigate cd .worktrees/$BRANCH_NAME
Default behavior: Symlink node_modules from main worktree to avoid duplicate installs (~30s saved).
bash# Symlink node_modules (default, unless --isolated) if [ -d "../../node_modules" ] && [ ! "$ISOLATED" = true ]; then ln -s "$(cd ../.. && pwd)/node_modules" node_modules echo "Symlinked node_modules from main worktree" fi # With --isolated: fresh install if [ "$ISOLATED" = true ]; then pnpm install # or npm/yarn based on lockfile detection fi
When to use --isolated:
node_modules issuesbash# Node.js (if not symlinked) if [ -f package.json ] && [ ! -L node_modules ]; then pnpm install # Detect from lockfile: pnpm-lock.yaml / yarn.lock / package-lock.json fi # Rust if [ -f Cargo.toml ]; then cargo build; fi # Python if [ -f requirements.txt ]; then pip install -r requirements.txt; fi if [ -f pyproject.toml ]; then poetry install; fi # Go if [ -f go.mod ]; then go mod download; fi
Instead of blocking on full test suite, run verification in background:
bash# Create log directory mkdir -p .worktree-logs # Background type check (Node.js) if [ -f tsconfig.json ]; then npx tsc --noEmit > .worktree-logs/typecheck.log 2>&1 & echo "Type check running in background (check with /git-worktree-status)" fi # Background test run if [ -f package.json ]; then npx vitest run --reporter=json > .worktree-logs/tests.log 2>&1 & echo "Tests running in background (check with /git-worktree-status)" fi
With --fast: Skip all verification.
Worktree ready at <full-path>
Branch: feat/auth (created from main)
Dependencies: symlinked from main worktree
Background checks: type check + tests running
Check status: /git-worktree-status
Ready to implement <feature-name>After worktree creation, detect database provider and suggest isolation.
| Provider | Suggested Command | |----------|-------------------| | Neon | neonctl branches create --name <branch> --parent main | | PlanetScale | pscale branch create <db> <branch> | | Local Postgres | psql -c "CREATE SCHEMA <schema>;" | | Other | Manual setup or shared DB |
Example output:
Worktree created at .worktrees/feat/auth
DB Isolation: neonctl branches create --name feat-auth --parent main
Then update .env with new DATABASE_URL
Full guide: ../workflows/database-branch-setup.mdCritical for environment variables:
bash# .worktreeinclude (at project root) .env .env.local .env.development **/.claude/settings.local.json
Why: Without this, .env files won't be copied to worktrees.
| Scenario | Create Branch? | |----------|---------------| | Schema migrations | Yes | | Data model refactoring | Yes | | Bug fix (no schema change) | No | | Performance experiments | Yes |
See: Database Branch Setup Guide for complete workflows.
| Situation | Action | |-----------|--------| | .worktrees/ exists | Use it (verify .gitignore) | | worktrees/ exists | Use it (verify .gitignore) | | Both exist | Use .worktrees/ | | Neither exists | Check CLAUDE.md, then ask user | | Not in .gitignore | Add + commit immediately | | No branch prefix | Auto-prefix with feat/ | | Node.js project | Symlink node_modules by default | | --fast flag | Skip install + tests | | --isolated flag | Fresh node_modules install | | Neon detected | Suggest neonctl branches create | | PlanetScale detected | Suggest pscale branch create | | No .worktreeinclude | Create with .env pattern |
Skipping .gitignore verification
Assuming directory location
Installing full node_modules in every worktree
--isolated only when neededNot copying .env to worktree
.env to .worktreeincludeUsing shared database for schema changes
/git-worktree auth
/git-worktree fix/session-bug
/git-worktree feature/new-api --fast
/git-worktree refactor/db-layer --isolatedBranch name: $ARGUMENTS
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 5,902 | 6,375 | +8% | 1 | 1 | 0% | 259 | 2,451 | +846% | 0 | 0 | — |
case-02 | fail→fail | 10,305 | 8,499 | -18% | 1 | 1 | 0% | 1,968 | 2,667 | +36% | 0 | 0 | — |
case-03 | fail→fail | 6,967 | 5,363 | -23% | 1 | 1 | 0% | 1,353 | 2,376 | +76% | 0 | 0 | — |
case-04 | fail→pass | 6,743 | 2,077 | -69% | 1 | 1 | 0% | 1,230 | 2,423 | +97% | 0 | 0 | — |
case-05 | fail→pass | 5,375 | 2,018 | -62% | 1 | 1 | 0% | 935 | 2,394 | +156% | 0 | 0 | — |
case-21 | pass→pass | 3,417 | 3,978 | +16% | 1 | 1 | 0% | 672 | 2,859 | +325% | 0 | 0 | — |
case-06 | pass→pass | 4,930 | 3,879 | -21% | 1 | 1 | 0% | 849 | 2,844 | +235% | 0 | 0 | — |
case-07 | fail→pass | 3,870 | 3,541 | -9% | 1 | 1 | 0% | 836 | 2,745 | +228% | 0 | 0 | — |
case-08 | pass→pass | 5,414 | 4,883 | -10% | 1 | 1 | 0% | 1,025 | 3,011 | +194% | 0 | 0 | — |
case-09 | pass→pass | 14,235 | 2,726 | -81% | 1 | 1 | 0% | 2,359 | 2,492 | +6% | 0 | 0 | — |
case-10 | pass→pass | 11,127 | 5,484 | -51% | 1 | 1 | 0% | 1,922 | 3,059 | +59% | 0 | 0 | — |
case-11 | pass→pass | 10,622 | 3,017 | -72% | 1 | 1 | 0% | 1,614 | 2,589 | +60% | 0 | 0 | — |
case-12 | fail→pass | 11,650 | 4,583 | -61% | 1 | 1 | 0% | 1,853 | 2,837 | +53% | 0 | 0 | — |
case-13 | fail→pass | 8,291 | 1,598 | -81% | 1 | 1 | 0% | 1,355 | 2,286 | +69% | 0 | 0 | — |
case-14 | pass→pass | 6,121 | 1,404 | -77% | 1 | 1 | 0% | 1,082 | 2,267 | +110% | 0 | 0 | — |
case-15 | fail→pass | 9,063 | 1,754 | -81% | 1 | 1 | 0% | 1,655 | 2,261 | +37% | 0 | 0 | — |
case-16 | fail→pass | 10,888 | 1,110 | -90% | 1 | 1 | 0% | 1,880 | 2,208 | +17% | 0 | 0 | — |
case-17 | fail→pass | 5,249 | 2,082 | -60% | 1 | 1 | 0% | 952 | 2,330 | +145% | 0 | 0 | — |
case-18 | pass→pass | 3,401 | 2,914 | -14% | 1 | 1 | 0% | 579 | 2,507 | +333% | 0 | 0 | — |
case-19 | fail→pass | 14,211 | 1,646 | -88% | 1 | 1 | 0% | 2,583 | 2,278 | -12% | 0 | 0 | — |
case-20 | pass→pass | 2,574 | 2,649 | +3% | 1 | 1 | 0% | 475 | 2,466 | +419% | 0 | 0 | — |
case-22 | pass→pass | 4,124 | 4,197 | +2% | 1 | 1 | 0% | 704 | 2,745 | +290% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 19 counted toward the lift figure. The other 3 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +41 percentage points is the difference between those two pass rates over the 19 comparable cases. 2 cases got worse with the skill loaded, and they are included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.