sandbox.additionalDirectories resolves absolute paths incorrectly (prepends ~/.claude/)
Bug Description
sandbox.additionalDirectories in ~/.claude/settings.json does not correctly resolve absolute paths. Absolute paths are prefixed with the ~/.claude/ directory, producing invalid paths.
Steps to Reproduce
- Add to
~/.claude/settings.json:
"sandbox": {
"additionalDirectories": ["/Users/username/.agent-memory"]
}
- Start Claude Code
- Run a Bash command that writes to
/Users/username/.agent-memory/(e.g., SQLite database write) - Command fails with "not writable" / sandbox permission error
Expected Behavior
The absolute path /Users/username/.agent-memory should be added to the sandbox write allowlist as-is.
Actual Behavior
The resolved sandbox config shows the path as /Users/username/.claude/Users/username/.agent-memory — the absolute path is joined relative to ~/.claude/ instead of being used directly. Relative paths (e.g., ../.agent-memory) also don't resolve correctly.
Environment
- macOS (Seatbelt sandbox)
- Claude Code (stable channel)
additionalDirectoriesis not documented on the official sandbox docs page (https://code.claude.com/docs/en/sandboxing) or settings reference (https://code.claude.com/docs/en/settings), but it does have a partial effect (it appears in the resolved write allowlist, just with wrong path).
Workaround
Using "Allow unsandboxed fallback" mode — when the sandboxed write fails, Claude retries with dangerouslyDisableSandbox: true which goes through normal permissions.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗