/sandbox creates empty stub files in project root when using git worktrees

Resolved 💬 11 comments Opened Feb 27, 2026 by baelter Closed May 18, 2026

Description

When using /sandbox in a repository that is a git worktree (where .git is a file pointer rather than a directory), a set of empty stub files are created in the project root and show up as untracked files in git status.

Affected files

The following empty (0-byte), read-only files are created in the project root:

Shell dotfiles (sandbox home dir mapping):
`.bash_profile, .bashrc, .gitconfig, .gitmodules, .idea, .mcp.json, .profile, .ripgreprc, .zprofile, .zshrc`

Git internals (normally live inside .git/ directory):
HEAD, config, hooks, objects, refs

Root cause hypothesis

In a normal repo, .git is a directory that already contains HEAD, config, hooks, objects, refs — so any sandbox stubs landing inside .git/ would be invisible to git status. In a worktree, .git is a file (e.g. gitdir: /path/to/worktrees/branch), so the sandbox writes the stubs to the project root instead, where git picks them up as untracked.

Reproduction steps

  1. Create or use a git worktree: git worktree add ../my-branch my-branch
  2. cd into the worktree directory (where .git is a file, not a directory)
  3. Run /sandbox connect in Claude Code
  4. Run git status — observe empty stub files listed as untracked

Expected behavior

No untracked files should be created in the project directory as a side effect of connecting to a sandbox.

Workaround

Add the affected filenames to .gitignore.

View original on GitHub ↗

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