sandbox.excludedCommands not working for git SSH operations

Resolved 💬 3 comments Opened Oct 31, 2025 by gsong Closed Nov 4, 2025

Description

The sandbox.excludedCommands setting does not appear to exclude git commands from sandboxing, preventing SSH authentication for git push/pull operations.

Configuration

In settings.json:

{
  "sandbox": {
    "enabled": true,
    "excludedCommands": ["git"],
    "network": {
      "allowUnixSockets": ["/private/tmp/com.apple.launchd.*/Listeners"]
    }
  }
}

Expected Behavior

Based on the sandboxing documentation, commands listed in excludedCommands should "bypass the sandbox entirely" and "run directly in your environment."

Git commands should have access to SSH keys and the SSH agent socket for authentication.

Actual Behavior

Git commands still run sandboxed and cannot access the SSH agent:

$ git push --force-with-lease
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Even ssh-add -l fails:

Error connecting to agent: Operation not permitted

Workaround

Using dangerouslyDisableSandbox: true on individual Bash tool calls works correctly.

Environment

  • OS: macOS (Darwin 24.6.0)
  • SSH_AUTH_SOCK: /private/tmp/com.apple.launchd.CbSQMJSe88/Listeners (verified to exist)
  • Git works from terminal: Yes, SSH authentication works fine outside Claude Code

Steps to Reproduce

  1. Configure sandbox.excludedCommands: ["git"] in settings.json
  2. Restart Claude Code
  3. Attempt git push to a repository requiring SSH authentication
  4. Observe permission denied error

Additional Notes

Tested with both:

  • sandbox.enabled: true explicitly set
  • sandbox.enabled omitted (default behavior)

Both configurations exhibit the same issue.

View original on GitHub ↗

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