florianbruniaux/claude-code-ultimate-guide/git-worktree
Claude Code and agent skill by florianbruniaux/claude-code-ultimate-guide
- community
Checking that the SKILL.md file is still in the repository.
Create isolated git worktrees for feature development without switching branches
Install
npx vskill@latest install florianbruniaux/claude-code-ultimate-guide/git-worktreeSKILL.md
Git worktree setup
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`
Process
- Validate Branch Name: Check naming convention and conflicts
- Check Existing Directories:
.worktrees/orworktrees/ - Verify .gitignore: Ensure worktree dir is ignored
- Create Worktree:
git worktree add - Symlink Dependencies: Reuse
node_modules/from main worktree - Detect Database Provider: Check for DB branching capability
- Install Dependencies: Auto-detect package manager (if not symlinking)
- Run Background Verification: Type check + tests in background
- Report Location: Confirm ready with status
Flags
| Flag | Effect | |
|---|---|---|
--fast | Skip dependency install and baseline tests | |
--isolated | Fresh node_modules install (no symlink) | |
--skip-install | Skip dependency install, keep baseline tests |
Branch name validation
Directory selection
Priority order
If both exist: .worktrees/ wins.
Safety verification
For project-local directories:
If NOT in .gitignore:
- Add line to .gitignore
- Commit the change
- Proceed with worktree creation
Why critical: Prevents accidentally committing worktree contents.
Creation steps
Dependency optimization (node.js)
Default behavior: Symlink node_modules from main worktree to avoid duplicate installs (~30s saved).
When to use `--isolated`:
- Schema changes requiring different package versions
- Testing dependency upgrades
- Debugging
node_modulesissues
Auto-Detect setup (multi-stack)
Background verification
Instead of blocking on full test suite, run verification in background:
With `--fast`: Skip all verification.
Final report
Database branch suggestion
After worktree creation, detect database provider and suggest isolation.
Quick command reference
| 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:
.worktreeinclude setup
Critical for environment variables:
Why: Without this, .env files won't be copied to worktrees.
When to create database branch
| 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.
Quick reference
| 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 |
Common mistakes
Skipping .gitignore verification
- Worktree contents get tracked, pollute git status
Assuming directory location
- Follow priority: existing > CLAUDE.md > ask
Installing full node_modules in every worktree
- Wastes disk and time. Use symlink by default,
--isolatedonly when needed
Not copying .env to worktree
- Symptom: Claude fails with "DATABASE_URL not found"
- Fix: Add
.envto.worktreeinclude
Using shared database for schema changes
- Symptom: Migration conflicts, broken dev environment
- Fix: Create database branch before modifying schema
Usage
Branch name: $ARGUMENTS
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingexamples/skills/git-worktree/SKILL.md
Popularity
- Repository stars
- 5,719
- Repository forks
- 749
- 7-day trend score
- 43
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/florianbruniaux/claude-code-ultimate-guide/git-worktree)