Running Two Claude Code Agents on the Same Repo with Git Worktrees

Running multiple Claude Code agents on the same repository simultaneously has been achieved using git worktrees. Each agent gets its own branch and dedicated working directory on disk, eliminating file conflicts and allowing reading/writing without interference.
Workflow
- Create a git worktree for each branch.
- Open a separate Claude Code session in each worktree directory.
- Let the agents run in parallel — they are unaware of each other.
- When both finish, merge the branches via normal git merge.
Practical Example
# Create a worktree for a feature branch
git worktree add ../repo-feature feature-branch
# Create a worktree for a bugfix branch
git worktree add ../repo-bugfix bugfix-branch
In each directory, start Claude Code
cd ../repo-feature && claude-code .
cd ../repo-bugfix && claude-code .
Benefits
Speed improvement is real for parallelizable work: one agent fixing a bug while another drafts a new feature, or a refactor alongside test coverage. Not every task splits cleanly, but genuinely independent concerns benefit. User reports having one agent fixing a bug and another drafting a feature simultaneously without conflict.
Considerations
The user asks about reliability for longer-running tasks and whether merge conflicts become a problem at scale. Standard git merge resolution applies when merging worktree branches back.
Who It's For
Developers using Claude Code who want to parallelize independent tasks on the same codebase.
📖 Read the full source: r/ClaudeAI
👀 See Also

Claude Code as a Compiler: A Practical Reframe for AI Development
A Reddit post argues Claude Code functions as a compiler translating English to working software, drawing parallels to historical computing breakthroughs like Grace Hopper's A-0 and FORTRAN. The author describes generating 400 lines across 6 files from a 3-paragraph English description, catching two issues in 25 minutes.

Sentrial: Production Monitoring for AI Agents
Sentrial is a monitoring tool that automatically detects failure patterns in AI products including loops, hallucinations, tool misuse, and user frustrations. It diagnoses root causes by analyzing conversation patterns, model outputs, and tool interactions.

AskFirst API adds human approval layer for AI agents
AskFirst is a REST API that lets AI agents pause for human approval before taking irreversible actions. It works with local models, hosted APIs, and any framework, providing email notifications, approve/deny options, and audit logs.

Autonomous coding workflow ships 163K lines overnight using Claude Code
A developer built an autonomous workflow that completed 72 tasks overnight, generating 163,643 lines of code and 6,400+ passing tests with an 85% first-attempt success rate.