worktrees:concepts
/worktrees:concepts
Comprehensive reference for git worktrees. Covers concepts, commands, conflict resolution, and best practices. Invoke with "/worktrees:concepts" or when user mentions "worktree reference", "explain worktrees", "worktree documentation", "worktree commands", "worktree concepts", or "learn about worktrees".
- Author
- aaronbassett ↗
- Repository
- agent-foundry ↗
- Licence
- MIT
- Last repository change
- 16.08.2026
Assessment and security
- Files in this package
- 4
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 16.08.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Comprehensive reference for git worktrees. Covers concepts, commands, conflict resolution, and best practices. Invoke with "/worktrees:concepts" or when user mentions "worktree reference", "explain worktrees", "worktree documentation", "worktree commands", "worktree concepts", or "learn about worktrees".
Triggers from the description
Original author description
Comprehensive reference for git worktrees. Covers concepts, commands, conflict resolution, and best practices. Invoke with "/worktrees:concepts" or when user mentions "worktree reference", "explain worktrees", "worktree documentation", "worktree commands", "worktree concepts", or "learn about worktrees".
How it works
- What Are Worktrees?
- When to Use Worktrees
- Directory Organization
- Workspace Organization
- Environment Isolation
- Resource Considerations
- Common Pitfalls
- Git Version Requirements
- Quick Reference
- Reference Files
SKILL.md preview
--- name: worktrees:concepts description: Comprehensive reference for git worktrees. Covers concepts, commands, conflict resolution, and best practices. Invoke with "/worktrees:concepts" or when user mentions "worktree reference", "explain worktrees", "worktree documentation", "worktree commands", "worktree concepts", or "learn about worktrees". version: 0.1.0 --- # Git Worktrees Reference Comprehensive reference for git worktrees in AI development workflows. ## What Are Worktrees? Git worktrees allow checking out multiple branches simultaneously in separate directories, all sharing the same `.git` repository. **Key characteristics:** - Each worktree has its own working directory and index - All worktrees share the same Git history and objects - Branches checked out in worktrees are "locked" to prevent checkout elsewhere - Worktrees persist across sessions until explicitly removed ## When to Use Worktrees **Ideal for:** - Parallel development of independent features - Isolating experimental work from stable code - Running tests in one branch while developing in another - AI agent collaboration requiring workspace isolation - Reviewing PRs without stashing current work **Not ideal for:** - Very small, quick fixes (overhead not worth it) - When disk space is severely limited - Single-file changes that don't need isolation ## Directory Organization ### Recommended Structure ``` my-project/ ├── .git/ # Shared git directory ├── .gitignore # Must include .worktrees/ ├── .worktrees/ # All worktrees live here │ ├── feature-auth/ # Feature worktree │ ├── feature-api/ # Another feature worktree │ └── hotfix-urgent/ # Hotfix worktree └── src/ # Main working directory ``` ### First-Time Setup Before creating any worktree, ensure `.worktrees/` is gitignored: ```bash grep -q "^\.worktrees" .gitignore 2>/dev/null || echo ".worktrees/" >> .gitignore git add .gitignore git commit -m "chore: add .worktrees to gitignore" ``` **Why gitignore?** Each worktree contains a complete checkout. Without gitignoring, you'd accidentally commit nested copies of your entire codebase. ### Naming Conventions | Type | Pattern | Example | |------|---------|---------| | Feature | `feature-<name>` | `feature-auth` | | Agent | `<agent-id>-<feature>` | `agent-42-api` | | Instance | `inst-<id>` | `inst-alpha` | | Hotfix | `hotfix-<issue>` | `hotfix-login` | ## Workspace Organization ### Desktop Layout For multiple concurrent worktrees: - **One Space/Desktop per worktree** - Quick switching with keyboard shortcuts - **Consistent layout**: IDE on left, Claude on right - **Separate terminal tabs** per worktree - **tmux sessions** for persistence ### Editor Windows - Separate window per worktree - Clear titles: `[worktree-name] - project` - Color-code terminals by worktree ## Environment Isolation ### Port Assignment Avoid port conflicts when running multiple instances: ```bash # Worktree 1 PORT=3001 npm run dev # Worktree 2 PORT=3002 npm run dev ``` ### Database Options | Approach | When to Use | |----------|-------------| | SQLite per worktree | Simple apps, testing | | PostgreSQL schemas | Shared DB, isolated data | | Docker containers | Full isolation | | In-memory DB | Unit tests | ```bash # SQLite: Different files DATABASE_URL="file:.worktrees/auth/dev.sqlite" # PostgreSQL: Different schemas DATABASE_URL="postgres://localhost/app?schema=worktree_auth" # Docker: Different containers docker-compose -p worktree-auth up -d ``` ### Environment Files Keep worktree-specific `.env` files: ```bash # In worktree cp ../.env.example .env # Customize PORT, DATABASE_URL, etc. ``` ## Resource Considerations ### Disk Space Each worktree duplicates working files (not git objects): - Small projects: ~10-50MB per worktree - Large projects: Can be significant ```bash # Check worktree sizes du -sh .worktrees/* ``` ### Memory Multiple running dev servers increase memory usage: - Monitor with `top` or `htop` - Stop unused dev servers - Consider using `--watch` only on active worktree ### File Watchers Many tools use file watchers (webpack, nodemon, etc.): - Each worktree may spawn watchers - Can hit system limits on large projects - Increase limits if needed: `fs.inotify.max_user_watches` ## Common Pitfalls ### Branch Already Checked Out **Error:** `fatal: 'branch-name' is already checked out at '/path'` **Cause:** Each branch can only exist in one worktree. **Solutions:** 1. Use the existing worktree: `git worktree list` 2. Create a new branch for the new worktree 3. Remove the existing worktree first ### Uncommitted Changes on Removal **Error:** `fatal: cannot remove worktree with uncommitted changes` **Solutions:** 1. Commit changes: `git add . && git commit -m "WIP"` 2. Stash changes: `git stash` 3. Force remove (loses changes): `git worktree remove --force` ### Stale Worktree References **Problem:** Manually deleted worktree directory leaves stale entry. **Solution:** `git worktree prune` ### Detached HEAD in Worktree **Problem:** Worktree ends up in detached HEAD state. **Solution:** ```bash cd .worktrees/<name> git checkout <branch> # or create new branch git checkout -b <new-branch> ``` ## Git Version Requirements | Feature | Git Version | |---------|-------------| | Basic worktree | 2.5+ | | `worktree list` | 2.7+ | | `worktree lock/unlock` | 2.10+ | | `worktree move` | 2.17+ | | `worktree remove` | 2.17+ | | `worktree repair` | 2.30+ | | `--orphan` | 2.37+ | Check version: `git --version` ## Quick Reference | Task | Command | |------|---------| | Create (new branch) | `git worktree add -b <branch> .worktrees/<name> [base]` | | Create (existing branch) | `git worktree add .worktrees/<name> <branch>` | | List | `git worktree list` | | Remove | `git worktree remove .worktrees/<name>` | | Force remove | `git worktree remove --force .worktrees/<name>` | | Prune stale | `git worktree prune` | | Lock | `git worktree lock .worktrees/<name>` | | Unlock | `git worktree unlock .worktrees/<name>` | | Move | `git worktree move .worktrees/<old> .worktrees/<new>` | | Repair | `git worktree repair` | ## Reference Files For detailed information, see: - **`references/commands-reference.md`** - Complete git worktree command reference - **`references/conflict-resolution.md`** - Handling merge conflicts - **`references/best-practices.md`** - Recommended patterns and tips ## Related Skills - **`/worktrees:new`** - Create a new worktree - **`/worktrees:status`** - Check worktree health and status - **`/worktrees:finish`** - Complete and clean up worktree - **`/worktrees:peer`** - Independent PR-based workflow - **`/worktrees:orchestrator`** - Multi-subagent parallel development
Files in this package (4)
- SKILL.md 7 KB
- references/best-practices.md 6 KB
- references/commands-reference.md 8 KB
- references/conflict-resolution.md 6 KB
Versions
The database has no other skills named worktrees:concepts.
Database snapshot: 13.11.2026 · package version d7108d49e572 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 2 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100wt
This skill should be used when the user asks about 'wt', 'worktree', 'worktrees', 'wt create', 'wt checkout', 'wt list', 'wt remove', 'wt pr', 'wt mr', or mentions managing git worktrees with wt. Also use when the user asks how wt works, how to use wt commands, or how to… - 100git-worktrees
Git worktree management for parallel agent team development. Triggers: 'create worktree', 'worktree setup', or during /delegate dispatch. Do NOT use for branch creation without delegation context. - 90worktrees:status
Display comprehensive worktree status including active worktrees, stale references, and uncommitted changes. Invoke with "/worktrees:status" or when user mentions "worktree status", "list worktrees", "check worktrees", "worktree health", or "audit worktrees". - 100worktree
Create, inspect, and safely remove git worktrees for repos under the workspace root (WORKSPACE_ROOT, default ~/git), enforcing the worktree-first policy and the no-stale-worktree guarantee. Use whenever you are about to make a change that will be committed, when the user says… - 100git-worktree
This skill should be used when the user wants to manage Git worktrees - creating worktrees from local or remote branches, listing active worktrees with details, deleting worktrees, or switching between worktrees. Ideal for working on multiple branches simultaneously without stashing changes. - 90worktrees-plan-recipe
Worktrees — Plan, follow or revise how this repository makes git worktrees, one per change. Use when the person wants changes done in worktrees ("trabaja en un worktree", "un worktree por desarrollo", "work in a worktree"), when a session says the worktrees feature has no recipe…