using-git-worktrees
Uses Git worktrees to maintain multiple working directories simultaneously.
Install
mkdir -p .claude/skills/using-git-worktrees-bashara-aina && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/18782" && unzip -o skill.zip -d .claude/skills/using-git-worktrees-bashara-aina && rm skill.zipInstalls to .claude/skills/using-git-worktrees-bashara-aina
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 git worktrees to work on multiple branches simultaneously. Detects existing worktrees, guards against submodules, and prefers native Claude Code worktree tool over raw git.Key capabilities
- →Detect existing Git worktrees
- →Create new worktrees using `EnterWorktree` tool
- →Exit worktrees, optionally cleaning them up
- →Prune stale worktree references
- →Place worktrees in `.claude/worktrees/`
How it works
The skill manages Git worktrees by detecting existing ones, creating new ones using a native tool, and providing options to exit and clean up worktrees, while guarding against submodule usage.
Inputs & outputs
When to use using-git-worktrees
- →Work on multiple branches
- →Manage development worktrees
- →Cleanup stale branches
About this skill
Detection
Before creating a worktree, check if one already exists:
git worktree list
If a worktree for the target branch already exists, use it instead of creating a new one.
Guard: Submodules
If the repo uses submodules, DO NOT use git worktrees. Submodules in worktrees are fragile and error-prone. Use git stash + git checkout instead.
To check: git submodule status
Priority: Native Tool First
Prefer EnterWorktree tool over raw git worktree add:
EnterWorktree({name: "branch-name"})— creates worktree and switches sessionExitWorktree({action: "keep"|"remove"})— exits and optionally cleans up
Only use raw git worktree add if the native tool is unavailable or insufficient.
Directory Priority
Worktrees should go in .claude/worktrees/ (Claude Code convention).
When using EnterWorktree, the worktree is automatically placed there.
Cleanup
- After merging a worktree branch, remove the worktree:
ExitWorktree({action: "remove"}) - If work is paused and you want to keep it:
ExitWorktree({action: "keep"}) - Prune stale worktree references:
git worktree prune
When not to use it
- →If the repository uses submodules
- →When the native `EnterWorktree` tool is available but raw `git worktree add` is preferred
- →For managing worktrees outside of `.claude/worktrees/`
Limitations
- →Cannot be used with repositories that use submodules
- →Worktrees should go in `.claude/worktrees/`
- →Raw `git worktree add` should only be used if the native tool is unavailable or insufficient
How it compares
This skill prioritizes a native `EnterWorktree` tool for worktree management and enforces specific directory conventions, offering a structured approach over raw Git commands.
Compared to similar skills
using-git-worktrees side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| using-git-worktrees (this skill) | 0 | 1mo | No flags | 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.