●WWDC — WWDC 2026 confirms Siri runs on Google Gemini; third-party handoff to ChatGPT is dropped, and Siri AI won't ship in the EU under the DMA at iOS 27●BILLING — 6 days until the Jun 15 change: Agent SDK, headless Claude Code, GitHub Actions, and third-party agents move to API-rate monthly credit●OUTAGE — claude.ai, Claude Code, and Cowork saw an outage (Jun). Scheduled runs are safest when built around fallbackModel and retries●DYNAMIC-WORKFLOWS — Dynamic workflows are on by default on Max/Team and the API, for codebase-wide bug hunts and independent verification●ULTRACODE — Claude Code's new ultracode setting sits in the effort menu, fixing effort to xhigh while Claude decides when to run a workflow●OPUS4.8 — Claude Opus 4.8 is settled in as the default across major plans, with stronger coding, agentic, and reasoning skills●WWDC — WWDC 2026 confirms Siri runs on Google Gemini; third-party handoff to ChatGPT is dropped, and Siri AI won't ship in the EU under the DMA at iOS 27●BILLING — 6 days until the Jun 15 change: Agent SDK, headless Claude Code, GitHub Actions, and third-party agents move to API-rate monthly credit●OUTAGE — claude.ai, Claude Code, and Cowork saw an outage (Jun). Scheduled runs are safest when built around fallbackModel and retries●DYNAMIC-WORKFLOWS — Dynamic workflows are on by default on Max/Team and the API, for codebase-wide bug hunts and independent verification●ULTRACODE — Claude Code's new ultracode setting sits in the effort menu, fixing effort to xhigh while Claude decides when to run a workflow●OPUS4.8 — Claude Opus 4.8 is settled in as the default across major plans, with stronger coding, agentic, and reasoning skills
to Parallel Development with Claude Code Worktrees
A practical guide to parallel development using Claude Code's worktree feature. Learn how to run multiple tasks simultaneously, isolate branches for safe development, and build powerful workflows step by step.
Modern development teams face a consistent challenge: managing multiple concurrent tasks in a single repository without context switching overhead. Claude Code combined with Git worktrees provides an elegant solution. This comprehensive guide walks you through implementing parallel development workflows that maximize team productivity while maintaining code safety and isolation.
(Masaki Hirokawa here — a contemporary artist and indie developer who has been running mobile apps with 50M+ downloads at Dolice since 2014.)
Setup and context: Why Parallel Development Matters
Traditional Git workflows follow a linear model: create branch → develop → await review → merge. While this works for sequential tasks, real-world project management demands parallel execution:
Production hotfixes occur while feature development is in progress
Code review processes create natural waiting periods for context switching
Multiple team members work on different features simultaneously
The cost of context switching in traditional workflows is substantial. Each branch switch requires:
Full working directory reconstruction
Build cache invalidation
Tool state reinitialization
Mental context reload
Git worktrees eliminate these inefficiencies by maintaining multiple independent working trees simultaneously, allowing near-zero-cost context switching.
Understanding Git Worktree Fundamentals
What Is a Worktree?
A Git worktree enables managing multiple branches across separate directory trees while sharing a single Git repository metadata (.git directory).
# Traditional workflow (sequential)git checkout maingit checkout feature-Xgit checkout bugfix-Y# Worktree workflow (parallel)git worktree add ../main-work maingit worktree add ../feature-X-work feature-Xgit worktree add ../bugfix-Y-work bugfix-Y# All three directories exist simultaneously
Core Benefits
Physical isolation - Each worktree maintains its own working directory while sharing repository metadata
Zero-cost switching - Change directories instead of checking out branches, preserving editor and build state
True parallelism - Multiple Claude Code sessions operate independently
Performance - Individual worktrees enable faster git operations on large repositories
Worktree and Branch Constraints
Critical limitation: One branch cannot be checked out in multiple worktrees simultaneously. This preserves Git state consistency.
# Invalid: same branch in two worktreesgit worktree add work1 maingit worktree add work2 main # Error: branch 'main' already checked out# Valid: create new branch for second worktreegit worktree add work1 maingit worktree add work2 -b feature/new-task
✦
Thank you for reading this far.
Continue Reading
What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.
WHAT YOU'LL LEARN
✦Step-by-step setup for parallel development using worktrees with practical command reference
✦How to run multiple Claude Code sessions simultaneously for maximum productivity
✦Advanced branch isolation techniques and troubleshooting for complex workflows
# Run test suitenpm test# Build verificationnpm run build# Type checkingnpx tsc --noEmit# Lintingnpm run lint# Review commitsgit log --oneline main..feature/user-dashboard
PR Preparation
# Optionally clean up commitsgit rebase -i main# Final status checkgit status# Push to remotegit push origin feature/user-dashboard
Create PR via GitHub UI while other worktrees continue work.
Concurrent Bug Fixes and Feature Development
Multiple worktrees shine when production incidents occur mid-feature-development.
Scenario Management
In progress - Feature development in feature-dashboard-work
Incident - Production login timeout error reported
Response - Parallel bug investigation and fix
Creating Emergency Fix Worktree
From a new terminal, without interrupting feature development:
cd ~/my-project# Create hotfix branch from current maingit fetch origin maingit checkout maingit pull origin maingit checkout -b hotfix/login-timeout# Create isolated worktreegit worktree add hotfix-work hotfix/login-timeoutcd hotfix-work# Initiate investigationclaude --worktree=. \ --context="Fix production authentication timeout - Error: 'Request timeout after 30s' - Frequency: Multiple regions simultaneously - Hypothesis: Auth API rate limiting exceeded - Solution approach: Timeout value tuning and connection pool optimization"
Git maintains complete separation across all three worktrees.
Merge and Cleanup
Once hotfix is complete and merged to main:
# Test hotfix thoroughlycd hotfix-worknpm testnpm run build# Push for PR reviewgit push origin hotfix/login-timeout# After merge on GitHub...# Remove worktreecd ~/my-projectgit worktree remove hotfix-work# Clean up local branch referencegit branch -d hotfix/login-timeout
Advanced: Agent Mode with Worktrees
Claude Code's agent mode combines with worktrees for powerful autonomous development:
CI/CD pipelines benefit significantly from worktree parallelization:
GitHub Actions Example
name: Parallel Testing with Worktreeson: [push, pull_request]jobs: test-matrix: runs-on: ubuntu-latest strategy: matrix: suite: [unit, integration, e2e] steps: - uses: actions/checkout@v3 - name: Create worktree for ${{ matrix.suite }} run: | git worktree add test-${{ matrix.suite }} ${{ github.ref }} cd test-${{ matrix.suite }} - name: Install dependencies run: | cd test-${{ matrix.suite }} npm ci - name: Run ${{ matrix.suite }} tests run: | cd test-${{ matrix.suite }} npm run test:${{ matrix.suite }}
This configuration executes unit, integration, and E2E tests in parallel, significantly reducing total CI time.
A Note from an Indie Developer
Key Takeaways
Git worktrees combined with Claude Code represent a paradigm shift in development efficiency. The ability to maintain multiple independent task contexts without context-switching overhead fundamentally changes how teams approach parallel development.
While the learning curve exists, the productivity gains—especially for teams managing concurrent features, bug fixes, and releases—justify the investment immediately. Teams embracing this workflow typically report 30-40% reductions in development cycle time and significantly improved code quality due to fewer interrupted contexts.
Start with your most time-critical parallel scenario and expand from there. The patterns and commands provided in this guide form a complete reference for implementing worktree-based workflows in any project.
Part 1: Worktrees from Basics to Advanced Patterns
1.1 Understanding Worktrees
Git worktrees let you maintain multiple working directories for a single repository simultaneously. Traditional branch switching (git checkout) swaps context in the same directory. Worktrees, by contrast, create physically separate directories, each with its own independent workspace.
Generates .claude-code-context.md in the new worktree
Initializes independent environment configuration
Critical Configuration: Each worktree has an independent CLAUDE.md scope. Development guidelines defined in the parent worktree don't automatically apply to children. In large projects, careful management of worktree-specific scope files is key to maintaining quality consistency.
1.3 Worktree Lifecycle Management
Worktrees follow a clear lifecycle from creation to destruction:
Important: The --force flag during deletion can lose unsaved changes. Always verify with git worktree list before removing.
Part 2: Sub-Agent Architecture
2.1 Claude Code's Multi-Agent Design
Claude Code can spin up a maximum of 7 parallel agents. Each agent runs on its own execution thread, sharing CPU/memory resources while working on different worktrees independently.
Explicitly declaring dependencies allows Claude Code to automatically compute the optimal execution sequence. This maximizes parallelism even in projects with limited agent count.
Part 4: Implementation Patterns and Operations
4.1 Fan-Out/Aggregation Pattern
The most effective parallel pattern for large projects is fan-out/aggregation.
Flow:
Parent agent distributes multiple independent tasks to child agents (fan-out)
Each child agent processes independently
Parent agent collects and integrates all results (aggregation)
// Example: simultaneous module developmentasync function fanOutAggregation() { const features = [ { name: "auth", branch: "feature/auth" }, { name: "payment", branch: "feature/payment" }, { name: "notification", branch: "feature/notification" }, ]; // Fan-out: launch all modules concurrently const agents = features.map(f => spawnAgent({ worktree: f.branch, task: `Complete implementation of ${f.name} module`, }) ); // Aggregation: wait for all results const results = await Promise.all( agents.map(a => a.waitForCompletion()) ); // Integration processing for (const result of results) { if (!result.success) { console.error(`${result.feature} failed`); // recovery logic... } } return results;}
4.2 Pipeline Pattern
When dependencies are strong, the pipeline pattern is effective. Output from one stage becomes input to the next.
Each agent progresses independently. Task management system auto-handles dependencies.
Day 1 Afternoon: Integration Testing Phase
After all sub-tasks complete, parent runs integration tests
Auto-resolve merge conflicts
Execute end-to-end tests
Day 1 Evening: QA Phase
Identify areas needing additional testing
If fixes needed, run additional implementation in relevant worktree
Final code quality check
Day 2 Morning: Deployment
Merge to main branch
Auto-deploy to staging
Promote to production (as needed)
Part 5: Advanced Techniques and Optimization
5.1 CLAUDE.md Scope Management
In large parallel projects, each worktree may need different development guidelines. The parent's CLAUDE.md is inherited by children, but worktree-specific scopes enable more precise instructions.
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.