prompts/skills/using-git-worktrees/SKILL.md
Use this whenever you need to create an isolated workspace.
npx skillsauth add ramblurr/nix-devenv using-git-worktreesInstall 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.
ls -d .worktrees 2>/dev/null.worktrees.# Check if directory pattern in .gitignore
grep -qE '^(\.worktrees|worktrees)/$' .gitignore && echo "pattern found" || echo "pattern not found"
cd $path# Node.js
if [ -f package.json ]; then npm install; 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
# Clojure (deps.edn with Babashka task runner)
if [ -f deps.edn ] && [ -f bb.edn ]; then echo "Clojure project detected - deps fetched on first run"; fi
# Examples - use project-appropriate command
npm test
cargo test
pytest
go test ./...
bb test # Clojure (Kaocha via Babashka)
If tests fail: Report failures, ask whether to proceed or investigate.
If tests pass: Report ready.
New working directory: <full-path>
Tests passing (<N> tests, 0 failures)
All commands and tools will now refer to: <full-path>
Understand that you are now in a new working directory. Your Bash tool instructions from here on out should refer to the worktree directory, NOT your original directory. This is ABSOLUTELY CRITICAL.
Remember: extra/ reference material is NOT in the worktree.
The extra/ directory (see @extra-reference-material skill) stays at the original project root. When you need reference material:
/home/user/project//home/user/project/.worktrees/feature/extra/ is at: /home/user/project/extra/ (NOT in the worktree)Store the project root path mentally and use it for all extra/ lookups.
CRITICAL: Once you create and enter a worktree, you must stay within it for the entire session.
Rules:
pwd # Should show .worktrees/branch-name in path
git branch # Should show * on your feature branch, not main
Red Flags:
extra/ inside the worktree path (it's at project root, not in worktree)For Clojure projects using deps.edn and Babashka task runner:
Setup: No explicit dependency install needed - deps are fetched on first run.
Test commands (Kaocha via Babashka):
bb test - Run all tests across all suitesbb test :suite-name - Run a single test suite (check tests.edn for suite names)bb test --help - Get test helpbb test --print-test-ids - List all testsbb test --focus namespace-test - Focus on one testOther tasks:
bb lint - Lint everythingbb lint dir1 dir2 - Lint specific directoriesbb fmt - Format code| Situation | Action |
| --------------------------- | -------------------------- |
| .worktrees/ exists | Use it (verify .gitignore) |
| .worktree/s does not exist | Check CLAUDE.md → Ask user | | Directory not in .gitignore | Add it immediately | | Tests fail during baseline | Report failures + ask | | No package.json/Cargo.toml | Skip dependency install | | deps.edn+bb.ednexist | Runbb test` for tests |
Skipping .gitignore verification
Assuming directory location
Missing project installation
Proceeding with failing tests
Hardcoding setup commands
You: I'm using the Using Git Worktrees skill to set up an isolated workspace.
[Check .worktrees/ - exists]
[Verify .gitignore - contains .worktrees/]
[Create worktree: git worktree add .worktrees/auth -b feature/auth]
[Run npm install]
[Run npm test - 47 passing]
Worktree ready at myproject/.worktrees/auth
Tests passing (47 tests, 0 failures)
Ready to implement auth feature
Never:
extra/ in worktree path (use project root)Always:
testing
Use this OCP when executing or preparing to execute commands that change a live or important system, service reloads/restarts, package changes, deployments, migrations, firewall/network/access changes, credential rotation, NixOS switch/test/boot/deploy, or incident mitigation. It guides safe operations with a persisted ledger for scope, preflight, baseline, rollback, validation, and evidence.
development
Create new agent skills with proper structure, progressive disclosure, and bundled resources. Use when user wants to create, write, or build a new skill.
documentation
Naming conventions for workflow documents in prompts/. Use when creating plans, PRDs, research reports, idea capture or other workflow documents. Triggers on (1) creating new planning documents, (2) naming PRDs or research reports, (3) questions about document organization in prompts/.
testing
Grilling session that challenges your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as decisions crystallise. Use when user wants to stress-test a plan against their project's language and documented decisions.