anthropics / anthropics/claude-code

Session's declared worktree path sometimes not populated by git worktree add — falls through to shared main checkout

Aberta
#91,349 0 comentários 0 reações 0 responsáveis Ver no GitHub
area:core bug
Linguagem predominante
Python
Estrelas
145k
Forks
23.1k
Métricas de merge de PRs
Métricas de PR pendentes

Descrição

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).

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
git
Domínio
cli, devtools
Tipo de issue
Bug
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Ativa
Clareza
Precisa de esclarecimento
Facilidade para iniciantes
25/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.