git-worktree
Enables working on multiple branches simultaneously using Git worktrees.
Install
mkdir -p .claude/skills/git-worktree-sealessland && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/17296" && unzip -o skill.zip -d .claude/skills/git-worktree-sealessland && rm skill.zipInstalls to .claude/skills/git-worktree-sealessland
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Use when working in a Git repository that needs multiple branches checked out simultaneously, feature isolation, or branch-per-task workflows.Key capabilities
- →Add a worktree for an existing branch
- →Add a worktree and create a new branch simultaneously
- →Remove a worktree without deleting the branch
- →Prune stale or manually-deleted worktree metadata
- →Lock a worktree to prevent automatic pruning
How it works
The skill manages git worktrees, which allow multiple branches to be checked out simultaneously in different directories. It provides commands to add, remove, prune, and lock worktrees.
Inputs & outputs
When to use git-worktree
- →Working on multiple branches simultaneously
- →Parallel testing and development
- →Isolating feature branches
About this skill
Git Worktree Workflow
Use git worktree when a task requires switching between branches without stashing, running tests on multiple branches, or keeping long-lived feature branches in isolated directories.
When to Use
- A feature branch needs independent build/test state from
main. - Two or more branches must be validated or edited in parallel.
- A rewrite, ADR, or refactor should live in its own checkout until reviewed.
- The workspace uses a branch-status board or per-worktree validation scripts.
Core Commands
# List current worktrees
git worktree list
# Add a worktree for an existing branch
git worktree add /tmp/<repo>-<branch> <branch>
# Add a worktree and create a new branch at the same time
git worktree add -b <new-branch> /tmp/<repo>-<new-branch> <base-branch>
# Remove a worktree (does not delete the branch)
git worktree remove /tmp/<repo>-<branch>
# Remove a worktree even if it has uncommitted changes
git worktree remove --force /tmp/<repo>-<branch>
# Prune stale or manually-deleted worktree metadata
git worktree prune
# Lock a worktree so it is not pruned automatically
git worktree lock /tmp/<repo>-<branch>
# Unlock when it is safe to prune
git worktree unlock /tmp/<repo>-<branch>
Safety Rules
- Never remove a worktree that contains uncommitted work unless the user explicitly confirms it is disposable.
- Keep worktree paths deterministic, e.g.
/tmp/<repo>-<branch>. - A branch can only be checked out in one worktree at a time.
git worktree removeremoves the directory; the branch remains.git branch -d <branch>removes the branch; associated worktrees must be removed first.- Run
git worktree pruneafter manual directory deletion to avoid stale metadata.
Project-Specific Workflow
In this workspace, use the helper script instead of raw git worktree add when possible:
rtk bash scripts/git-worktree.sh create <branch-name>
After creating, removing, or switching worktrees, regenerate the local status board:
rtk python3 scripts/update-branch-status.py fast
Validate the branch inside its worktree:
rtk bash -c "cd /tmp/<repo>-<branch> && bash scripts/validate-workspace.sh"
Cleanup Checklist
Before claiming a worktree task is done:
- The intended branch is checked out in exactly one worktree.
- Unneeded experimental worktrees are removed or explicitly kept.
-
git worktree listmatches the active branch plan. -
BRANCH_STATUS.local.mdis regenerated and reflects current worktrees. - Each active feature worktree passes
scripts/validate-workspace.sh.
Common Patterns
Split a commit out into its own branch + worktree:
# From the branch that still contains the mixed commit
git log --oneline --graph
git rebase --onto <new-base> <last-shared-commit> <current-branch>
git checkout -b <new-branch>
git worktree add /tmp/<repo>-<new-branch> <new-branch>
Move a commit from branch A to a new branch B:
git checkout branch-a
git branch branch-b <commit-to-move>
git rebase --onto branch-a~1 <commit-to-move> branch-a # drop it from A
git worktree add /tmp/<repo>-branch-b branch-b
Clean up a stale feature worktree:
git worktree remove /tmp/<repo>-<branch>
git branch -D <branch> # only if the branch is truly discarded
git worktree prune
rtk python3 scripts/update-branch-status.py fast
When not to use it
- →When a task does not require switching between branches without stashing
- →When not running tests on multiple branches simultaneously
- →When not keeping long-lived feature branches in isolated directories
Limitations
- →A branch can only be checked out in one worktree at a time
- →Removing a worktree does not delete the branch
- →Requires manual pruning after directory deletion to avoid stale metadata
How it compares
This skill enables parallel development and testing by isolating branch environments, which is more efficient than constantly stashing and switching branches in a single working directory.
Compared to similar skills
git-worktree side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| git-worktree (this skill) | 0 | 1mo | Review | Intermediate |
| resolve-conflicts | 81 | 8mo | Review | Intermediate |
| openspec-onboard | 10 | 5mo | Review | Beginner |
| codex-cli-bridge | 9 | 9mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
resolve-conflicts
antinomyhq
Use this skill immediately when the user mentions merge conflicts that need to be resolved. Do not attempt to resolve conflicts directly - invoke this skill first. This skill specializes in providing a structured framework for merging imports, tests, lock files (regeneration), configuration files, and handling deleted-but-modified files with backup and analysis.
openspec-onboard
studyzy
Guided onboarding for OpenSpec - walk through a complete workflow cycle with narration and real codebase work.
codex-cli-bridge
alirezarezvani
Bridge between Claude Code and OpenAI Codex CLI - generates AGENTS.md from CLAUDE.md, provides Codex CLI execution helpers, and enables seamless interoperability between both tools
skill-sync
KyleKing
Syncs Claude Skills with other AI coding tools like Cursor, Copilot, and Codeium by creating cross-references and shared knowledge bases. Invoke when user wants to leverage skills across multiple tools or create unified AI context.
github-workflow-automation
ruvnet
Advanced GitHub Actions workflow automation with AI swarm coordination, intelligent CI/CD pipelines, and comprehensive repository management
git-advanced-workflows
wshobson
Master advanced Git workflows including rebasing, cherry-picking, bisect, worktrees, and reflog to maintain clean history and recover from any situation. Use when managing complex Git histories, collaborating on feature branches, or troubleshooting repository issues.