using-git-worktrees
БесплатноЗапускает вложенные скриптыНе проверенThis skill MUST be invoked when the user says "create worktree", "isolated workspace", "parallel branch work", "git worktree", "feature isolation", or "branch…
от deepeshBodh★ 41 звезда на GitHubОб этом скилле
Using Git Worktrees
Overview
Create isolated workspaces sharing the same repository for parallel branch work. Follow systematic directory selection and safety verification to ensure reliable isolation.
Violating the letter of the rules is violating the spirit of the rules. Skipping safety verification "just this once" or assuming directory locations are the most common causes of worktree problems.
When to Use
- Starting feature work requiring isolation from current workspace
- Working on multiple branches simultaneously
- Executing implementation plans in a clean environment (OPTIONAL: pairs with
humaninloop:plan) - Testing changes without affecting the main working directory
- Parallel code review while continuing development
When NOT to Use
- Single-branch workflows: No need for isolation when working linearly
- Quick fixes on current branch: Worktrees add overhead for simple changes
- Non-git repositories: Worktrees are git-specific
- Temporary experiments: A simple branch may suffice
- When disk space is constrained: Each worktree duplicates working files
Red Flags - STOP and Restart Properly
If any of these thoughts arise, STOP immediately:
- "The directory is probably already ignored"
- "I know where worktrees go in this project"
- "Tests are slow, I'll skip baseline verification"
- "This is a simple project, safety checks are overkill"
- "User wants to start quickly, I'll verify later"
- "I've done this before, I can skip the priority order"
All of these mean: Rationalization is occurring. Restart with proper process.
Common Rationalizations
| Excuse | Reality |
|---|---|
| "Directory is probably ignored" | Probably =/= verified. One git check-ignore command takes seconds. Always verify. |
| "I know where worktrees go here" | Knowledge =/= following process. Check existing directories, then CLAUDE.md, then ask. |
| "Tests are slow" | Slow tests =/= skip tests. Baseline verification prevents hours of debugging wrong baseline. |
| "Simple project" | Simple projects have caused the biggest worktree pollution. Process exists because of them. |
| "Will verify later" | Later rarely comes. Worktree contents in git history are permanent mistakes. Do it now. |
| "User seems impatient" | Impatience is not permission. Explain why verification matters. |
Core Process
Step 1: Directory Selection
Follow this priority order strictly:
1.1 Check Existing Directories
# Check in priority order
ls -d .worktrees 2>/dev/null # Preferred (hidden)
ls -d worktrees 2>/dev/null # Alternative
If found, use that directory. If both exist, .worktrees takes precedence.
1.2 Check CLAUDE.md Configuration
grep -i "worktree.*director" CLAUDE.md 2>/dev/null
If a preference is specified, use it without asking.
1.3 Ask User
Only when no directory exists AND no CLAUDE.md preference:
No worktree directory found. Where should worktrees be created?
1. .worktrees/ (project-local, hidden)
2. ~/worktrees/<project-name>/ (global location)
Which is preferred?
No exceptions:
- Not for "obvious" projects
- Not for "standard" setups
- Not when "everyone uses .worktrees"
- Not even if user says "just use the usual place"
Step 2: Safety Verification
For project-local directories (.worktrees or worktrees):
MUST verify directory is ignored before creating worktree:
# Verify directory is ignored (respects local, global, and system gitignore)
git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null
If NOT ignored:
- Add appropriate line to
.gitignore - Commit the change:
git add .gitignore && git commit -m "chore: add worktree directory to gitignore" - Proceed with worktree creation
Why critical: Prevents accidentally committing worktree contents to repository. Worktree contents in git history cannot be fully removed without history rewriting.
For global directories (e.g., ~/worktrees):
No gitignore verification needed - outside project entirely.
No exceptions:
- Not for "I'm pretty sure it's already ignored"
- Not for "this repo has good gitignore defaults"
- Not when "I'll check after creating the worktree"
- Not even for "the user said don't worry about it"
Step 3: Create Worktree
# Get project name
project=$(basename "$(git rev-parse --show-toplevel)")
# Determine full path based on location type
# For project-local:
path=".worktrees/$BRANCH_NAME"
# For global:
path="$HOME/worktrees/$project/$BRANCH_NAME"
# Create worktree with new branch
git worktree add "$path" -b "$BRANCH_NAME"
cd "$path"
Step 4: Run Project Setup
Auto-detect and run appropriate setup commands:
| File | Setup Command |
|---|---|
package.json |
npm install or yarn install or pnpm install |
Cargo.toml |
cargo build |
requirements.txt |
pip install -r requirements.txt |
| `pyproject.to |
Установить using-git-worktrees в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл using-git-worktrees?
This skill MUST be invoked when the user says "create worktree", "isolated workspace", "parallel branch work", "git worktree", "feature isolation", or "branch workspace". SHOULD also invoke when starting feature work that needs isolation from current workspace.
Как установить скилл using-git-worktrees?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл using-git-worktrees запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic