[FEATURE] Agent worktree isolation from a non-git workspace root: let isolation target a nested repo
Environment
- Claude Code 2.1.274, desktop app and CLI, macOS
Problem
A common layout is one workspace folder that is not a git repo, holding many repos:
~/work/ <- session opens here (not a git repo)
repo-a/.git
repo-b/.git
...
From a session rooted there, Agent with isolation: "worktree" always fails:
Cannot create agent worktree: not in a git repository and no WorktreeCreate hooks are configured.
That holds even when the subagent's whole task is inside repo-a. The only ways around it are opening a separate session inside each repo, or writing WorktreeCreate/WorktreeRemove hooks by hand to re-create git's own worktree behavior.
Why it matters
Running parallel subagents on the same repo is where worktree isolation pays off, and a multi-repo workspace is exactly where one session coordinates work across repos. As it stands, the orchestrating session either gives up isolation (subagents edit one checkout and collide) or gives up parallelism.
Proposed
Let the caller name the repo to isolate, for example isolation: "worktree", repo: "repo-a" (a path relative to cwd), or have Claude Code infer it when the task's paths fall inside a single nested repo. Claude Code then creates the worktree in that repo exactly as it does today when the session root is the repo.