git-worktree
Creates, lists, and removes git worktrees to manage parallel workspaces. Activate when the user needs to work on multiple branches simultaneously, run parallel tasks in isolation, or when an agent needs its own workspace. Also activate when the user says "worktree", "parallel branch", "work on two things at once", or "run these in parallel".
Worktrees give each parallel task its own filesystem while sharing one repository. Every worktree has a branch; every parallel agent gets its own worktree.
Steps
Pre-flight (mandatory before any worktree creation):
-
Run these two commands and compare output:
git rev-parse --git-dir git rev-parse --git-common-dirIf the outputs differ, you are inside a worktree. Stop immediately and warn: "You are already inside a worktree. Switch to the main checkout first." Do not proceed.
-
Run:
git check-ignore -q .worktreesIf exit code is non-zero, add
.worktrees/to.gitignorebefore proceeding.
Both checks are mandatory. Never skip them — nested worktrees corrupt repository state.
-
Create the worktree — Run:
git worktree add .worktrees/<name> -b <branch-name>Convention: name the directory after the task, prefix the branch by type:
git worktree add .worktrees/fix-auth-bug -b fix/auth-bug git worktree add .worktrees/redesign-nav -b feature/redesign-navIf the branch already exists:
git worktree add .worktrees/<name> <existing-branch> -
Work in the worktree —
cd .worktrees/<name>and operate normally. Run the project's tests after entering to confirm a clean baseline. -
List active worktrees — After creating worktrees, always run:
git worktree listThis confirms the worktrees are set up correctly and shows the full set of active workspaces.
-
Merge results — When work is complete:
- Push the branch and create a PR, or
- From the main checkout:
git merge <branch-name>
-
Remove the worktree — After merging, always run both commands:
git worktree remove .worktrees/<name> git branch -d <branch-name>Both are required —
worktree removedetaches the directory,branch -ddeletes the branch. If the directory was deleted manually, rungit worktree pruneinstead.
Parallel Execution Pattern
For batch operations across multiple tasks, see parallel-execution.md.
Conventions
- Store worktrees in
.worktrees/at the project root - Name directories after the task (not the branch)
- Branch naming: use a type prefix matching your project's
convention (e.g.,
feature/,fix/,release/,experiment/) - Add
.worktrees/to.gitignore(one-time setup) - Remove worktrees after merging — they are temporary
Gotchas
- Same branch twice — Git refuses to check out a branch in two worktrees simultaneously. Use a different branch name or detach HEAD.
- Shared refs — All worktrees share
.git/refs. A tag or remote update in one is visible in all. - Shared stash —
git stashis global. Name stashes:git stash push -m "worktree: description" - Hooks — Git hooks are shared (
.git/hooks). A pre-commit hook runs in whichever worktree triggers it. - IDE state — Open each worktree as a separate project window to avoid conflicts.
- Skipping pre-flight — Agents consistently skip
pre-flight checks when eager to create worktrees. The
guards exist because nested worktrees corrupt state and
unignored
.worktrees/pollutes git status.
Boundaries
- DOES create, list, and remove worktrees
- DOES establish branch naming conventions for worktrees
- DOES demonstrate parallel execution patterns
- Does NOT manage PRs or merges (use create-pr skill)
- Does NOT handle CI/CD or deployment
- Does NOT replace branch workflow — extends it with parallelism
├── references/
SKILL.md | | Raw
Git Worktrees
Worktrees give each parallel task its own filesystem while sharing one repository. Every worktree has a branch; every parallel agent gets its own worktree.
Steps
Pre-flight (mandatory before any worktree creation):
-
Run these two commands and compare output:
git rev-parse --git-dir git rev-parse --git-common-dirIf the outputs differ, you are inside a worktree. Stop immediately and warn: "You are already inside a worktree. Switch to the main checkout first." Do not proceed.
-
Run:
git check-ignore -q .worktreesIf exit code is non-zero, add
.worktrees/to.gitignorebefore proceeding.
Both checks are mandatory. Never skip them — nested worktrees corrupt repository state.
-
Create the worktree — Run:
git worktree add .worktrees/<name> -b <branch-name>Convention: name the directory after the task, prefix the branch by type:
git worktree add .worktrees/fix-auth-bug -b fix/auth-bug git worktree add .worktrees/redesign-nav -b feature/redesign-navIf the branch already exists:
git worktree add .worktrees/<name> <existing-branch> -
Work in the worktree —
cd .worktrees/<name>and operate normally. Run the project's tests after entering to confirm a clean baseline. -
List active worktrees — After creating worktrees, always run:
git worktree listThis confirms the worktrees are set up correctly and shows the full set of active workspaces.
-
Merge results — When work is complete:
- Push the branch and create a PR, or
- From the main checkout:
git merge <branch-name>
-
Remove the worktree — After merging, always run both commands:
git worktree remove .worktrees/<name> git branch -d <branch-name>Both are required —
worktree removedetaches the directory,branch -ddeletes the branch. If the directory was deleted manually, rungit worktree pruneinstead.
Parallel Execution Pattern
For batch operations across multiple tasks, see parallel-execution.md.
Conventions
- Store worktrees in
.worktrees/at the project root - Name directories after the task (not the branch)
- Branch naming: use a type prefix matching your project's
convention (e.g.,
feature/,fix/,release/,experiment/) - Add
.worktrees/to.gitignore(one-time setup) - Remove worktrees after merging — they are temporary
Gotchas
- Same branch twice — Git refuses to check out a branch in two worktrees simultaneously. Use a different branch name or detach HEAD.
- Shared refs — All worktrees share
.git/refs. A tag or remote update in one is visible in all. - Shared stash —
git stashis global. Name stashes:git stash push -m "worktree: description" - Hooks — Git hooks are shared (
.git/hooks). A pre-commit hook runs in whichever worktree triggers it. - IDE state — Open each worktree as a separate project window to avoid conflicts.
- Skipping pre-flight — Agents consistently skip
pre-flight checks when eager to create worktrees. The
guards exist because nested worktrees corrupt state and
unignored
.worktrees/pollutes git status.
Boundaries
- DOES create, list, and remove worktrees
- DOES establish branch naming conventions for worktrees
- DOES demonstrate parallel execution patterns
- Does NOT manage PRs or merges (use create-pr skill)
- Does NOT handle CI/CD or deployment
- Does NOT replace branch workflow — extends it with parallelism
references/parallel-execution.md | | Raw
Parallel Execution Pattern
Run batch operations across multiple tasks using one worktree per task.
Example: Eval All Skills
# Create one worktree per task
git worktree add .worktrees/eval-skill-a -b eval/skill-a
git worktree add .worktrees/eval-skill-b -b eval/skill-b
git worktree add .worktrees/eval-skill-c -b eval/skill-c
# Run tasks in parallel (each in its own directory)
cd .worktrees/eval-skill-a && tessl eval run skills/skill-a/ &
cd .worktrees/eval-skill-b && tessl eval run skills/skill-b/ &
cd .worktrees/eval-skill-c && tessl eval run skills/skill-c/ &
wait
# Merge results back
git merge eval/skill-a eval/skill-b eval/skill-c
# Cleanup
git worktree remove .worktrees/eval-skill-a
git worktree remove .worktrees/eval-skill-b
git worktree remove .worktrees/eval-skill-c
git branch -d eval/skill-a eval/skill-b eval/skill-c
Multi-Agent Pattern
When delegating to multiple agents:
- Create a worktree per agent before spawning
- Each agent operates in its own
.worktrees/<task>/ - Agents commit independently on their branches
- Coordinator merges results from the main checkout
git-worktree manages parallel git workspaces for simultaneous multi-branch development.
Why the skill runs pre-flight checks for nested worktrees
Creating a worktree inside another worktree corrupts git state silently. Recovery requires manual cleanup. The pre-flight check prevents an irreversible mistake.
Why directory names and branch names are separate
Directory is named for the task (what you're doing). Branch is named by type convention (why it exists). This separation makes worktree lists readable while keeping branch conventions consistent.
Why cleanup requires both worktree remove and branch delete
git worktree remove leaves the branch behind.
Orphan branches accumulate and pollute git branch
output. Explicit cleanup of both prevents drift.
Why the skill warns about shared stash
Git stash is global across all worktrees. Stashing in one worktree then popping in another causes silent data mixing. Named stash convention makes this footgun visible.
[1.0.1] - 2026-06-11
Added
- RATIONALE.md explaining design decisions
[1.0.0] - 2026-05-24
Added
- Initial release of git-worktree skill
- Create, list, and remove git worktrees for parallel workspaces
- Pre-flight checks to prevent nested worktrees and ensure
.worktrees/is gitignored - Branch naming conventions for worktree branches
- Parallel execution pattern for batch operations
- Gotchas section covering shared refs, stash, hooks, and IDE state