US

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.zip

Installs 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.
176 charsno explicit “when” trigger
Intermediate

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

You give it
Target branch name for worktree
You get back
New or managed Git worktree

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 session
  • ExitWorktree({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.

SkillInstallsUpdatedSafetyDifficulty
using-git-worktrees (this skill)01moNo flagsIntermediate
resolve-conflicts818moReviewIntermediate
openspec-onboard105moReviewBeginner
codex-cli-bridge99moReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

Search skills

Search the agent skills registry