From dev-workflow
Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification
How this skill is triggered — by the user, by Claude, or both
Slash command
/dev-workflow:using-git-worktreesThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
**One worktree per feature branch to avoid git index conflicts.**
One worktree per feature branch to avoid git index conflicts.
When running multiple implementer agents in parallel or executing implementation plans with isolated workspaces, worktrees prevent git index conflicts and provide clean workspace isolation.
Always use for:
dev-workflow:plan-executionThis prevents:
Git worktrees allow multiple working directories for the same repository:
Verify current state is clean:
# Check if we're in a clean state
git status
# Check if branch name already exists (local or remote)
git branch -a | grep feature-name
Checkpoint: Main repo is clean. Branch name is available.
Create the feature branch:
# Create branch from current HEAD (usually main)
git branch feature-name
Create worktree inside the repo's .worktrees/ directory:
# Internal directory pattern: .worktrees/BRANCH_NAME
# Example: .worktrees/feature-auth
git worktree add .worktrees/feature-auth feature-auth
Directory naming convention:
.worktrees/BRANCH_NAME.worktrees/feature-auth.worktrees/ is in .gitignoreCheckpoint: Worktree created. Directory exists.
Navigate into worktree and verify state:
cd .worktrees/feature-auth
# Confirm branch and clean state
git status
# Verify worktree list (works from any worktree)
git worktree list
Checkpoint: In worktree directory. Branch is correct. State is clean.
Now that worktree is set up, chain to writing-plans:
The worktree is ready. I'll now invoke the writing-plans skill
to create the implementation plan for [feature description].
The implementation plan will execute in this isolated worktree, preventing any conflicts with the main workspace.
When work is merged or PR is created:
# Remove worktree directory and unregister it
git worktree remove .worktrees/feature-auth
# Or if directory was manually deleted:
git worktree prune
# Delete local branch
git branch -d feature-auth
# Delete remote branch if pushed
git push origin --delete feature-auth
Checkpoint: Worktree removed. Branch deleted if merged.
# List remaining worktrees
git worktree list
# Should only show main worktree
# Create worktree for new branch
git worktree add .worktrees/branch-name branch-name
# Create worktree for existing branch
git worktree add .worktrees/existing-branch existing-branch
# Create worktree and new branch from specific commit
git worktree add -b new-branch .worktrees/new-branch abc123
# List all worktrees
git worktree list
# Remove specific worktree
git worktree remove .worktrees/branch-name
# Remove worktree (if already deleted manually)
git worktree prune
# Remove worktree with uncommitted changes (force)
git worktree remove --force .worktrees/branch-name
# Work from inside the worktree directory
cd .worktrees/branch-name
git status
git add .
git commit -m "feat: implement feature"
git push origin branch-name
Note: Prefer working from within the worktree. Use git -C .worktrees/branch-name only as a fallback (e.g., from the lead orchestrator when agents are unavailable).
git status shows cleangit branch -a | grep feature-name is emptygit branch feature-namegit worktree add .worktrees/feature-name feature-namecd .worktrees/feature-name, verify with git statusChains to dev-workflow:writing-plans:
Works with dev-workflow:plan-execution:
Works with dev-workflow:implementer:
❌ Creating worktree when main repo is dirty
❌ Using branch name that already exists
❌ Creating worktrees as sibling directories outside the repo (breaks permission scoping)
❌ Forgetting to verify worktree state after creation
❌ Leaving worktrees around after feature is merged
❌ Using worktree for quick branch switches (just use git switch)
❌ Creating nested worktrees
❌ Forgetting to add .worktrees/ to .gitignore
✅ Main repo state is clean before worktree creation
✅ Branch name is unique (doesn't exist locally or remotely)
✅ Worktree created inside .worktrees/ directory
✅ .worktrees/ is in .gitignore
✅ Worktree list shows both main and new worktree
✅ Implementation plan chains after worktree setup
✅ Cleanup performed after feature merge/completion
SCENARIO: Implementing new authentication feature with parallel agents
Phase 1 - SAFETY CHECKS
$ git status
→ On branch main, working tree clean ✓
$ git branch -a | grep feature-auth
→ No output, branch name available ✓
Phase 2 - CREATE
$ git branch feature-auth
$ git worktree add .worktrees/feature-auth feature-auth
→ Preparing worktree (new branch 'feature-auth')
→ Checking out files: 100% done
$ git worktree list
→ /home/user/project [main]
→ /home/user/project/.worktrees/feature-auth [feature-auth]
Phase 3 - NAVIGATE & VERIFY
$ cd .worktrees/feature-auth
$ git status
→ On branch feature-auth, nothing to commit, working tree clean ✓
Phase 4 - CHAIN TO PLANNING
→ Invoke dev-workflow:writing-plans
→ Create implementation plan for authentication feature
→ Plan executes in isolated worktree directory
→ No conflicts with main workspace
Phase 5 - CLEANUP (after merge)
$ git worktree remove .worktrees/feature-auth
$ git branch -d feature-auth
$ git worktree list
→ /home/user/project [main]
→ Worktree cleaned up ✓
Main repo: /home/user/workspace/my-app
Worktrees (inside .worktrees/):
.worktrees/feature-auth → Authentication feature
.worktrees/fix-login-bug → Bug fix branch
.worktrees/refactor-api → Refactoring work
.worktrees/add-tests → Test additions
Main repo: /home/user/workspace/claude-code-workflows
Worktrees (inside .worktrees/):
.worktrees/context-recovery
.worktrees/pr-merge-improvements
.worktrees/new-skill
# Check where branch exists
git branch -a | grep branch-name
# If local, use different name or delete old branch
git branch -d branch-name
# If remote, fetch and use different name
git fetch origin
# List worktrees
git worktree list
# Remove if stale
git worktree remove .worktrees/branch-name
# Or prune all stale worktrees
git worktree prune
# Check if directory is a worktree
git worktree list | grep branch-name
# If not a worktree, remove or use different name
rm -rf .worktrees/branch-name
# Option 1: Commit or stash changes from within the worktree
cd .worktrees/branch-name
git add .
git commit -m "WIP: save work"
# Option 2: Force remove (loses changes)
git worktree remove --force .worktrees/branch-name
Guides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.
npx claudepluginhub tombakerjr/claude-code-workflows --plugin dev-workflow