Running Parallel Claude Code Agents with Git Worktrees
How to use git worktrees to run multiple Claude Code sessions simultaneously on separate tasks without branch conflicts.
One of the most powerful patterns I have found with Claude Code is running multiple agents in parallel — each working on a different task in the same repository, simultaneously. The secret ingredient is git worktrees.
If you have not used worktrees before, you are about to discover a workflow that will dramatically increase your throughput. Here is the complete guide.
The problem with one agent at a time
By default, you have one checkout of your repository and one Claude Code session working in it. If you want to work on two features at once, you have to either wait for the first to finish or constantly switch branches. Both options are slow.
Worse, if you try to run two Claude Code sessions in the same directory, they will step on each other — editing the same files, creating conflicting changes, generally making a mess. You need isolated working directories that share the same git history.
Enter git worktrees
Git worktrees let you check out multiple branches of the same repository into separate directories, all sharing a single .git database. Each worktree is a fully independent working directory with its own HEAD, index, and working files.
Here is the basic setup:
# You are in your main checkout at ~/projects/myapp
# Create a worktree for a new feature
git worktree add ../myapp-feature-auth feature/auth
# Create another for a bug fix
git worktree add ../myapp-fix-nav fix/nav-regression
# List all worktrees
git worktree list
Now you have three directories, each on a different branch, all sharing the same git history and remote configuration. Changes committed in one worktree are immediately visible to the others (since they share the object database).
Running Claude Code in each worktree
The magic happens when you open a separate Claude Code session in each worktree. Each agent gets its own isolated environment:
# Terminal 1 — working on auth feature
cd ~/projects/myapp-feature-auth
claude
# Terminal 2 — fixing nav regression
cd ~/projects/myapp-fix-nav
claude
# Terminal 3 — main checkout, reviewing PRs
cd ~/projects/myapp
claude
Each Claude Code instance sees only its own branch's files. They can all read, write, run tests, and commit without interfering with each other. You have effectively parallelized your development.
A practical workflow
Here is how I structure a typical parallel session:
- Triage your backlog. Pick 2-3 tasks that are independent — they should not touch the same files. A new feature, a bug fix, and a refactoring task are a good combo.
- Create branches and worktrees. One command per task. I use a naming convention:
../projectname-tasknameso they are easy to identify. - Launch Claude Code sessions. One per worktree. Give each agent a clear, focused prompt describing the task.
- Monitor and guide. Check in on each session periodically. Answer questions, approve file edits, adjust direction. With ShellPod, you can do this from multiple browser tabs.
- Review and merge. As each agent finishes, review the diff, run tests, and create a PR. Since each worktree is on its own branch, merging is clean.
Tips for success
Keep tasks independent. Parallel agents work best when they are not touching the same files. If two agents both need to modify schema.prisma, you will have merge conflicts. Plan your task allocation to minimize overlap.
Use descriptive branch names. When you have three worktrees open, you need to quickly identify which is which. I prefix with the task type: feat/, fix/, refactor/.
Set up shared dependencies first. If all tasks need a new package, install it on main first and create your branches from there. This avoids each agent independently installing packages and creating conflicting lockfile changes.
Clean up when done. Worktrees accumulate if you forget about them. After merging a PR, remove the worktree:
git worktree remove ../myapp-feature-auth
Why this is even better on ShellPod
Running parallel agents locally means multiplying the CPU and memory load on your laptop. Three Claude Code sessions will bring most machines to their knees.
On ShellPod, the agents run on cloud infrastructure with dedicated resources. Your laptop stays cool and responsive while three agents churn through tasks on the server. You can monitor all of them from browser tabs, or even from your phone.
The persistent environment also means you can set up your worktrees in the morning, kick off the agents, and check on them throughout the day. No worrying about your laptop sleeping or sessions dying.
Getting started
You do not need any special tools to try this. If you have Claude Code and git installed, you can create worktrees and run parallel sessions right now. Start with two tasks and see how it feels. Once you experience the productivity boost of parallel agents, you will never go back to single-threaded development.
And if your laptop fans start screaming, well — that is what ShellPod is for.