pub fn worktree_base(root: &Path) -> PathBufExpand description
The checkout root the claude CLI forks a worker’s --worktree under:
the repository’s main working tree, resolved from the first entry of
git worktree list --porcelain - the main checkout when the project is
itself a linked worktree, the repo root for a subdirectory. Measured on
2.1.280: the CLI resolves its cwd to that root before composing
<root>/.claude/worktrees/<label>, so a project rooted in a linked
worktree (or in a repo subdirectory) otherwise names a directory the
CLI never creates (#2460). A path that is not a repository is its own
base.
A repository kept in a separate git dir is NOT a supported worker layout: git names its admin dir (not a checkout) as the first worktree entry, and the CLI’s own base for that shape is unverified, so forge follows git’s answer rather than guessing a checkout it cannot derive.
Memoised per root: callers include render paths that ask per row per frame, and a checkout’s canonical root does not move under a live forge. A git that could not answer is NOT memoised - a transient failure must not pin the path this exists to correct - and is reported once per root.