claude-code - 💡(How to fix) Fix [DOCS] Background session isolation docs omit non-git `WorktreeCreate` hook behavior

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…

Fix Action

Fix / Workaround

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.

Claude skips the worktree when:

  • The session is already inside a linked git worktree, whether Claude created it under .claude/worktrees/ or you created it with git worktree add somewhere else
  • The working directory isn't a git repository
  • The write is outside the working directory

Outside a git repository, sessions write to the working directory directly and aren't isolated from each other, so avoid dispatching parallel sessions that edit the same files.

RAW_BUFFERClick to expand / collapse

Documentation Type

Incorrect/outdated documentation

Documentation Location

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

Section/Topic

"How file edits are isolated" in the background sessions / agent view docs

Current Documentation

The docs currently say:

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.

Claude skips the worktree when:

  • The session is already inside a linked git worktree, whether Claude created it under .claude/worktrees/ or you created it with git worktree add somewhere else
  • The working directory isn't a git repository
  • The write is outside the working directory

Outside a git repository, sessions write to the working directory directly and aren't isolated from each other, so avoid dispatching parallel sessions that edit the same files.

What's Wrong or Missing?

This section only describes git repositories and plain non-git directories. It does not explain how background-session isolation behaves when a project uses a non-git VCS and configures a WorktreeCreate hook.

That omission now makes the page misleading: the current wording implies that background sessions always skip isolation whenever the directory is not a git repository, even though Claude Code also documents WorktreeCreate hooks for SVN, Perforce, Mercurial, and other non-git setups.

For the v2.1.144 background-session isolation change, users need explicit guidance on whether the isolation guard applies when WorktreeCreate is configured, what behavior to expect before EnterWorktree, and when worktree.bgIsolation: "none" is still the right setting.

Suggested Improvement

Update the agent-view page so the isolation rules cover non-git VCS repositories with WorktreeCreate hooks configured.

At minimum:

  1. Revise the "Claude skips the worktree when" list so it does not imply that every non-git repository bypasses isolation.
  2. Add a short note explaining the background-session behavior when WorktreeCreate is present for non-git VCS users.
  3. Cross-link the non-git VCS hook documentation from the background-session isolation section.
  4. Clarify how this interacts with worktree.bgIsolation: "none".

Impact

Medium - Makes feature difficult to understand

Additional Context

Affected Pages:

PageLine(s)Context
https://code.claude.com/docs/en/agent-view305-313, 327Says background sessions skip worktrees when the directory is not a git repository and says non-git directories are not isolated
https://code.claude.com/docs/en/settings275Documents worktree.bgIsolation for background sessions but does not explain non-git WorktreeCreate hook behavior
https://code.claude.com/docs/en/worktrees129-131Documents non-git WorktreeCreate / WorktreeRemove hooks, but not that the same setup affects background-session isolation

Total scope: 3 pages affected

This appears to need a docs update tied to the v2.1.144 background-session isolation change for non-git VCS users with WorktreeCreate hooks configured.

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