CWD is polluted with empty boundary files at every session start (package.json, yarn.lock, .env.*, etc.)

Resolved 💬 3 comments Opened Apr 21, 2026 by PinkTultle Closed Apr 21, 2026

Summary

Every claude session creates 10+ empty (0-byte) files and a node_modules/ directory in the current working directory (CWD) at startup. These cannot be disabled through any documented setting, including sandbox.enabled: false.

Environment

  • Claude Code version: 2.1.116
  • OS: Linux 6.6.87.2-microsoft-standard-WSL2 (Ubuntu on WSL2)
  • Shell: bash

Reproduction

  1. mkdir /tmp/repro && cd /tmp/repro
  2. claude (any session, even with no prompt)
  3. ls -la in CWD

Expected

CWD remains untouched unless the user explicitly creates files.

Actual

The following 0-byte files and directory are created at startup (all with the same nanosecond timestamp, indicating a single programmatic burst):

.env
.env.development
.env.development.local
.env.local
.env.production
.env.production.local
.env.test
.env.test.local
.gitmodules
.npmrc
.yarnrc
.yarnrc.yml
bunfig.toml
package.json
package-lock.json
pnpm-lock.yaml
yarn.lock
node_modules/.bin/   (empty directory)

Additionally, bind-mounts (character devices owned by nobody:nogroup) are placed over common user config files (.bashrc, .zshrc, .gitconfig, .mcp.json, .idea, .vscode, scripts, etc.) at initial CWD entry.

Hypothesis (unverified)

The Claude Code binary appears to be compiled with bun build --compile. strings on the installed binary reveals:

  • JavaScriptCore / Bun runtime symbols (JSLexicalEnvironment_variables, JSC::FTL::...)
  • The exact filenames above embedded as literals
  • Bun compile flags: --no-compile-autoload-dotenv, --no-compile-autoload-bunfig, --no-compile-autoload-package-json

This suggests the embedded Bun runtime's autoload discovery (or a related isolation layer) is responsible, but the precise creation path is opaque to end users.

Why this matters

  • Users expect cd ~/my-workspace && claude to leave the workspace untouched.
  • The empty files conflict with real project initialization (npm init, bun init) because they already exist.
  • Users must add all ~18 filenames to .gitignore to prevent pollution in version control.
  • Several of the files (.env*) have security implications — their presence can change how other tools (Next.js, Vite, Docker Compose) interpret the directory.

Workarounds tried

  1. Setting "sandbox": { "enabled": false } in both ~/.claude/settings.json and ./.claude/settings.local.jsonno effect, files still created.
  2. Disabling all plugins — no effect.
  3. Custom SessionStart hooks — cannot prevent, only react.

Request

Please provide one of:

  1. A documented setting to disable boundary-file creation (e.g. "workspace": { "isolateCwd": false }).
  2. An environment variable (e.g. CLAUDE_CODE_NO_CWD_MARKERS=1).
  3. Runtime CLI flags that pass through to the embedded Bun's --no-compile-autoload-* family.
  4. At minimum, documentation explaining which files are created, why, and that users should run claude only in disposable or dedicated directories.

Additional info

All files created in a single syscall burst — example stat output:

2026-04-21 11:15:14.378440534 +0900 .env
2026-04-21 11:15:14.378440534 +0900 .env.development
2026-04-21 11:15:14.378440534 +0900 package.json
2026-04-21 11:15:14.378440534 +0900 bunfig.toml
...

View original on GitHub ↗

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