Coding Agent Sandbox: Run Claude Code on Your Macs14 min read2,783 words

Coding Agent Sandbox: Run Claude Code on Your Macs

Run Claude Code or Codex in disposable sandboxes on hardware you control. Learn what isolation means, how Potluck works, and where its security limits are.

coding agent sandboxClaude Code sandboxCodex sandboxself-hosted coding agentsPotluck sandbox
Coding Agent Sandbox: Run Claude Code on Your Macs

Run Claude Code and Codex in Sandboxes on Your Own Machines

Coding agents can run shell commands, install packages, change files, and fetch web pages. That's exactly why they're useful - and why running them directly on your everyday laptop is a real security decision. One mistaken command (or a hostile instruction hidden in an issue or web page) can go as far as the agent's account can reach.

A hosted sandbox moves that work onto someone else's infrastructure. If you run the sandbox on machines you control, you get a different trade-off: disposable environments without handing your code and execution to a third-party sandbox provider. Potluck is one way to manage that setup across Macs and Linux machines. It creates fresh virtual machines (or isolated containers), runs commands inside them, and removes them afterward.

This guide covers what a useful coding-agent sandbox should isolate, what Potluck does (and doesn't) protect, and how to set up Claude Code or Codex. The key distinction isn't just "container versus VM." It's what the agent can reach, who can inspect the sandbox, and what credentials you put inside it.

Why put a coding agent in a sandbox you own?

People usually frame this as either "run the agent on your laptop" or "pay for a hosted sandbox." There's a third option: run the agent in a disposable environment on hardware you (or your team) operate. It helps you keep a stronger separation from your personal files without sending your source code to someone else's machines.

But self-hosting doesn't mean "the host can't see anything." The machine running the sandbox can read what's inside the environment: code, commands, output, and any credentials you supply to the agent. With self-hosting, you're the one who gets added to the trust list (or whoever runs the machines you join). Self-hosting changes who you trust - it doesn't erase the trust relationship.

Comparison Agent on your laptop Potluck sandbox on your machines
Where commands run On your laptop, under your user account In a VM or container on a machine in your pool
Access to your laptop files Potentially available to the agent Not available by default from the sandbox
Who may inspect code and output You and processes with laptop access You and the owner of the host machine
Who operates the hardware You You or your team

When self-hosting is a good fit

Self-hosting can work well if you already have a Mac or Linux machine with spare capacity, you need to keep work inside infrastructure your team controls, or you want short-lived agent runs without giving them direct access to your workstation. It also lets you choose which machines to use and control how long each environment stays alive.

It's not automatically cheaper to run. You're responsible for the host's uptime, updates, capacity, and network setup. And if you need sandboxes available on demand around the clock, a hosted service may be simpler. If you can't manage the machine (or its access) confidently, self-hosting can end up moving risk around rather than reducing it.

The practical comparison

A local container can help isolate processes, but it often shares the laptop's network and may still have access to mounted files. Potluck's goal is broader: isolate the sandbox from the host, the local network, and other sandboxes, then discard it after the run. Exactly how strong that boundary is depends on the runtime and how the host is configured, so you should test it rather than assume it's perfect.

A better question than "is it local or cloud?" is: what can the agent reach, what can the machine owner read, and what's left after the task ends? Those answers matter more than a generic claim that "it's sandboxed."

What should a coding-agent sandbox actually isolate?

A coding agent isn't just a text generator. It executes commands, edits files, installs dependencies, and processes untrusted input. A malicious (or just sloppy) issue description or web page can push instructions that don't match what you meant to do. A sandbox helps limit the damage if the agent follows a bad instruction or makes a mistake.

Potluck's isolation document lists six boundaries. Use them as checks for your setup, not as a substitute for understanding how your host and network are configured.

Six boundaries worth checking

  1. Host access: The sandbox should not be able to connect to services on the machine that runs it, including local development ports. On Tart, Potluck documents an exception for Softnet's DNS forwarder on the host.
  2. Local network access: The agent should not be able to reach devices on your host's LAN (your router, NAS, printer, other computers, and so on).
  3. Peer separation: One sandbox should not connect to another sandbox in the same pool.
  4. Credential minimization: A fresh sandbox should start without your keys. Credentials should only be added when the task actually needs them.
  5. Clean lifecycle: Each task should start from a known image, and the sandbox should be removed at its time limit (or when you delete it).
  6. Outbound mail controls: Outbound mail ports should be closed to reduce the risk of a compromised agent sending email directly.

Network access still matters. A sandbox that can't reach the host or LAN can still have internet access (often required to download packages or call external services). Potluck documents filtered networking on Linux after potluck doctor reports the network configuration; --net off disables network access entirely. The offline option is safer for tasks that don't need downloads, but it can break normal dependency installation and agent workflows.

Verify the boundary, then decide what to trust

Potluck provides potluck isolation test <machine>-c2m4 to test host access, local-network access, Tailscale-network access, and peer-sandbox isolation on your machine. The potluck host command checks mail access. Run these checks on the machines you plan to use, and repeat them after meaningful changes to the runtime or network setup.

Testing helps, but it's not proof that every attack path is impossible. The hypervisor/container isolation, host configuration, and software updates all play a role. Treat a sandbox as a risk-reduction boundary, not as a reason to drop production credentials into an agent by default.

How does Potluck create disposable sandboxes?

Potluck coordinates machines in a pool and the sandboxes created on them. A pool is a group of machines you (and other members) make available. Each machine shares some of its capacity; by default, Potluck makes half its cores and memory available. A sandbox is then a fresh VM or container on one of the hosts in that pool.

Potluck doesn't add a separate "virtualization layer" of its own. On Apple-silicon Macs it uses Tart virtual machines, and on Linux it uses Docker with Kata or gVisor. That runtime choice affects what you can run and what you need installed. A Mac can host standard Potluck sandboxes through Tart, but the provided agent image requires a Linux machine in the pool.

What happens when you request a sandbox

When you create one, Potluck picks the smallest shared machine size that fits your request. A size like c2m4 means two cores and 4 GB of RAM. It starts a new environment from the selected image and returns an ID you use to run commands, open a shell, copy files, or delete the sandbox.

For development tasks, the agent template includes Potluck's Linux image plus Git, GitHub CLI, Node 22, Go, Python 3, ripgrep, jq, build tools, and the Claude Code and Codex command-line tools. That's a practical starting point, not a promise that every repository will build without setup. Some projects need extra system packages, different language versions, services, or environment variables.

When you pass --ref HEAD, Potluck sends the current commit from your checkout as a Git bundle. Add --dirty if the sandbox also needs uncommitted changes. This is an important workflow choice: without the right snapshot, the agent may work against an older commit or ignore local edits. On the flip side, sending a dirty working tree can include changes you didn't mean to expose to the task.

Know what the host and pool can see

The sandbox's host can read everything inside the environment. The pool machine can also see commands, output, and secrets passing through it, subject to Potluck's documented command-sealing behavior. If you use --via tunnel, the tunnel provider may also be able to see that traffic. Potluck's README recommends joining only a pool whose owner you'd trust with that level of access.

That caveat is central to the self-hosted model. You can isolate the sandbox from the host's network and still have the host administrator able to read what's inside. Network isolation and administrator confidentiality aren't the same thing. Use machines you trust, and don't send secrets just because the sandbox is disposable.

How do you set up Claude Code or Codex step by step?

The setup has five stages: install and check the machine, start a pool, create an agent-ready sandbox, run the task, and remove the environment. The commands below assume you've installed Potluck and you're operating a machine you control.

1. Install Potluck and check dependencies

curl -fsSL https://raw.githubusercontent.com/sengirunners/potluck/main/install.sh | sh

potluck doctor

On a Mac, you need Tart and Softnet. On Linux, you need Docker configured with Kata or gVisor. potluck doctor reports missing components and (on Linux) identifies what network configuration is needed for filtered networking.

The ready-made agent template and potluck agent-runner need a Linux machine with Docker and Kata or gVisor in the pool. A Mac-only pool can run plain sandboxes, but it can't run this Linux agent image.

2. Start a pool and share the machine

potluck create team --via tunnel

potluck host

If you're hosting on a Mac you're actively using, add --reclaim-idle-s 0. By default, keyboard or pointer activity can keep the Mac sandbox from ending. That may be fine for an idle host, but it can interrupt an agent running on your workstation.

3. Create the sandbox and send the right code

potluck sandbox create --template agent --ref HEAD

Add --dirty if the task needs uncommitted work. Remember: that includes the working-tree changes you send. Review what's present before you share it with the sandbox.

4. Run a command or open an agent session

potluck sandbox exec <id> --timeout 600 -- npm test

potluck sandbox shell <id>

exec runs a literal argument list and returns the command's exit code. Its default limit is 30 seconds; use --timeout for longer commands, up to 600 seconds. If you need something to keep running in the background, use --detach and follow output with potluck sandbox logs -f. Use shell to open an interactive terminal and start Claude Code or Codex. potluck sandbox cp moves files in or out.

For a one-off command, potluck run -- make test does creation, commit sending, execution, output streaming, and cleanup in one go. It's simpler when you don't need to inspect or reuse the sandbox.

5. Remove the sandbox

potluck sandbox rm <id>

Deletion is part of the security model, not just housekeeping. Set an appropriate time limit when creating the environment, and remove it once the task finishes. A disposable sandbox reduces how long files and processes hang around, but it can't undo anything you copied out or any secret that was already exposed.

How should you handle runners, secrets, and multiple agents?

There are two operating modes. In the first, you create a sandbox and start an agent yourself from inside its shell. In the second, an agent can use Potluck's sandbox tools through MCP, or Claude Code can run through its self-hosted runner mode. Those modes aren't interchangeable - the second one needs more careful handling of tool permissions and credentials.

Let an agent manage sandboxes through MCP

Potluck can expose sandbox operations to an MCP client. Its server offers tools to create, execute, list, extend, stop, restart, and delete sandboxes, manage background processes, and read or write files. Configure the client to run Potluck with the right pool selected. If you only have one pool, the pool argument is optional.

Keep the tool boundary narrow. An agent that can create and delete sandboxes has more operational authority than one that can only run a test in an existing environment. Potluck also says sandbox output is treated as data, not instructions. That's a good design rule: output from a test, a log, or a file shouldn't silently override the user's instructions.

Run Claude Code's self-hosted runner

Claude Code supports a self-hosted runner mode. Potluck's runner command starts a fresh sandbox for each runner and replaces it when one ends. This setup requires a Linux host with Docker and Kata or gVisor, plus an agent image that includes Claude Code. The default image doesn't include the claude command.

potluck agent-runner claude --secret-file ~/.config/claude/environment-secret --image ghcr.io/sengirunners/potluck-box-agent

You can use --count to run multiple sessions, --timeout to set a limit (one hour by default), and --allow-tool or --deny-tool to control tool permissions. Before relying on runner support, create an agent sandbox and check claude self-hosted-runner --help inside it. Potluck doesn't install the runner mode itself, and the documented agent image is pinned for Linux; macOS guests don't currently take secrets in this setup.

Treat secrets as a deliberate exception

The sandbox and the machine running it can read a key supplied to the session. Only provide a credential when the task truly needs it, use the narrowest permissions available, and rotate it if you suspect exposure. Deleting a sandbox later doesn't make a secret safe while the process is running.

For network access, a trusted sandbox can reach the internet while staying blocked from the host and its LAN, depending on the configured runtime and network rules. Use --net off when the task doesn't need connectivity. If you're running multiple agents, separate workspaces and be clear about ownership. Potluck's makers also offer Mezze, a separate product for coordinating agents with work items and messaging.

Conclusion

Running Claude Code or Codex in a sandbox you own can keep agent work away from your everyday files without sending execution to a hosted sandbox provider. Potluck automates the lifecycle - but your security outcome still depends on the host, runtime, network configuration, and the secrets you choose to provide.

Start with one low-risk task. Run the isolation checks, confirm the agent has only the code and permissions it needs, and verify cleanup behaves as expected. If you want minimal operational overhead, a hosted service may be the better trade-off. If you need control over the hardware and you're willing to operate it, a self-hosted sandbox is a practical middle ground.

Frequently Asked Questions

Yes. Create a sandbox with --template agent, open it with potluck sandbox shell, and start Claude Code. To run Claude Code’s self-hosted runner for sessions started from claude.ai, use potluck agent-runner claude with the required Linux host, agent image and environment secret.
The agent image includes the Codex command-line tool, so you can start Codex in a sandbox as you would from a terminal. Potluck’s built-in runner adapter is for Claude Code; adapters for other vendors are not currently built, according to the project’s documentation.
No. The pool and host can be the same computer, and the basic setup does not require an account. A second machine becomes useful when you want to separate your daily workstation from the host or invite other people to contribute machines to a pool.
It ends when its time limit is reached. Set a time limit with --ttl when creating it, and use potluck sandbox extend <id> to add time within the machine’s configured cap. For longer commands, account for both the command timeout and the sandbox lifetime.
It can provide stronger separation from the laptop’s files and network, depending on the runtime and configuration. Potluck aims to isolate the sandbox from its host, local network and peer sandboxes. The host owner can still inspect sandbox contents, and isolation should be tested on the actual machine.

Related articles