Claude Code Parallel Sessions: How to Run Multiple Agents at Once
Claude Code Parallel Sessions: How to Run Multiple Agents at Once
Running a single Claude Code session is powerful. Running multiple sessions in parallel is how you actually ship fast. You can have one agent refactoring your API layer while another writes tests and a third updates documentation. But without proper isolation, parallel sessions turn into a mess of merge conflicts and corrupted state.
This guide covers the practical patterns for running Claude Code parallel sessions safely, from simple tmux splits to full git worktree isolation.
Why Parallel Sessions Matter
A single Claude Code session processes one task at a time. Even with fast models, complex tasks take minutes. If you have three independent changes to make, running them sequentially means waiting 15+ minutes. Running them in parallel brings that down to 5 minutes.
The key insight: most coding tasks are independent. Adding a new API endpoint does not conflict with fixing a CSS bug in the settings page. Writing unit tests for module A does not touch module B. Parallel sessions exploit this natural independence.
The Three Approaches to Parallel Sessions
| Approach | Isolation Level | Setup Complexity | Best For | |---|---|---|---| | Multiple terminals, same directory | None | Trivial | Read-only tasks, research, code review | | Tmux + separate branches | Branch-level | Low | Small, non-overlapping changes | | Git worktrees | Full filesystem | Medium | Any parallel editing, especially overlapping files |
Approach 1: Multiple Terminals, Same Directory
The simplest option. Open two or more terminal windows, navigate to the same repo, and run claude in each one.
This works for tasks that mostly read code: exploring the codebase, answering architecture questions, reviewing PRs. It falls apart the moment two sessions try to edit the same file. One agent's changes overwrite the other's.
When to use: One session edits while others only read. Never for concurrent writes.
Approach 2: Tmux with Separate Branches
Create a tmux session with multiple panes, each on its own git branch:
# Create branches for each task
git branch feat/api-endpoint
git branch fix/settings-css
git branch test/auth-module
# In tmux pane 1
git checkout feat/api-endpoint && claude
# In tmux pane 2
git checkout fix/settings-css && claude
# In tmux pane 3
git checkout test/auth-module && claude
Each agent commits to its own branch. You merge when all tasks complete. This prevents direct file conflicts during editing but has a limitation: git checkout changes the working directory for the entire repo. If you run this from the same clone, only one branch can be checked out at a time per worktree.
That is where approach 3 comes in.
Approach 3: Git Worktrees (Recommended)
Git worktrees create separate working directories that share the same .git history. Each worktree can have a different branch checked out simultaneously:
# From your main repo
git worktree add ../myproject-api feat/api-endpoint
git worktree add ../myproject-css fix/settings-css
git worktree add ../myproject-tests test/auth-module
# Now run Claude Code in each worktree
cd ../myproject-api && claude
cd ../myproject-css && claude
cd ../myproject-tests && claude
Each agent has its own complete filesystem. No file conflicts. No accidental overwrites. Each agent can build and run tests independently without interfering with the others.
Cleanup After Merging
# After merging branches, remove worktrees
git worktree remove ../myproject-api
git worktree remove ../myproject-css
git worktree remove ../myproject-tests
Architecture: Parallel Session Isolation
Setting Up Tmux for Parallel Claude Code Sessions
A practical tmux configuration for running three parallel sessions:
#!/bin/bash
# parallel-claude.sh - Launch parallel Claude Code sessions
SESSION="claude-parallel"
PROJECT_DIR=$(pwd)
PROJECT_NAME=$(basename "$PROJECT_DIR")
# Create branches
git branch -f task/api-work 2>/dev/null
git branch -f task/test-work 2>/dev/null
git branch -f task/docs-work 2>/dev/null
# Create worktrees
git worktree add "/tmp/${PROJECT_NAME}-api" task/api-work 2>/dev/null
git worktree add "/tmp/${PROJECT_NAME}-tests" task/test-work 2>/dev/null
git worktree add "/tmp/${PROJECT_NAME}-docs" task/docs-work 2>/dev/null
# Create tmux session with three panes
tmux new-session -d -s "$SESSION" -c "/tmp/${PROJECT_NAME}-api"
tmux split-window -h -t "$SESSION" -c "/tmp/${PROJECT_NAME}-tests"
tmux split-window -v -t "$SESSION" -c "/tmp/${PROJECT_NAME}-docs"
# Attach
tmux attach -t "$SESSION"
Common Pitfalls and How to Avoid Them
Build Conflicts
If two worktrees share node_modules via symlinks or hardlinks, one agent running npm install can break the other's build. Solution: each worktree gets its own node_modules. The initial npm install in each worktree takes a few seconds but prevents hours of debugging.
CLAUDE.md Divergence
Each worktree gets its own copy of CLAUDE.md. If one agent updates project instructions, the others do not see the change. This is usually fine since session-specific instructions should not affect other sessions. For shared context, use the ~/.claude/projects/ directory instead.
Port Collisions
Two agents both trying to start a dev server on port 3000 means one fails. Set different ports per worktree:
# In worktree A
PORT=3001 npm run dev
# In worktree B
PORT=3002 npm run dev
Database Migrations
If two agents run conflicting database migrations, you get schema corruption. Rule: only one session handles migrations. Others work with the existing schema or use a separate test database.
Resource Usage: What to Expect
Running multiple Claude Code sessions consumes more API tokens and local resources. Here is what to plan for:
| Sessions | RAM Usage | API Token Burn Rate | Context Windows | |---|---|---|---| | 1 | ~200 MB | 1x baseline | 1 active | | 2 | ~400 MB | 2x baseline | 2 active | | 3 | ~600 MB | 3x baseline | 3 active | | 5+ | ~1 GB+ | 5x+ baseline | 5+ active (monitor costs) |
Token costs scale linearly. Three parallel sessions cost three times as much as one session but finish three times faster. The ROI is clear when your time is worth more than the API cost.
When to Use Parallel Sessions vs. Single Session
Use parallel sessions when:
- You have 3+ independent tasks that do not touch overlapping files
- You are under time pressure and can pay the extra API cost
- Tasks span different parts of the codebase (frontend vs backend vs tests)
Stay with a single session when:
- Tasks depend on each other (task B needs task A's output)
- You are debugging a single complex issue (parallel sessions add confusion)
- The codebase is small enough that one agent finishes quickly anyway
Fazm's Approach to Parallel Agent Execution
Fazm takes the parallel session concept further by handling isolation at the application level. Instead of manual worktree setup, Fazm's agent orchestration layer automatically provisions isolated execution environments for each task. The agent runtime manages filesystem isolation, port allocation, and merge coordination so you focus on describing what needs to happen rather than managing git worktrees by hand.
Each Fazm agent session gets its own sandboxed workspace with controlled access to the filesystem, network, and system resources. When tasks complete, results merge back through a coordinated pipeline that detects and resolves conflicts before they reach your main branch.
Key Takeaways
- Git worktrees are the gold standard for Claude Code parallel sessions because they provide full filesystem isolation
- Tmux makes managing multiple sessions practical from a single terminal
- Always plan for port collisions, build isolation, and migration conflicts before starting parallel work
- Three parallel sessions is the sweet spot for most projects: enough parallelism to save significant time without excessive complexity or cost
- Monitor API token usage since parallel sessions multiply costs linearly