{"version":"2.1.290","anchor":"worktree-guard-now-distinguishes-a-different-worktree","canonical_anchor":"worktree-guard-now-distinguishes-a-different-worktree","heading":"Clearer error when a session writes into a different worktree","tier":"notice","area":"Worktrees","scope":"individual","heads_up":false,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.290\/e\/worktree-guard-now-distinguishes-a-different-worktree","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.290","markdown":"### Clearer error when a session writes into a different worktree\n\nWhen an isolated session tries to write into another worktree, Claude Code now says so instead of calling it the shared checkout\n\n**Unclear.** It is not clear whether there are other conditions that turn the guard on or off.\n\n**What**\n\nA worktree is a separate working copy of a git repository, so several tasks can work on the same project without touching each other's files. Claude Code can keep a background session confined to its own worktree, and it blocks writes and shell commands that reach outside it.\n\nBefore, the error always said the path was in the shared main checkout. Now Claude Code tracks which worktree the session belongs to. If the path is in a different worktree, it gives a separate message saying so and points to the copy of the file inside the session's own worktree.\n\nThe guard applies to background sessions, where `CLAUDE_CODE_SESSION_KIND` is `bg`. It is skipped when `CLAUDE_CODE_HOST_WORKTREE` is set.\n\n**Why**\n\nWhen several agents work in several worktrees at once, the old message could point at the wrong place. The new one says which kind of mistake happened, so the agent or you can fix the path.\n\n- Area: Worktrees\n- Tier: You'll notice\n- Useful: 1\/5\n- Signal: 1\/5\n- Scope: individual\n- Heads-up: no"}