DEV Community

brian austin
brian austin

Posted on

Run Claude Code on multiple tasks simultaneously with git worktrees

Run Claude Code on multiple tasks simultaneously with git worktrees

One of the biggest Claude Code productivity killers is waiting. You ask it to refactor a module, it works for 3 minutes, and you sit there watching tokens burn.

Here's the pattern that fixed this for me: git worktrees + parallel Claude sessions.

The problem with sequential AI sessions

If you're using Claude Code sequentially:

  1. Start task A → wait 3-5 minutes
  2. Task A done → start task B → wait 3-5 minutes
  3. Repeat

You're paying for rate limits AND time. At $100/month Pro Max, hitting quota in 1.5 hours is a real problem (it's a known issue).

The solution: run tasks in parallel so you're not blocked waiting.

git worktrees — the key ingredient

Git worktrees let you check out multiple branches simultaneously in different directories:

# Create worktrees for parallel feature development
git worktree add ../project-feature-auth feature/auth-refactor
git worktree add ../project-feature-tests feature/test-coverage
git worktree add ../project-feature-docs feature/documentation
Enter fullscreen mode Exit fullscreen mode

Now you have three separate working directories, all from the same repo, on different branches.

Start parallel Claude Code sessions

In three terminal tabs (or tmux panes):

# Terminal 1
cd ../project-feature-auth
claude "Refactor the auth module to use JWT properly. Focus only on src/auth/"

# Terminal 2  
cd ../project-feature-tests
claude "Write comprehensive tests for the payment module. Target 80% coverage."

# Terminal 3
cd ../project-feature-docs
claude "Generate API documentation for all public endpoints in src/routes/"
Enter fullscreen mode Exit fullscreen mode

Three tasks running simultaneously. While auth is being refactored, tests are being written, docs are being generated.

The tmux setup for maximum efficiency

#!/bin/bash
# parallel-claude.sh
SESSION="claude-parallel"

tmux new-session -d -s $SESSION -n main

# Create panes
tmux split-window -h -t $SESSION:main
tmux split-window -v -t $SESSION:main.left

# Send commands to each pane
tmux send-keys -t $SESSION:main.left "cd ../project-feature-auth && claude '${1}'" Enter
tmux send-keys -t $SESSION:main.right "cd ../project-feature-tests && claude '${2}'" Enter  
tmux send-keys -t $SESSION:main.bottom "cd ../project-feature-docs && claude '${3}'" Enter

tmux attach -t $SESSION
Enter fullscreen mode Exit fullscreen mode

Usage:

./parallel-claude.sh \
  "Refactor auth to JWT" \
  "Write payment tests" \
  "Document API endpoints"
Enter fullscreen mode Exit fullscreen mode

The rate limit math

Here's why this matters for cost:

Sequential approach:

  • Task A: 3 min active Claude time
  • Task B: 3 min active Claude time
  • Task C: 3 min active Claude time
  • Total: 9 min of quota burned, 9 min of your time

Parallel approach:

  • Tasks A+B+C: 3 min active Claude time (overlapping)
  • Total: Same quota, but only 3 min of your time

You're not saving tokens — you're saving your time while using the same quota budget.

If you're on a rate-limited plan, parallel worktrees mean you hit the same ceiling but get 3x more done before hitting it.

Merging back

When sessions finish:

# Review each worktree's changes
cd ../project-feature-auth && git diff main
cd ../project-feature-tests && git diff main
cd ../project-feature-docs && git diff main

# Merge what looks good
git checkout main
git merge feature/auth-refactor
git merge feature/test-coverage
git merge feature/documentation

# Clean up worktrees
git worktree remove ../project-feature-auth
git worktree remove ../project-feature-tests
git worktree remove ../project-feature-docs
Enter fullscreen mode Exit fullscreen mode

When to use this pattern

Good for:

  • Independent tasks that don't share files
  • Different modules/features
  • Test writing + implementation (separate concerns)
  • Documentation generation

Avoid when:

  • Tasks modify the same files (conflicts)
  • Task B depends on Task A's output
  • You need to review A before starting B

The cost angle

I use SimplyLouie as my Claude API backend — flat ✌️2/month instead of metered billing. With parallel worktrees, I can run 3-4 simultaneous sessions without worrying about per-token costs multiplying.

At $100/month Pro Max with quota exhaustion in 1.5 hours, parallel sessions actually make the quota problem worse. At a flat rate, parallel sessions are just a productivity multiplier.

The worktree pattern itself is free — it's built into git. The constraint is usually your AI subscription model, not the tooling.


Running 3 parallel Claude sessions on a ✌️2/month flat rate feels different than running them on a per-token meter. Try it: simplylouie.com

Top comments (0)