Git worktrees are not an isolation boundary for coding agents
1–10 of 43 posts
Re: Git worktrees are not an isolation boundary for coding agents
#2Re: Git worktrees are not an isolation boundary for coding agents
#3An agent in a worktree can reach your hooks, your config, another worktree's stash. Probably not a common problem. But when it does happen you're not debugging your code, you're debugging git, and it's not obvious where to even start looking.
The one that actually bothers me is prompt injection. The agent reads an issue, or a dependency's README, or a web page, and what it's told to do is drop a file in the .git it can already write to. Next time you commit, that runs on your machine as you.
Separate thing - worktrees just get annoying to manage. Can't check out the same branch twice, so you're making up branch names to keep git happy. Every one is another directory to keep track of. Then something goes stale and you're back in git worktree prune.
So has any of it got to you? Or do you hit the annoying parts, shrug, and carry on?
Re: Git worktrees are not an isolation boundary for coding agents
#4I haven’t hit these issues when using worktrees. But what’s a pain is having to compile from scratch every time, and not carrying over gitignored files.
Re: Git worktrees are not an isolation boundary for coding agents
#5Worktrees are the obvious pick, and I get why. One command, cheap, and if you're the only one driving, then sharing .git is the point rather than a compromise. I started there too. An agent in a worktree can reach your hooks, your config, another worktree's stash. Probably not a common problem. But when it does happen you're not debugging your code, you're debugging git, and it's not obvious where to even start looki…
Re: Git worktrees are not an isolation boundary for coding agents
#6I haven’t hit these issues when using worktrees. But what’s a pain is having to compile from scratch every time, and not carrying over gitignored files.
https://code.claude.com/docs/en/worktrees#copy-gitignored-fi...
Re: Git worktrees are not an isolation boundary for coding agents
#7Re: Git worktrees are not an isolation boundary for coding agents
#8I haven’t hit these issues when using worktrees. But what’s a pain is having to compile from scratch every time, and not carrying over gitignored files.
The only problem I ran into was when Codex or Claude Code were configured to create the worktrees nested into the parent repository.
Then grep would yield results from a worktree and the agent would happily start to work in the wrong worktree.
Re: Git worktrees are not an isolation boundary for coding agents
#9The parallel trees could have different ownership and access privileges, so that the editable working copy does not require the same filesystem access rights as the metadata tree. The git CLI actions would be performed with the more privileged filesystem role, and it would also have to be audited to make sure it treats all the working copy content as untrusted payload.
Re: Git worktrees are not an isolation boundary for coding agents
#10Unless someone is building their harness from scratch like you this is a 30sec configuration and you could just save your list of blocked commands with wildcards in a file, and copy paste from one harness to the other.