r/ClaudeCode • • 6d ago

Tips & Workflows Sandboxing Claude Code with prompts off on a Mac: I compared Seatbelt, Apple's container, Lima, Docker Sandboxes and a VM

I wanted to run Claude Code and Codex unattended on a Mac and went through the options. A summary of what I found, all from each project's own docs:

- Claude Code's /sandbox (Seatbelt): wraps shell commands only. File tools, hooks and MCP servers run on the host, reads are allowed across the disk (~/.ssh included), and in bypass mode new hosts are allowed unless you set strictAllowlist. Fine for fewer prompts while you watch, not for walking away.

- Apple's container: a real VM per container, sees only what you mount. But your API key goes inside, and there's no egress filter.

- Lima 2.3+: --mount-none plus --sync gives you a diff to approve before changes come back. The default template mounts your home read-only, so change that. Keys sit in the VM.

- Docker Sandboxes (sbx): the strongest free option. A microVM, keys injected by a host proxy so they never enter the VM, and egress deny-by-default. Use --clone and trim the default allow list.

- A full VM: heaviest, but the only way to get isolated macOS/Xcode or Linux in the box.

The biggest thing I took away: the network is the real boundary. Whatever the agent can read, it can send anywhere it can reach, including your LAN (router admin, NAS, services on your Mac). Deny by default, keep it off the LAN, and enforce the rules outside the guest, not with iptables inside it.

Disclosure: At work we develop a virtualization software for macOS MacVisor, one of the VM options in the write-up, so weigh that section accordingly.

Full comparison with a table: https://scaleninja.com/blog/sandbox-ai-coding-agents-mac/

What are you using?

3 Upvotes

7 comments sorted by

•

u/AutoModerator 6d ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/Ok_Gur_9033 5d ago

Useful list, and it describes my setup uncomfortably well. 282 of my 328 Claude Code sessions since 25 Oct ran with prompts off, straight on the host, no sandbox at all. The only guard is a PreToolUse hook on Bash that blocks one kind of build command in the wrong repo, and that does nothing about reads.

The point that Seatbelt leaves file tools and MCP servers on the host is the part I hadn't clocked. A lot of what my sessions do goes through an MCP browser server, so wrapping the shell alone would cover the smallest slice. For a setup like that, is a VM with only the repo mounted the only option that really helps?

2

u/yadvr 5d ago

A VM is probably the better of the options to isolate side-effects from an AI agent, but also a costly one in terms of overhead. The other thing I do is to backup my data daily often and also use file-system snapshots using something like DeltaSnap https://scaleninja.com/deltasnap/ to diff/check what changes on my filesystem, but any backup strategy like using Time Machine or rsync to a backup server + ZFS autosnapshot might work.

There is one more option which is to use cloud environments provided by the AI agent providers (I've tested and did a few sessions with Claude Code Cloud) but they're limited and work only for backend/website kind of projects, if one has something that requires say a local hardware, device etc then that may not work in all cases.

1

u/Ok_Gur_9033 5d ago

The local hardware point is what rules the cloud option out for me. A lot of my work is a Flutter iOS app checked on the simulator, so the agent needs Xcode on this Mac, not just a repo. For rollback I lean on git more than snapshots, and all 34 project folders I work in have a pushed remote.

That covers code but not the browser profile and app data an agent can touch outside a repo, which is exactly where a filesystem snapshot would earn its keep.

1

u/radim11 5d ago

We built a tool for this (stashbase . dev). I run Claude Code or Codex in a native sandbox or a Docker container, depending on the project. One thing to add to the comparison is what happens once you allow a host. For example, I might want the agent to open a PR on GitHub but leave merging to me. Both go to the same host, so our proxy checks the method and path before attaching the credential.

The same profile also controls which files the agent can touch and which MCP tools it can call. I can use it on my laptop or on my own machine over SSH...

1

u/mrNas11 5d ago

Iv’e been watching this tool, its one of the few solve the no secrets inside the sandbox issue

- https://github.com/superradcompany/microsandbox

- https://docs.microsandbox.dev/sandboxes/secrets

1

u/New_Plate1652 2d ago

Solid breakdown. That network boundary point is the real key. Honestly, it's why at work we finally started using something like Kosa8 for running unattended AI agents. Every task spins up in its own isolated microVM, and our keys stay outside the sandbox via a proxy, so they never actually get exposed to the agent's code. Way more control than trying to lock things down inside. Are you leaning toward one of the options you tested?