Git Worktrees with Claude Code: Parallel Development Without the Chaos

  ·  4 min read

Context switching is expensive. You’re deep into fixing a bug when someone pings you about reviewing a PR. Or you’re midway through a refactor and realize you need to prototype an alternative approach before committing. The usual solution—stashing, branching, unstashing—works, but it’s friction. And friction compounds.

Git worktrees solve this by letting you check out multiple branches simultaneously in separate directories. Each worktree is an independent working copy of your repo, isolated from the others. Combined with Claude Code, this becomes a surprisingly powerful way to run parallel development workflows without the mental overhead of constant branch switching.

Why This Matters for AI-Assisted Development #

Here’s the thing about working with Claude Code: you’re not just juggling your own mental state. You’re also babysitting the AI’s context. Every branch switch is a chance for both of you to lose the thread.

With worktrees, each Claude session gets its own universe:

  • One session refactoring your API, another prototyping a feature, neither confused by the other’s changes
  • Side-by-side comparisons of competing approaches without merge hell
  • Code review in one terminal tab, development in another, zero interference

I’ve been using this workflow for some time now. The difference is tangible. Each AI session stays focused on one task, and I’m not constantly explaining to Claude why half the codebase just disappeared because I switched branches.

The Basic Workflow #

Start by creating a worktree for a new feature:

git worktree add ../myproject-feature-x feature-x

This creates a new directory ../myproject-feature-x with the feature-x branch checked out. Navigate there and launch Claude Code:

cd ../myproject-feature-x
claude

Now you have a dedicated Claude Code session working on that feature branch. Meanwhile, your main project directory remains untouched, potentially running a different Claude session on a different branch.

Want to experiment with an alternative implementation? Create another worktree:

git worktree add ../myproject-feature-x-alt feature-x-alt
cd ../myproject-feature-x-alt
claude

Now you have two Claude sessions working on competing approaches, isolated from each other.

Why This Works #

Isolation prevents interference. Each worktree is completely independent. Claude can refactor your API in one while you prototype a feature in another. No stashing. No branch switching. No explaining to the AI why everything just changed.

Parallelism becomes natural. Multiple terminal tabs, each with its own Claude session, all working simultaneously. Want to prototype three solutions to the same problem? Open three worktrees. Compare side-by-side. Pick the winner.

Code reviews get easier. Check out the PR in a separate worktree. Run tests, explore the code, ask Claude questions about the implementation. Your actual work stays untouched. When you’re done reviewing, delete the worktree. Five seconds of cleanup.

Keeping Worktrees Organized #

You’ll forget which worktree has what. Trust me. Use a naming convention:

# By feature/ticket
git worktree add ../myproject-KH-1234 feature/KH-1234-auth

# By task type
git worktree add ../myproject-bugfix-login bugfix/login-timeout
git worktree add ../myproject-review-pr-456 pr-456-review

Pick something obvious. When you’ve got four terminal tabs open and you’re trying to find the one with the actual fix, you’ll thank yourself.

Cleanup #

Worktrees accumulate. Fast. One for the feature. One for the review. One for that “quick fix” that wasn’t quick.

When you’re done with one, remove it:

git worktree remove ../myproject-feature-x

Already deleted the directory manually? Clean up the metadata:

git worktree prune

Make this a habit. Old worktrees clutter your file system and your mental model of what’s actually active.

What This Isn’t #

If your Git workflow is already a mess, worktrees won’t fix it. They’ll just give you more branches to mismanage. Worktrees amplify whatever you’ve got going. Good workflows get better. Chaos gets more chaotic.

This also isn’t a replacement for feature flags or CI/CD. Worktrees are local. They don’t change how you integrate or deploy. They just make the local part less annoying.

The Real Win #

The benefit isn’t measured in hours saved. It’s measured in mental clarity.

Context switch? Open a different terminal tab. Compare two approaches? Literally look at them side-by-side. Keep Claude focused? The worktree does it automatically.

Git worktrees have been around for years, but they hit different with AI-assisted development. Isolated environments plus focused AI sessions makes context switching feel less like juggling and more like having actual workspaces. Which is what we should’ve had all along.

Simple tools, properly applied, often beat complex ones.