[BUG] Bash tool tries to create .claude file in project dir, denied by sandbox

Resolved 💬 4 comments Opened Jan 22, 2026 by mpinto-bit Closed Feb 28, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When using the Claude Agent SDK with sandbox enabled, the Bash tool attempts to create a .claude/ configuration directory in the working directory (cwd). This fails because the sandbox (bubblewrap) restricts writes. Note: The input to the tool itself is not trying to modify the .claude directory

What Should Happen?

If the Bash tool is modifying .claude internally, this should be allowed.

Error Messages/Logs

This error happens on any invocation of the Bash tool, no matter what command is executed:
bwrap: Can't create file at {cwd}/.claude: Permission denied

Steps to Reproduce

Create an agent with the SDK using these options:

from claude_agent_sdk import query, ClaudeAgentOptions

async def main():
options = ClaudeAgentOptions(
cwd="/path/to/sandbox/workspace",
permission_mode="bypassPermissions",
sandbox={
"enabled": True,
"autoAllowBashIfSandboxed": True,
"allowUnsandboxedCommands": False,
},
)

async for message in query(prompt="List all files in the directory", options=options):
print(message)

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.15

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

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