Worktrees spawned by Claude Code are missing untracked files from main branch

Resolved 💬 3 comments Opened May 13, 2026 by paddykopp Closed May 16, 2026

Bug Description

When Claude Code spawns a git worktree (via EnterWorktree), the worktree only contains tracked files from the repository. Untracked files present in the main working directory are not visible in the worktree.

This causes Claude to make incorrect decisions about the codebase — e.g., concluding that a module "doesn't exist" or that a require() path is broken, when the file actually exists in the main branch as an untracked file.

Reproduction Steps

  1. Have one or more untracked files in the main project directory (e.g., config_loader.js, combo_trend_tracker.js)
  2. Claude Code spawns or enters a worktree (e.g., via EnterWorktree or automatic worktree creation for plan mode)
  3. From within the worktree, use Glob or Read to look for those files
  4. Result: Files are not found — worktree only reflects tracked git state

Expected Behavior

The worktree should either:

  • Include untracked files from the main working directory, OR
  • Clearly surface a warning that untracked files are not present, so Claude can fall back to reading from the main directory

Actual Behavior

Untracked files silently do not exist in the worktree. Claude proceeds with incomplete file state, leading to wrong analysis (e.g., "this module does not exist", broken require() path analysis).

Environment

  • OS: Windows 11 Pro (10.0.22631)
  • Claude Code: CLI version (latest)
  • Repo type: Standard git repository (not bare)

Impact

Claude makes incorrect refactoring decisions based on an incomplete view of the codebase. In one documented case, a module listed as a require() dependency was declared "missing" because the file was untracked in the worktree. This required the user to manually intervene and redirect Claude to the main directory.

Suggested Fix / Mitigation

Either copy untracked files into the worktree at creation time, or inject a clear notice in the worktree's CLAUDE.md that untracked files are not present and all reads should fall back to the main working directory.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗