Sandbox filesystem restrictions break git worktree workflows

Resolved 💬 2 comments Opened Feb 17, 2026 by mlupton100 Closed Feb 17, 2026

Problem

Claude Code's sandbox scopes filesystem writes to the current working directory. Git worktrees (both bare repo layouts and normal clone worktrees) require writes to shared git internals outside the current working directory, causing all git write operations (add, commit, push) to fail with:

fatal: Unable to create '.../index.lock': Read-only file system

Reproduction

  1. Set up a bare repo with worktrees:

``bash
git clone --bare repo.git .bare
echo "gitdir: ./.bare" > .git
git worktree add main main
cd main
``

  1. Enable sandbox in Claude Code settings ("sandbox": { "enabled": true })
  2. Ask Claude to make a commit — fails because .bare/ is outside the cwd

This also affects normal clones with worktrees: git worktree add ../feature-branch creates a worktree whose git metadata lives at <original-repo>/.git/worktrees/, which is outside the worktree's cwd.

What doesn't work

  • excludedCommands: ["git"] — bypasses command-level sandboxing but the filesystem write restriction still blocks git's internal file writes
  • sandbox.filesystem.write.additionalAllow — not a real config key (no effect)

Impact

This blocks a compelling multi-agent workflow: spawning Claude Code agents in separate worktrees to work on features in parallel. Each agent's sandbox prevents it from committing in its own worktree.

Suggested solutions (any of these would help)

  1. Make excludedCommands fully bypass the filesystem sandbox — if a command is excluded, don't restrict its filesystem writes
  2. Auto-detect git internals — resolve the repo's git directory (via git rev-parse --git-common-dir) and automatically allow writes there
  3. Support additionalAllow in sandbox config — let users explicitly add paths to the filesystem write allowlist:

``json
"sandbox": {
"filesystem": {
"write": {
"additionalAllow": ["/path/to/.bare"]
}
}
}
``

Option 2 would provide the best DX — zero config, works for all worktree layouts.

Environment

  • Claude Code with sandbox enabled
  • Git bare repo with worktrees (also reproducible with normal clone + git worktree add)
  • Linux (Arch)

View original on GitHub ↗

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