Replace git worktrees with local clones for complete agent isolation#153
Merged
that-github-user merged 1 commit intomainfrom Mar 29, 2026
Merged
Replace git worktrees with local clones for complete agent isolation#153that-github-user merged 1 commit intomainfrom
that-github-user merged 1 commit intomainfrom
Conversation
Root cause: agents with Bash access discover the main repo via worktree .git pointer files, then run git worktree commands that destroy other agents' metadata. Locks, backups, gc.auto=0, and prompt constraints all failed because agents are creative at finding the main repo. Fix: use plain git clone instead of git worktree add. Local clones use hardlinks (near-zero extra disk), have fully independent .git directories, and share no metadata with the main repo or other clones. An agent can rm -rf .git, git init, or run any git command without affecting anything outside its own clone. Verified: 3/3 Opus agents on our own repo captured diffs successfully. Zero ENOENT errors. 89% convergence. The getDiff bug is fixed. Research: evaluated --shared (alternates risk), --dissociate (unnecessary overhead), worktree hybrid (complexity). Plain local clone wins on all axes: isolation, speed (0.1s), disk (hardlinks), and simplicity. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
that-github-user
pushed a commit
that referenced
this pull request
Mar 29, 2026
…ments' We switched from worktrees to clones in #153 but the user-facing messages still said 'worktrees'. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace
git worktree addwithgit clone(local, hardlinks) for agent isolation.Root cause: Agents discover the main repo via .git pointer files and run destructive git worktree commands. All mitigations (locks, backups, gc.auto=0, prompt constraints) failed.
Fix: Local clones have fully independent .git directories. No shared metadata. No path to main repo. Near-zero disk overhead via hardlinks.
Verified: 3/3 Opus agents on our own repo captured diffs successfully. Zero ENOENT errors. 89% convergence.
Change type
How to test
Breaking changes
🤖 Generated with Claude Code