Claude Tips mascot
Claude Tips & Tricks
Claude Code intermediate

Run Parallel Sessions with Git Worktrees

Use git worktrees to run multiple Claude Code instances simultaneously on different tasks without merge conflicts.

Git worktrees let you check out multiple branches into separate directories while sharing the same repository. Combined with Claude Code, you can run completely independent sessions in parallel.

Setup

# Create worktrees for parallel tasks
git worktree add ../my-project-feature-auth origin/main
git worktree add ../my-project-bugfix-api origin/main

# Start Claude in each worktree
cd ../my-project-feature-auth && claude
cd ../my-project-bugfix-api && claude

Each worktree has its own files, branch, and Claude session with its own context window. Claude working on auth in one worktree won’t interfere with Claude fixing an API bug in another.

Power User Setup

Keep 3-5 worktrees running:

  • Main work - your primary feature
  • Bug fixes - quick patches
  • Analysis - a read-only worktree for investigation
  • Experiments - throwaway prototyping

Add shell aliases to hop between them quickly:

alias cw1="cd ../my-project-feature && claude"
alias cw2="cd ../my-project-bugfix && claude"

Subagent Worktrees

You can also delegate to subagents with worktree isolation by asking Claude to “use a subagent in a worktree to refactor the auth module.” The subagent works in its own isolated copy and reports back when done.

Paste into Claude Code
Set up git worktrees for parallel Claude Code sessions. Create worktrees for feature work, bugfixes, and experiments with shell aliases to quickly switch between them.