CLAUDE LABJP
AGENTS — When you create a Managed Agents session, pass agent_with_overrides to swap the model, system prompt, tools, MCP servers, or skills for that single sessionKEYS — API keys in the Claude Console can now carry an expiration (a preset, a custom duration, or Never), with an email reminder before keys that live 7 days or longer expireMCP — Admins can provision MCP connectors org-wide through their identity provider, starting with Okta, so users get connector access automatically on first loginWORKBENCH — The legacy Workbench at platform.claude.com/workbench retires on August 17, along with the experimental prompt generate, improve, and templatize APIsREVIEW — Claude Code adds a background /code-review so you can keep working while a review runs, with better MCP and Windows path handling alongsideFASTEND — Fast mode for Claude Opus 4.7 is removed today, July 24. Any speed: 'fast' calls need to move over to Opus 4.8AGENTS — When you create a Managed Agents session, pass agent_with_overrides to swap the model, system prompt, tools, MCP servers, or skills for that single sessionKEYS — API keys in the Claude Console can now carry an expiration (a preset, a custom duration, or Never), with an email reminder before keys that live 7 days or longer expireMCP — Admins can provision MCP connectors org-wide through their identity provider, starting with Okta, so users get connector access automatically on first loginWORKBENCH — The legacy Workbench at platform.claude.com/workbench retires on August 17, along with the experimental prompt generate, improve, and templatize APIsREVIEW — Claude Code adds a background /code-review so you can keep working while a review runs, with better MCP and Windows path handling alongsideFASTEND — Fast mode for Claude Opus 4.7 is removed today, July 24. Any speed: 'fast' calls need to move over to Opus 4.8
Articles/Claude Code
Claude Code/2026-03-25Intermediate

Claude Code Worktree — Maximize Productivity with Parallel Development

Master parallel branch development with Claude Code's --worktree flag. Work on multiple features simultaneously without switching overhead.

Claude Code201Git4worktree3Parallel Development2Productivity4

Running four repositories in the same morning window

Running four technical blogs as an indie developer, there are mornings when I want to touch several repositories at once. claudelab, gemilab, antigravitylab, rorklab — each is its own repository, yet I often want to apply similar fixes across them in parallel.

The old way meant switching Git branches, and every switch triggered a rebuild and a wait for dependencies to resolve. Move from a bug fix in one session to a feature in another, and my hands stopped each time.

Since I started using Claude Code's Worktree feature, that waiting has all but disappeared. Each branch lives in its own directory, and separate sessions run side by side. This article gathers what I learned running them in parallel — including where I tripped up.

Understanding Git Worktree

What is Worktree?

Git Worktree lets you create multiple working directories from a single repository, each checking out a different branch independently.

Traditional approach (branch switching):

main ← checkout → feature-A
↓ (time-consuming)
feature-B ← checkout

With Worktree:

main/             ← ~/project-main
feature-A/        ← ~/project-feature-a (independent directory)
feature-B/        ← ~/project-feature-b (independent directory)

Each worktree is isolated, enabling simultaneous work across branches without switching delays.

Key Benefits

  1. Parallel Development: Work on multiple branches simultaneously
  2. Fast Switching: Just change directories (no checkout needed)
  3. Resource Efficiency: Each worktree can maintain independent dependencies
  4. CI/CD Integration: Build and test multiple branches in parallel

Learn it by hand first — git worktree add

Before reaching for Claude Code's convenience flags, run the plain Git command by hand once. Everything that follows makes more sense afterward, and this is the foundation of parallel development.

# Run from the root of the repository that holds main
# Create a worktree for feature/search in a sibling directory
git worktree add ../project-feature-search feature/search
 
# Use -b to create the branch at the same time if it doesn't exist yet
git worktree add -b feature/pagination ../project-feature-pagination

Move into the new directory and launch Claude Code there.

cd ../project-feature-search
claude

Once "open one more Claude Code in a separate directory" feels natural, the flags are just shortcuts. Since this relies only on plain Git, it works reliably in any environment.

The --worktree Flag

Claude Code shipped built-in Worktree support in v2.1.49 (February 2026). The --worktree flag (short form -w) automatically creates a worktree for a given branch and starts the session inside it.

claude --worktree feature/auth-system

This command automatically:

  1. Creates a worktree for feature/auth-system from your current repo
  2. Launches Claude Code in the new directory
  3. Runs code edits and file operations within that worktree

Basic Usage Examples

Example 1: Feature Branch Development

# Create a worktree for feature/user-dashboard
claude --worktree feature/user-dashboard

Example 2: Parallel Bug Fixes

# Fix API timeout issues
claude --worktree hotfix/api-timeout
 
# In a separate terminal, work on pagination
claude --worktree feature/pagination

The desktop app creates a worktree automatically

If you use the Claude Code desktop app instead of the terminal, every new session gets its own worktree automatically — no -w flag needed. Because sessions never touch each other's files, you can build a feature in one and fix a bug in another without collisions.

Managing Worktrees

List Existing Worktrees

git worktree list

Sample output:

/home/dev/project               abc1234 [main]
/home/dev/project-feature-auth  def5678 [feature/auth-system]
/home/dev/project-feature-dash  ghi9012 [feature/user-dashboard]

Remove a Worktree

Once work is complete, remove the worktree:

git worktree remove ../project-feature-auth

If only a stale reference remains, clean it up with:

git worktree prune

Know the auto-cleanup conditions

Worktrees that Claude Code created for subagents and background sessions are removed automatically once they are older than your cleanupPeriodDays setting. But this only happens when there are no uncommitted changes, no untracked files, and no unpushed commits.

That condition is quiet but matters in practice. Leave logs or build output inside a worktree and it counts as untracked, so it falls outside auto-cleanup and old worktrees quietly pile up. Rather than leaning entirely on automation, I recommend taking stock with git worktree list at each stopping point.

Isolation Mode

Claude Code's Worktree supports Isolation Mode, which fully separates environments between worktrees.

What Isolation Mode Provides

Isolation Mode gives each worktree its own independent:

  • node_modules directory
  • .env files
  • Build artifacts (dist/, build/, etc.)
  • Server processes (running on different ports)

Enabling Isolation Mode

claude --worktree feature/payments --isolation

Environment Variable Separation Example

# main worktree
cd ~/project
export API_KEY="prod-key-main"
export PORT=3000
 
# feature/payments worktree
cd ~/project-feature-payments
export API_KEY="dev-key-payments"
export PORT=3001  # Different port

This lets you run multiple development environments at once.

Where I tripped up in parallel — living with disk space

Running four repositories side by side with worktrees, the first wall I hit was disk space.

In Isolation Mode, node_modules is duplicated per worktree. Behind the convenience, the dependency tree grows with every repository. One morning, my automated update run halted with ENOSPC (No space left on device). Tracing it back, a few old worktrees I had forgotten to remove had quietly filled the disk.

So I tightened the workflow:

  • Remove a worktree with git worktree remove the moment it's done. "I'll clean it later" is the entrance to the pile-up.
  • For dependency-heavy repositories, cap how many run in parallel. Don't open them all — only expand the ones you'll touch that morning.
  • Where you rely on auto-cleanup, design around leaving no untracked files (move logs to a separate directory).

The number of parallel sessions isn't "as many as you can spin up" — it's a number you settle with your disk. Once I saw it that way, the stalls stopped.

A first step

Start by running git worktree add once on a repository you already have, and open one more Claude Code in the separate directory. When you feel two sessions advance without touching each other's files, scaling up the parallelism becomes a natural next move.

For me, one branch was all I could handle at first; now I run four repositories in the same morning window. I hope this helps with your own setup — thank you for reading.

Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

Claude Code2026-04-02
Parallel Development with Claude Code Worktrees
A practical look at running parallel tasks with Claude Code and Git worktrees. Learn how to isolate branches into separate directories so context switches stay cheap, with the rough edges I hit while actually running this day to day.
Claude Code2026-03-11
Claude Code Worktree Guide — Safe Parallel Development Techniques
Learn how to use git worktree with Claude Code for safe parallel development. Work on multiple tasks simultaneously without branch switching.
Claude Code2026-07-19
A Committed Symlink That Points Outside the Worktree — Auditing Repos Before You Let AI Spin Up Parallel Trees
Claude Code 2.1.212 fixed a bug where a committed symlink under .claude/worktrees could be followed during worktree creation and write outside the repo. The patch closes the following side. Here is an audit script for the committed side, plus a quarantine workflow.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →