The Blind Spot Most Developers Have
There is a workflow mistake that almost every developer makes when first working with AI coding agents: they start an agent, wait for it to finish, review the result, merge – and then start the next agent. Serial. One after another. As if time were not a resource.
It feels tidy. It feels controlled. And it wastes most of the productivity potential that AI agents actually offer.
Simon Willison, one of the most prolific AI tooling researchers in the field, described this problem precisely in October 2025: while an agent works on Task A, your machine sits idle, the API connection waits, and the next ticket goes unstarted. In the time one agent spends 10 minutes building a feature, a second agent could already have the next feature half finished. Serial execution does not just halve your output – it thirds it.
The conceptual fix is simple: start multiple agents in parallel. The technical challenge is doing this without the agents getting in each other's way – writing to the same files, clobbering the same branches, generating merge conflicts that cost more time than the parallelism saves.
Git Worktrees solve exactly this problem. And Claude Code has built a native integration for them.
"The question is no longer whether you work with agents. The question is: parallel or serial?"— Joshua Heller, LinkedIn, June 15, 2026
What Are Git Worktrees?
Git Worktrees are an often-overlooked feature of Git, present in the core since version 2.5 (2015) – but experiencing their breakthrough as a productivity tool only with the AI agent wave. The core idea: a single Git repository can have multiple working directories at the same time.
Normally, a repository has exactly one working directory – the folder where you see and edit your files. Everything else lives in the .git database. With worktrees you can "check out" this working directory as many times as you like – each on its own branch, in its own folder on your filesystem. All worktrees share the same .git database.
The Critical Difference from a Fresh Clone
Many developers solve the parallel work problem by cloning the repository multiple times. That works – but it has significant drawbacks:
- Every clone duplicates the entire
.gitdatabase. For large repos (100 MB+) that costs time and disk space. - Commits in Clone A are not visible in Clone B until after a
git fetchandgit pull. - It is easy to lose track of which clone has which state.
- Node modules, Python virtual environments, build artifacts – everything gets duplicated unless carefully configured.
With worktrees, Git creates only a new working directory that points to a branch. The entire object database (commits, blobs, trees) continues to exist exactly once. A new worktree is created in seconds – regardless of whether the repo is 10 MB or 10 GB.
The Three Most Important Worktree Commands
# Create a new worktree (creates branch feature/payment-api and folder ../repo-payment) git worktree add ../repo-payment feature/payment-api # New worktree from an existing remote branch git worktree add ../repo-auth -b feature/auth-refactor origin/main # List all active worktrees git worktree list # Remove a worktree (after merging) git worktree remove ../repo-payment # Prune stale worktree references git worktree prune
The output of git worktree list shows all active directories at a glance:
/home/user/my-project a3f9b21 [main] /home/user/my-project-payment 8c4d032 [feature/payment-api] /home/user/my-project-auth 1e7f994 [feature/auth-refactor] /home/user/my-project-tests 9a2c551 [feature/test-coverage]
The naming schema [repo-name]-[ticket-id] for worktree folders has proven itself in practice: myapp-123, myapp-456. Every developer immediately knows which folder belongs to which ticket – and which AI agent is currently working there.
Claude Code's Native Worktree Support
What turns Git Worktrees from a useful tool into a genuine productivity multiplier is the native integration in Claude Code – Anthropic's CLI for using Claude as a coding agent. Claude Code has two flags built specifically for the parallel worktree workflow:
# Claude Code starts in a new worktree (isolated branch) claude --worktree # Claude Code + tmux: agent runs in a dedicated tmux pane claude --worktree --tmux
What happens when you run claude --worktree? Claude Code:
- Automatically creates a new worktree – with a cleanly generated branch name based on your task description.
- Starts the Claude session in this isolated working directory.
- All changes made by the agent land on this branch, not on
main. - After the task is complete, you can review, adjust, and merge – or discard the worktree.
The --tmux flag adds another layer: each agent gets its own tmux pane in your terminal. You can switch between running agents, observe progress, and intervene if needed – all in a single terminal window.
# Typical parallel workflow: starting 3 agents simultaneously # Terminal 1: Feature A claude --worktree "Implement Payment Integration with Stripe" # Terminal 2: Feature B (start at the same time) claude --worktree "Refactor Auth module to use JWT" # Terminal 3: Tests (start at the same time) claude --worktree "Increase test coverage to 80% for User Service" # Or everything in one tmux session: claude --worktree --tmux "Implement Payment Integration with Stripe"
Git Worktrees do not inherit .env files – these are typically listed in .gitignore. Copy them manually or create a setup script that automatically symlinks .env when creating a worktree.
Architecture Diagram: What Parallel Work Looks Like
The following diagram shows how a central repository is split into multiple worktrees, each with its own agent – and how the results flow back into main:
3 Concrete Use Cases
Scenario 1: Parallel Feature Development
The most obvious scenario – and the most common use case in development teams that work with AI agents in parallel. You have multiple tickets in the sprint: Feature A, Feature B, a bug fix in an unrelated module. Normally a developer would tackle these one after another, or the team would split tasks.
With parallel agents you start all three tasks simultaneously:
# Task 1: Payment Integration (Terminal 1) cd /workspace/my-project claude --worktree "Implement Stripe webhook handler for subscription events. Requirements: - Accept POST /webhooks/stripe - Events: customer.subscription.updated, invoice.payment_failed - Log to webhook_events table - Retry logic on DB failure" # Task 2: Auth Refactoring (Terminal 2, simultaneously) cd /workspace/my-project claude --worktree "Refactor src/auth/ from session cookies to JWT. All existing tests must still pass. New tests for token refresh flow expected." # Task 3: Database Migration (Terminal 3, simultaneously) cd /workspace/my-project claude --worktree "Create DB migration for new user_preferences table. Schema: user_id (FK), key VARCHAR(64), value JSONB, updated_at. Include rollback script."
While you grab a coffee or prepare for the next meeting, all three agents run in parallel. When you return, you have three pull requests ready to review and merge. At an average task runtime of 8–15 minutes, you have waited once for 15 minutes instead of 45 minutes serially.
Important: Tasks must genuinely be independent. Payment integration and auth refactoring touch different modules – that is ideal. If both agents were to work on src/middleware/auth.ts, merge conflicts would be guaranteed.
Scenario 2: Model Comparison – Claude Opus 4.8 vs. Codex vs. GPT-5.5
A particularly powerful scenario: you send the same task to three different models simultaneously and compare the results. This might sound inefficient – but it is not, when you face a complex implementation decision and want to know which approach is best.
Practical example: you need to implement a caching strategy for a high-traffic API. Redis? In-memory LRU? Edge caching? Three models, three approaches – you review the differences and pick the best:
# Create worktrees git worktree add ../project-cache-claude -b experiment/cache-claude git worktree add ../project-cache-codex -b experiment/cache-codex git worktree add ../project-cache-gpt -b experiment/cache-gpt # Start agents (different models, same task) cd ../project-cache-claude && claude --model opus "Implement caching for GET /api/products..." cd ../project-cache-codex && codex "Implement caching for GET /api/products..." cd ../project-cache-gpt && gpt-code "Implement caching for GET /api/products..." # Compare results git diff experiment/cache-claude experiment/cache-codex -- src/cache/ git diff experiment/cache-claude experiment/cache-gpt -- src/cache/
What you will regularly observe: the models choose different abstraction levels. Claude Opus 4.8 tends toward more complete implementations with error handling and tests. Codex often produces more compact code that stays closer to the existing patterns in the repository. GPT-5.5 frequently shines with well-thought-out types and interfaces.
The outcome is not a question of "which model is better" but which approach fits this specific codebase, this team, and these requirements.
The model comparison costs roughly three times as much as a single agent session. It pays off for complex implementation decisions where a wrong approach will be expensive to fix later. For routine tasks like bug fixes or CRUD operations, a single agent is more cost-efficient.
Scenario 3: Scout Mode – Explore Without Commitment
Scout mode is a pattern Simon Willison described in his October 2025 post, and it is extremely valuable in practice: you send an agent into a worktree to answer a question without intending to merge the code.
Typical scout questions:
- "How hard would it be to migrate this module to TypeScript 5.x?"
- "Which tests break if we switch the database connection to connection pooling?"
- "Can our API layer support GraphQL without breaking the REST endpoints?"
# Create scout worktree git worktree add ../project-scout -b scout/typescript-migration # Agent explores – no merge planned cd ../project-scout claude "Try to migrate src/api/ to TypeScript 5.5. Write a summary at the end: - How many files need to change? - What breaking changes are there? - Estimate: how many hours of manual work? You do NOT need to fix everything, just explore and report." # After the scout: read result, then remove worktree cat SCOUT_REPORT.md git worktree remove ../project-scout
The key advantage: the scout agent can and should make mistakes, leave incomplete implementations behind, break tests – that is intentional. The output is not mergeable code but an effort estimate and risk assessment. For planning conversations and sprint estimates, that is invaluable.
Quick-Start Guide: Parallel Workflow in 10 Minutes
Here is the complete step-by-step guide to get started with parallel AI agents on worktrees immediately:
Step 1: Prepare the Repository
# Make sure main is clean git checkout main git pull origin main git status # no uncommitted changes!
Step 2: Create Worktrees
# Pattern: [parent-dir]/[repo]-[ticket-id] git worktree add ../my-project-123 -b feature/TICKET-123 git worktree add ../my-project-124 -b feature/TICKET-124 git worktree add ../my-project-125 -b feature/TICKET-125 # Verify all worktrees git worktree list
Step 3: Copy .env Files
# .env is in .gitignore – copy manually cp my-project/.env ../my-project-123/.env cp my-project/.env ../my-project-124/.env cp my-project/.env ../my-project-125/.env # Optional: script for automatic setup cat > setup-worktree.sh << 'EOF' #!/bin/bash WT_PATH=$1 cp .env "$WT_PATH/.env" echo "Worktree $WT_PATH ready." EOF chmod +x setup-worktree.sh
Step 4: Start Agents in Parallel
# Option A: Separate terminals # Terminal 1: cd ../my-project-123 && claude "TICKET-123: ..." # Terminal 2: cd ../my-project-124 && claude "TICKET-124: ..." # Terminal 3: cd ../my-project-125 && claude "TICKET-125: ..." # Option B: tmux (all in one window) tmux new-session -d -s agents tmux send-keys -t agents "cd ../my-project-123 && claude --worktree 'TICKET-123...'" Enter tmux split-window -h tmux send-keys -t agents "cd ../my-project-124 && claude --worktree 'TICKET-124...'" Enter tmux split-window -v tmux send-keys -t agents "cd ../my-project-125 && claude --worktree 'TICKET-125...'" Enter tmux attach -t agents
Step 5: Review and Merge
# Review diff before merging cd ../my-project-123 git diff main...HEAD # Run tests npm test # Go back to main repo and merge cd my-project git merge feature/TICKET-123 git merge feature/TICKET-124 git merge feature/TICKET-125 # Clean up worktrees git worktree remove ../my-project-123 git worktree remove ../my-project-124 git worktree remove ../my-project-125 git worktree prune
Best Practices and Common Pitfalls
| Situation | DO ✓ | DON'T ✗ |
|---|---|---|
| Task selection | Run independent tasks in parallel (different modules, different features) | Parallelize tasks that touch the same files |
| Worktree naming | [repo]-[ticket-id] – unambiguous, instantly understandable |
Generic names like temp1, test, new |
| .env files | Copy or symlink when creating the worktree | Forget to copy – the agent will have no credentials and fail silently |
| Retries | Max 2 retry attempts per task, then check manually | Let agents loop blindly – API costs spiral out of control |
| Code review | Review every agent output before merging – even for simple tasks | Blind merge without reviewing the diff |
| Dependencies | Update shared libraries in a separate step beforehand | Let different agents upgrade the same dependency simultaneously |
| Cleanup | Remove worktrees immediately after merging (git worktree remove) |
Leave worktrees around for months – they confuse future sessions |
| Number of parallel agents | 3–5 agents as a sweet spot, depending on rate limits | 20+ agents simultaneously – rate limits and API costs spiral |
Databases, ports, and processes cannot be shared between worktrees. If Task 1 starts a dev server on port 3000 and Task 2 does the same, there will be a conflict. Solution: configure different ports per worktree, or only test the final build rather than running live servers.
How This Works with OpenClaw
Teams using OpenClaw as their agent framework get native support for parallel worktree workflows – with considerably more comfort than the manual approach using the Claude Code CLI.
OpenClaw has had a built-in Worktree Dispatcher since version 0.8, which automatically distributes tasks to available worktrees. The core principle:
- Task Queue: You pass multiple tasks to OpenClaw. The dispatcher orders them by dependency and resource contention.
- Automatic Worktree Management: OpenClaw creates worktrees, copies
.envfiles, and configures the correct branch automatically. - Parallelisation: Independent tasks run simultaneously. Dependent tasks wait for their prerequisites.
- Review Dashboard: All results land in a central review interface – you see the diff, can provide feedback, and merge or reject with one click.
- Cleanup: After merging, worktrees are automatically removed and branches cleaned up.
# OpenClaw parallel task queue openclaw dispatch \ --task "TICKET-123: Payment Integration" \ --task "TICKET-124: Auth Refactoring" \ --task "TICKET-125: DB Migration" \ --parallel \ --model claude-opus-4-8 \ --review-before-merge # OpenClaw automatically starts 3 worktrees and shows dashboard > Dispatching 3 tasks to parallel worktrees... > worktree-1 [feature/ticket-123]: RUNNING (Claude Opus 4.8) > worktree-2 [feature/ticket-124]: RUNNING (Claude Opus 4.8) > worktree-3 [feature/ticket-125]: RUNNING (Claude Opus 4.8) > Open dashboard: http://localhost:8080/review
For enterprise teams running OpenClaw on-premises, Clawgency additionally provides a central monitoring system that makes all parallel agent activities visible in real time – including token consumption, runtimes, and an audit log for GDPR compliance.
Clawgency implements OpenClaw for DACH-region enterprises – including parallel worktree workflows, a central review dashboard, GDPR-compliant audit logging, and integration into existing CI/CD pipelines (GitHub Actions, GitLab CI, Azure DevOps). Live in 2–4 weeks.
FAQ: All Questions About Parallel AI Agents with Git Worktrees
Git Worktrees let you check out multiple working directories from a single Git repository – each on its own branch. Unlike a fresh clone, all worktrees share the same .git database, so no space is wasted on duplicate objects and commits are immediately visible across all worktrees. You create them with git worktree add [path] [branch].
Theoretically unlimited – in practice, 3 to 5 parallel agents is a good starting point. Limiting factors are the available API rate limits of the model you are using (Claude Opus 4.8 has higher limits than Haiku), the CPU/RAM of your machine, and the number of independent tasks available. Most teams report that 3 concurrent agents (one per feature ticket) hit the sweet spot between speed and manageability.
Yes. OpenClaw natively supports parallel agent instances on different worktrees. The OpenClaw Dispatcher can automatically distribute tasks to available worktrees, including automatic logging, retry logic, and a central review dashboard. Clawgency implements this workflow for enterprise teams with a GDPR-compliant audit trail.
Best suited are tasks that are independent of each other: different features, independent bug fixes, migration scripts, test suites, documentation updates, or refactoring tasks in different modules. Unsuitable are tasks that work on the same files, occupy the same ports, or depend on shared database locks. The rule of thumb: if two tasks could be conflict-free merged onto main, they can run in parallel.
A fresh clone duplicates the entire .git database – costing time and disk space. Git Worktrees share the same .git database: commits, blobs, and trees exist only once. A new worktree is created in seconds, regardless of repo size. Branches are also immediately visible between worktrees – no fetch or push required.
Yes, worktrees are not deleted automatically. After merging, remove them with git worktree remove [path] and clean up stale references with git worktree prune. OpenClaw handles this cleanup automatically after each merge.
claude --worktree automates the worktree setup: branching, directory creation, and session context are configured automatically. In the manual approach you create the worktree and branch yourself, change into the directory, and start Claude there. Both approaches produce the same result; --worktree is more convenient for ad-hoc tasks, while the manual approach gives you more control over branch names and directory structure.
Ready to develop 3x faster?
Clawgency implements parallel AI agent workflows with OpenClaw for enterprises in Germany, Austria, and Switzerland – GDPR-compliant, integrated into existing CI/CD pipelines, and live within 2 to 4 weeks.
Book a Free Discovery Call →