claude-code - 💡(How to fix) Fix [DOCS] Background session docs omit worktree-isolation behavior for spawned subagents

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

C. The worktree.bgIsolation: "none" exception is ambiguous for subagents

RAW_BUFFERClick to expand / collapse

Documentation Type

Missing documentation (feature not documented)

Documentation Location

https://code.claude.com/docs/en/agent-view

Section/Topic

"How file edits are isolated" and the interaction between background sessions and subagents.

Current Documentation

The Agent View page says background sessions isolate file edits before writing:

Every background session, whether started from agent view, /bg, or claude --bg, starts in your working directory. Before editing files, Claude moves the session into an isolated git worktree under .claude/worktrees/, so parallel sessions can read the same checkout but each writes to its own.

It also says backgrounded sessions can start subagents:

Once in the background, the session can start new subagents, monitors, and background commands, and those keep running across later detach and reattach.

The Subagents page documents background subagents, but only covers permission behavior:

Background subagents run concurrently while you continue working. They run with the permissions already granted in the session and auto-deny any tool call that would otherwise prompt.

What's Wrong or Missing?

Claude Code v2.1.154 fixed subagents in background sessions bypassing the worktree-isolation guard and writing to the shared checkout.

The current docs document background-session worktree isolation and subagent background execution separately, but they do not state what happens when those features overlap:

A. Subagent file-write isolation inside background sessions is not explicit

Users can see that a background session should move into an isolated worktree before editing, but the docs do not say that subagents spawned by that background session are also covered by the same guard before they write files.

B. The shared-checkout failure mode is not ruled out

The release fix shows that a background-session subagent could previously bypass the guard and write to the shared checkout. The docs do not clearly state the intended current behavior: with worktree.bgIsolation at its default, background-session subagents should not edit the shared checkout directly.

C. The worktree.bgIsolation: "none" exception is ambiguous for subagents

The settings page says "none" lets background jobs edit the working copy directly, but it does not explicitly say whether "background jobs" includes subagents spawned from a background session. Users need to know whether disabling isolation applies to the whole background-session process tree, including subagents.

Suggested Improvement

Add a short note to Agent View's "How file edits are isolated" section:

Subagents spawned by a background session use the same worktree-isolation guard as the parent background session. With the default worktree.bgIsolation: "worktree" behavior, a background-session subagent must enter the session's isolated worktree before it can edit files under the repository, so it does not write to the shared checkout directly. If worktree.bgIsolation is set to "none", subagents spawned by that background session may edit the working copy directly along with the parent session.

Also add a cross-reference from the Subagents page's "Run subagents in foreground or background" section so users looking at background subagents can discover the file-isolation behavior.

Impact

Medium - Makes feature difficult to understand

Additional Context

Affected Pages:

PageContext
https://code.claude.com/docs/en/agent-viewPrimary background-session isolation docs; explains worktree isolation and that background sessions can start subagents, but not their combined behavior
https://code.claude.com/docs/en/sub-agentsBackground subagent docs cover permission behavior but not repository write isolation when the parent is a background session
https://code.claude.com/docs/en/settingsworktree.bgIsolation says "none" lets background jobs edit the working copy directly, but does not clarify whether that includes background-session subagents

Total scope: 3 pages affected

Version context: Claude Code v2.1.154 release entry: "Fixed subagents in background sessions bypassing the worktree-isolation guard and writing to the shared checkout."

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING