Sandbox creates phantom dotfiles in project directory instead of protecting home directory files
Description
When Claude Code's sandbox initializes, it creates empty (0-byte), read-only placeholder files in the current working directory for various dotfiles that should only be protected in $HOME. These phantom files persist after the session ends and clutter the project directory.
Affected files created in CWD
.bash_profile.bashrc.gitconfig.gitmodules.idea.mcp.json.profile.ripgreprc.vscode.zprofile.zshrc
Evidence
The bwrap command shows incorrect --ro-bind entries that bind from/to the project directory:
--ro-bind /home/user/project/.bashrc /home/user/project/.bashrc
--ro-bind /home/user/project/.zshrc /home/user/project/.zshrc
--ro-bind /home/user/project/.gitconfig /home/user/project/.gitconfig
(etc.)
These should presumably be protecting ~/.bashrc, ~/.zshrc, etc. in the home directory, not creating files in the project.
File characteristics
$ ls -la .bashrc
-r--r--r-- 1 user user 0 Jan 9 21:03 .bashrc
$ file .bashrc
.bashrc: empty
- All files are 0 bytes
- All are read-only (0444 permissions)
- All share the same creation timestamp (sandbox init time)
- Cannot be deleted from within the sandbox
Expected behavior
The sandbox should protect sensitive dotfiles in $HOME without creating any files in the project directory.
Actual behavior
Empty placeholder files are created in the project directory as bind mount targets.
Environment
- OS: Linux (Arch Linux 6.18.3)
- Claude Code version: latest as of 2025-01-09
- Shell: bash/zsh
- Dotfile manager: chezmoi (may be related - these are the files chezmoi tracks in
$HOME)
Workaround
Manually delete the files after exiting Claude Code:
rm -f .bash_profile .bashrc .gitconfig .gitmodules .idea .mcp.json .profile .ripgreprc .vscode .zprofile .zshrcThis issue has 3 comments on GitHub. Read the full discussion on GitHub ↗