Wink Pings

Claude Code Introduces Git Worktree Support: AI Agents Finally Stop Fighting

Anthropic has added native git worktree support to Claude Code, allowing multiple AI agents to work in parallel without interfering with each other. Each agent gets its own independent worktree, completely resolving file lock conflicts.

![Command line interface screenshot showing claude --worktree command](https://wink.run/image?url=https%3A%2F%2Fpbs.twimg.com%2Fmedia%2FHBpEqFFaUAA26OK%3Fformat%3Dpng%26name%3Dlarge)

Developer Boris Cherny announced this feature in the latest release of Claude Code 2.1.50. "Agents can now run in parallel without interfering with each other," he wrote in a tweet, "Each agent gets its own worktree and can work independently."

## Solving a Classic Problem

For developers familiar with git workflows, this sounds natural. The git worktree feature has existed since 2015, allowing developers to handle multiple branches simultaneously within the same repository. However, AI agents previously faced an awkward issue: they would fight over the same working directory, leading to `index.lock` conflicts.

A user in the replies pointed out precisely: "Git worktrees solved the problem of concurrent feature development for humans back in 2015. Now agents can follow the same pattern instead of fighting over index.lock."

## Practical Use Cases

![Screenshot of code migration task table](https://wink.run/image?url=https%3A%2F%2Fpbs.twimg.com%2Fmedia%2FHBpFHCebcAEgsZM%3Fformat%3Dpng%26name%3Dlarge)

This feature is particularly useful for large batch changes and code migrations. Developers can ask Claude to start multiple agents using worktree isolation. For example, when migrating all synchronous I/O to asynchronous, you can batch process changes, launch 10 parallel agents, each agent tests its own changes, and then submits a PR.

Custom agents can also be configured to always run in their own worktree by adding `isolation: worktree` to the preamble.

## Non-Git Users Can Also Benefit

![Screenshot of non-Git version control configuration](https://wink.run/image?url=https%3A%2F%2Fpbs.twimg.com%2Fmedia%2FHBpC7HzbYAET0-f%3Fformat%3Djpg%26name%3Dlarge)

For Mercurial, Perforce, or SVN users, worktree hooks can be defined to gain isolation benefits without using Git. This demonstrates Anthropic's consideration for tool compatibility.

## Technical Details

Worktree support has been integrated into the CLI, desktop app, IDE extensions, web version, and Claude Code mobile app. In the command line, use `claude --worktree` to enable it.

A user asked about best practices for the number of parallel agents: "What is the sweet spot for the number of parallel agents before context thrashing starts?" Boris Cherny's reply was direct: "I've used hundreds in parallel with great results."

## Workflow

For developers unfamiliar with worktree, the process is roughly as follows: after an agent completes its work, its changes are "merged" into the main branch, and the worktree is then deleted. Other agents will handle potential merge conflicts.

This pattern makes it possible to build agent teams, where each agent has its own worktree, and eventually their work converges.

## The Bigger Picture

This update is part of the rapid iteration of Claude Code. As another user observed: "That's because Claude Code is using Claude Code to develop Claude Code."

It is always impressive when tools start to show signs of self-improvement. When AI development tools can solve the pain points in their own development, we may be approaching an inflection point.

Update to version 2.1.50 to experience this feature. For teams long limited by single-agent workflows, this could be a game-changing update.

发布时间: 2026-02-21 13:12