Claude Code Bash tool hits E2BIG when sandbox profiles scale with large git worktrees
jkMLnop · ghdev · 2026-07-17
A Claude Code bug report shows Bash tool calls failing with spawn E2BIG whenever the working directory is inside a non-trivial git repository.
Main finding
The command itself is not the problem. The compiled sandbox filesystem policy grows with the repository's working-tree file count until the OS argument-length limit is exceeded. The report says the error mentions around 187 filesystem deny paths and a compiled profile around 1–1.1 MB.
Repro pattern
The failure appears to require both of these conditions:
- cwd is inside a git repo
- the repo has a sufficiently large working tree
Observed behavior:
- non-git directories did not fail, even with 377,000+ files
- a git repo with one file worked
- git repos with 148+ working-tree files consistently failed, up to roughly 40,000 files
What was ruled out
The reporter says they tested and eliminated several plausible causes, including:
- git internals / reflog file count
- .claude/commands
- per-project Claude Code session history
- secret-filename pattern matching
The report concludes that the pattern is robust, but the exact internal code path still needs source access to identify.
More from coding & agent
- Codex tip: use Sol with Astra and Luna sub-agents to save usage — pvncher · 2026-09-11
- agents-best-practices: a provider-neutral Agent Skill for designing and auditing agentic harnesses — tom_doerr · 2026-09-11
- Cognition's SWE-2 uses a KKT duality argument in RL to shift the effort Pareto curve — YouJiacheng · 2026-09-11
- First-ever Three.js Conference lands in Paris, with a panel on AI-shortened design workflows — OdinLovis · 2026-09-11
- Data engineering, not agent frameworks, is the real bottleneck for enterprise AI agents — dhruv2038 · 2026-09-11
- RTK Terminal Compression Cuts Tokens but Leaves Your AI Coding Bill Unchanged — Bartaseth · 2026-09-11