OmniscioGuidesWorktree isolation
Claude Code: command blocked by the worktree isolation checks
The command was refused because this session works in its own git worktree, and the command could leave it. The worktree is doing its job; the fix is to write the command so it plainly stays inside.
Last checked against Anthropic's documentation on November 25, 2026. By the Omniscio team. Updated .
What does the message say?
This session is isolated in the worktree /path/to/worktree, but this command evaluates ${!x@P} arithmetically inside a construct too complex to verify, which can run a command hidden in a variable's value. Refusing to run it — a worktree-isolated session's git operations must target its own worktree. Split it into plain, separate commands and run them from /path/to/worktree.Every refusal opens the same way, names the worktree, then gives the reason and what to do instead. The reason changes with the check that refused it: the working directory resolved to the shared checkout or is in a different worktree, the command pointed git at the main checkout, or Claude Code could not verify from the command's text that the git it runs stays inside the worktree. The example above is the last of those.
Why the command was refused
A session becomes isolated when you start it with --worktree but not --tmux, or when Claude moves it with EnterWorktree. From that moment Claude Code blocks tool calls that leave the worktree, on four checks:
- Command working directory. A Bash, PowerShell or Monitor command whose working directory resolves to the main checkout, or that Claude Code cannot verify stays outside it, is refused.
- Git redirects. A Bash or Monitor command that redirects git into the main checkout is refused. That covers
git -C,--git-dir, aGIT_DIRorGIT_WORK_TREEvariable, and acdinto the main checkout before running git. - Command shape. A Bash or Monitor command is refused when Claude Code cannot verify from the text that any git it runs stays inside the worktree, for example when the command name is computed at runtime or an expansion could run a command the text does not spell out.
- File edits. An
Edit,WriteorNotebookEditaimed at a path in the main checkout is blocked the same way.
The enforcement covers every subagent Claude spawns from the isolated session, and it applies whether the session is interactive or running in the background. It covers the repository you launched Claude Code from and the main checkout a linked worktree is linked from.
Claude sees each refusal as a tool error that names the worktree and says how to proceed, which is why the session usually continues: Claude reads the reason and rewrites the command.
How do I clear it?
- Split the command. Run the pieces as plain, separate commands from inside the worktree, with no variable indirection such as
${!name}and no function substitution such as${ command; }that could hide what runs. - Run git on its own. Drop
-C,--git-dirand anyGIT_DIRorGIT_WORK_TREEthat points at the main checkout, and let the command run from the worktree's directory, or spell out acdinto the worktree before it.
If you meant to work on the main checkout, there are two documented ways out, and either one ends the refusal:
- Run it yourself. Anthropic's error reference says to run the command in a terminal outside the session.
- Leave the worktree. Start a session without
--worktreein the checkout you want, or have Claude leave the worktree withExitWorktreewhere the session has that tool. For a background session,worktree.bgIsolationset to"none"is the documented setting.
One check cannot be turned off: Anthropic says the command-shape check has no switch, because an expansion can produce a command the text never spells out. The other checks end with the isolation itself, which is why leaving the worktree is the fix when the refusal keeps coming back.
PowerShell is narrower than Bash here: for PowerShell commands Claude Code applies only the working-directory check.
How do I know it is fixed?
One refusal followed by a command that works is the expected shape: Claude reads the reason and adapts. These are the checks that confirm the failure has cleared:
- The same command now runs, and the tool result shows its output instead of a refusal.
- Run
git rev-parse --show-toplevelin the session. It should print the worktree's path, not the main checkout's. - New commands that stay inside the worktree run without a refusal.
What does not help
- Asking again with the same command. The checks read the command's text and its working directory, so an unchanged command is refused the same way.
- Restarting the session. A resumed worktree session comes back isolated, so the same checks apply.
- Waiting for an approval prompt. The refusal is the answer, and Claude is told how to rewrite the command rather than what to click.
If a command that never touches git keeps being refused, its working directory or its text is the reason: the message says which. A working directory that resolves to the shared checkout or is in a different worktree is the directory check; otherwise something in the text can produce a command Claude Code cannot verify. Spelling that value out literally is the documented way past it.
Where these answers come from
- Anthropic's error reference, Command blocked by the worktree isolation checks, read November 25, 2026: the message, the three reasons it lists, the note that a command never naming git can still be refused, and what to do about each.
- Anthropic's worktrees page, How Claude Code enforces isolation, read November 25, 2026: when a session becomes isolated, the four checks, the subagent and background coverage, the PowerShell limit, and the note that the command-shape check cannot be turned off.
- Anthropic's worktrees page, Resuming a worktree session: that a resumed session returns isolated, and
ExitWorktree. - Anthropic's worktrees page, Claude has no EnterWorktree tool:
worktree.bgIsolationset to"none"for background sessions.
Common questions
Why did Claude Code refuse my command in a worktree session?
The session is isolated in a git worktree, and one of the command checks refused it: it would run in the main checkout or another worktree, it points git at the main checkout, or Claude Code cannot verify from the command text that any git it runs stays inside the worktree. The message names which one, and the fix is usually to rewrite the command so it runs plainly from inside the worktree.
Why was my command refused when it never mentions git?
That can be the command-shape check. Anthropic says a command that never names git can still be refused, because an expansion such as ${!name} or a function substitution such as ${ command; } produces a value at runtime that can itself be a command. Split it into plain, separate commands and run them from the worktree.
Can I turn the worktree isolation checks off?
Not the command-shape check: Anthropic says you cannot turn it off. Isolation itself ends when the session stops being a worktree session, so start the session without --worktree in the checkout you want to work in, or have Claude leave the worktree with ExitWorktree where the session has that tool. For background sessions, worktree.bgIsolation set to "none" is the documented setting.
Which commands do the checks not cover?
None of the checks tracks which files a shell command writes. A command such as cp or a shell redirect that writes into the main checkout without running git there is not refused by them; Claude Code treats it like any other shell command under your permissions and sandboxing settings.