Last reviewed
Correct answer: B. In the session's own worktree, since the subagent inherits that working directory — and outside a repository there would be no isolation at all
Explanation
The principle — a worker inherits where it works from whatever started it, and the isolation everything here depends on is a git feature that either exists or does not.
Why the key is correct — the first half is stated directly: a subagent the background session spawns inherits the session's working directory, so its file edits land in the session's worktree rather than your working copy. That is what makes several dispatched sessions safe to run at once — parallel sessions can read the same checkout but each writes to its own. The second half is the warning attached to the same mechanism: 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. And worktrees require a git repository, so there is no worktree to inherit in that case. The consequence worth carrying is that the same arrangement is safe in one place and unsafe in the other, with no message to mark the difference.
Why the others are wrong — the edits do not reach your working copy. A worktree cannot be had outside a repository. And nothing hands out a substitute space when there is no repository — the sessions simply share one directory.
Remember this — the subagent writes where its session lives, and with no repository nothing is isolated from anything.
Sources — Anthropic's Claude Code documentation on managing multiple agents, and on worktrees.
Sources
“A subagent the background session spawns inherits the session's working directory, so its file edits land in the session's worktree rather than your working copy.”
“so parallel sessions can read the same checkout but each writes to its own”
“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.”
“Worktrees require a git repository”
Practise 10 questions on this topic
Take Claude Code Workflows — Timed Test 1 (10 questions) — scored instantly, explanation for every question, no login.