Claude Code + GitHub Worktrees: Parallel PR Workflow
This guide shows how to combine Claude Code with GitHub worktrees to run multiple AI agents in parallel, each producing its own PR-ready branch on GitHub.
Why Combine Claude Code with GitHub Worktrees?
Claude Code modifies files as it works. If you run two Claude sessions on the same checkout, they will overwrite each other. Git worktrees give each session its own directory and branch, while sharing the same repository. Add GitHub to the mix and each branch becomes a PR that your team can review independently.
| Without worktrees | With worktrees + GitHub |
|---|---|
| One Claude session at a time | Multiple sessions in parallel |
| Manual branch switching between tasks | Each task in its own directory |
| One PR at a time | Multiple PRs created simultaneously |
Step-by-Step: Claude Code to GitHub PR
Step 1: Launch Claude Code in a Worktree
Use the --worktree flag to start a session in an isolated worktree:
# Start three Claude sessions in separate worktrees
claude --worktree feat/auth
claude --worktree feat/search
claude --worktree fix/perfStep 2: Claude Works in Isolation
Each Claude session edits files, runs tests, and commits in its own worktree. Changes in one session do not affect the others.
Step 3: Push and Create PRs
After each Claude session finishes, push the branch and open a PR:
# From each worktree directory, push and create a PR
cd ../project-feat-auth
git push -u origin feat/auth
gh pr create --base main --title "feat: add OAuth login" --body "Implements OAuth 2.0 flow with Google and GitHub providers."
cd ../project-feat-search
git push -u origin feat/search
gh pr create --base main --title "feat: full-text search" --body "Adds Elasticsearch-backed search to the API."
cd ../project-fix-perf
git push -u origin fix/perf
gh pr create --base main --title "fix: reduce API latency" --body "Optimizes database queries in the hot path."Step 4: Review and Merge on GitHub
Your team reviews each PR independently on GitHub. After merging, clean up the worktrees:
# Clean up after PRs are merged
cd ../project
git worktree remove ../project-feat-auth
git worktree remove ../project-feat-search
git worktree remove ../project-fix-perf
# Pull the merged changes
git pull origin mainAutomation: Launch Parallel Claude Sessions
This script launches multiple Claude worktree sessions in tmux panes. After the sessions finish, you still need to push and create PRs manually (see Steps 3–4 above):
#!/bin/bash
# launch-claude-sessions.sh — start 3 Claude agents in parallel worktrees
TASKS=("feat/auth" "feat/search" "fix/perf")
SESSION="claude-work"
tmux new-session -d -s $SESSION
for i in "${!TASKS[@]}"; do
TASK=${TASKS[$i]}
if [ $i -gt 0 ]; then
tmux split-window -t $SESSION
tmux select-layout -t $SESSION tiled
fi
tmux send-keys -t $SESSION "claude --worktree $TASK" Enter
done
tmux attach-session -t $SESSION
# After sessions complete, push branches and create PRs:
# cd ../project-feat-auth && git push -u origin feat/auth
# gh pr create --base main --title "feat: auth"GitHub Actions: CI for Claude-Generated PRs
PRs created by Claude Code trigger GitHub Actions just like any other PR. No special configuration is needed. Your CI pipeline runs tests, linting, and builds on each branch independently.
If you want to label or tag Claude-generated PRs, add a label in the gh pr create command:
gh pr create --base main --title "feat: auth" --label "ai-generated" --body "Generated by Claude Code with worktree isolation."Summary
Claude Code + GitHub worktrees is a multiplier for development velocity. Each Claude session works in an isolated worktree, produces commits on its own branch, and the branch becomes a PR on GitHub. Your team reviews and merges independently, and CI validates each branch automatically.