anthropics / anthropics/claude-code
Session's declared worktree path sometimes not populated by git worktree add — falls through to shared main checkout
- 主要语言
- Python
- 星标
- 145k
- 派生
- 23.1k
- PR 合并指标
- PR 指标待抓取
描述
Investigating a session that was given a `.claude/worktrees/` path in its system prompt as its "Worktree path", but the directory was completely empty (no `.git`, no files) even though the session had already done real work (reading files, editing, committing, pushing a branch, opening/merging a PR).
Because `git` walks up parent directories looking for `.git` when none exists in the cwd, every git command run with that empty directory as cwd silently resolved to and operated on the shared main repo checkout instead of an isolated worktree. The session's own commits/push/PR were still valid (they hit the real `.git` and remote), so no work was lost in that instance — but the isolation the harness presumably intended was silently absent for the whole session, and a concurrent session using the same shared checkout could have had its own in-progress branch/checkout state stomped on.
Broader check across the same repo (read-only) found this is not a one-off: under `.claude/worktrees/` there were 12 directories total, but `git worktree list` only registered 6 of them as real, populated git worktrees. The other 6 were empty shells not registered in `git worktree list` at all, with folder mtimes spanning at least two days and clearly many separate sessions (not one bad run). One of the six was later cleaned up automatically (removed entirely) between checks; the other five are still sitting there empty and unregistered.
This suggests the session-provisioning step creates/declares a worktree folder and path, but the corresponding `git worktree add` that should populate and register it doesn't always run (or fails silently, or races) — leaving the session pointed at a path that git treats as no worktree at all, with a silent fallback to the shared checkout rather than any error.
Reported as a repo-external / harness-level issue since there's no application code path to fix; happy to share more detail on the repo layout if useful (kept generic here since the actual repo is private).
贡献指南
这个仓库没有索引到贡献指南
调研方向
Begin with the harness-level session-provisioning path that creates `.claude/worktrees/`, then compare the expected `git worktree add` step with `git worktree list` for empty directories. Done means each declared path is populated and registered, while any failed or raced provisioning attempt reports an error instead of falling back to the shared checkout.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- git
- 领域
- cli, devtools
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 活跃
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100