
Git Worktrees
Run parallel feature branches in separate folders without stashing so a solo builder can code on main work while reviewing or testing another branch in isolation.
Overview
Git Worktrees is an agent skill most often used in Build (also Ship review) that guides solo builders through `git worktree` commands and parallel-directory workflows so multiple branches stay active without stashing or
Install
npx skills add https://github.com/neolabhq/context-engineering-kit --skill git-worktreesWhat is this skill?
- One worktree per active branch—switch context by changing directories, not by checkout
- Shared `.git` object database across linked worktrees (no full repo clone duplication)
- Branch lock: each branch can only be checked out in one worktree at a time
- Quick-reference commands for add, list, remove, prune, and move worktrees
- Workflow patterns for PR review while continuing feature development on another path
- Core concepts table covers 5 worktree ideas (main, linked, shared .git, branch lock, metadata)
- Quick-reference command table for common worktree tasks
Adoption & trust: 512 installs on skills.sh; 1.1k GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need to jump between branches—for a PR review, a hotfix, or an experiment—but stashing or recloning breaks your flow and risks losing local state.
Who is it for?
Solo developers who routinely context-switch between a feature branch, review branches, and quick experiments on the same repository.
Skip if: Repos where you only ever work linearly on a single branch with no parallel review or spike work—or teams that already standardize on separate full clones per task and do not want linked worktrees.
When should I use this skill?
Working on multiple branches simultaneously, context switching without stashing, reviewing PRs while developing, testing in isolation, or comparing implementations across branches.
What do I get? / Deliverables
You get stable extra working directories tied to one repo, clear commands for add/list/prune, and a one-worktree-per-branch habit so the agent can run Git operations in the right folder without branch checkout conflicts.
- Correct `git worktree` command sequences for the user’s scenario
- Recommended directory layout (one worktree per active branch)
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Parallel checkouts are a day-to-day build-time workflow for anyone shipping code with Git, even before formal ship-phase review. Git worktrees are repo and tooling integration patterns—exactly the integrations shelf for how the agent runs Git alongside your editor and CI.
Where it fits
Spin up a linked worktree for a dependency bump while your main tree stays on a half-finished feature.
Check out a teammate’s PR branch in its own directory to run tests without touching your WIP commits.
Prototype an alternate API shape in a throwaway worktree before merging back to your main branch.
Reproduce a production bug on a hotfix branch in isolation while release prep continues on main.
How it compares
Prefer structured worktree workflows over repeated `git stash` / `git checkout` churn when you need two branches live at once.
Common Questions / FAQ
Who is git-worktrees for?
It is for solo and indie builders (and small teams) who use AI coding agents on real Git repos and need parallel branches without losing uncommitted work.
When should I use git-worktrees?
Use it during Build when integrating features across branches, and during Ship review when you want to test or read a PR in isolation while keeping your main working tree on in-progress work.
Is git-worktrees safe to install?
It is procedural Git guidance, not a binary you run; review the Security Audits panel on this Prism page and only let agents execute worktree commands in repos you trust.
SKILL.md
READMESKILL.md - Git Worktrees
# Git Worktrees ## Overview Git worktrees enable checking out multiple branches simultaneously in separate directories, all sharing the same repository. Create a worktree instead of stashing changes or cloning separately. **Core principle:** One worktree per active branch. Switch contexts by changing directories, not branches. ## Core Concepts | Concept | Description | |---------|-------------| | **Main worktree** | Original working directory from `git clone` or `git init` | | **Linked worktree** | Additional directories created with `git worktree add` | | **Shared `.git`** | All worktrees share same Git object database (no duplication) | | **Branch lock** | Each branch can only be checked out in ONE worktree at a time | | **Worktree metadata** | Administrative files in `.git/worktrees/` tracking linked worktrees | ## Quick Reference | Task | Command | |------|---------| | Create worktree (existing branch) | `git worktree add <path> <branch>` | | Create worktree (new branch) | `git worktree add -b <branch> <path>` | | Create worktree (new branch from ref) | `git worktree add -b <branch> <path> <start>` | | Create detached worktree | `git worktree add --detach <path> <commit>` | | List all worktrees | `git worktree list` | | Remove worktree | `git worktree remove <path>` | | Force remove worktree | `git worktree remove --force <path>` | | Move worktree | `git worktree move <old> <new>` | | Lock worktree | `git worktree lock <path>` | | Unlock worktree | `git worktree unlock <path>` | | Prune stale worktrees | `git worktree prune` | | Repair worktree links | `git worktree repair` | | Compare files between worktrees | `diff ../worktree-a/file ../worktree-b/file` | | Get one file from another branch | `git checkout <branch> -- <path>` | | Get partial file changes | `git checkout -p <branch> -- <path>` | | Cherry-pick a commit | `git cherry-pick <commit>` | | Cherry-pick without committing | `git cherry-pick --no-commit <commit>` | | Merge without auto-commit | `git merge --no-commit <branch>` | ## Essential Commands ### Create a Worktree ```bash # Create worktree with existing branch git worktree add ../feature-x feature-x # Create worktree with new branch from current HEAD git worktree add -b new-feature ../new-feature # Create worktree with new branch from specific commit git worktree add -b hotfix-123 ../hotfix origin/main # Create worktree tracking remote branch git worktree add --track -b feature ../feature origin/feature # Create worktree with detached HEAD (for experiments) git worktree add --detach ../experiment HEAD~5 ``` ### List Worktrees ```bash # Simple list git worktree list # Verbose output with additional details git worktree list -v # Machine-readable format (for scripting) git worktree list --porcelain ``` **Example output:** ``` /home/user/project abc1234 [main] /home/user/project-feature def5678 [feature-x] /home/user/project-hotfix ghi9012 [hotfix-123] ``` ### Remove a Worktree ```bash # Remove worktree (working directory must be clean) git worktree remove ../feature-x # Force remove (discards uncommitted changes) git worktree remove --force ../feature-x ``` ### Move a Worktree ```bash # Relocate worktree to new path git worktree move ../old-path ../new-path ``` ### Lock/Unlock Worktrees ```bash # Lock worktree (prevents pruning if on removable storage) git worktree lock ../feature-x git worktree lock --reason "On USB drive" ../feature-x # Unlock worktree git worktree unlock ../feature-x ``` ### Prune Stale Worktrees ```bash # Remove stale worktree metadata (after manual directory deletion) git worktree prune # Dry-run to see