Free Intensive Nov 21–22Free 2-day hands-on Vibecoding Intensive on Nov 21–22 at 16:00 MSK (Sat–Sun) · Live Cohort 3 starts Nov 23Join Free →Cohort 3 (Nov 23)
ReleaseInsight · On RadarX: @simonw→ original

Simon Willison Shows How to Isolate Claude Code and Codex Agent Code on a Mac

Coding agents like Claude Code and Codex run commands directly on your Mac, and a single mistake can wipe the wrong folder. Simon Willison has described an "external sandbox": the agent stays on the Mac, while the code it writes runs in isolation, in WebAssembly, QEMU, or Apple Container. It is like an intern working at your desk but running experiments in a lab behind glass. That lets you give the agent freedom without handing it your entire laptop.

AI-processed from X: @simonw; edited by Hamidun News
Simon Willison Shows How to Isolate Claude Code and Codex Agent Code on a Mac
Source: X: @simonw. Collage: Hamidun News.
Listen to article
Article Fact Sheet & Key Figures
ParameterDetails
Primary sourceX: @simonw ↗
Editor-in-Chief
Key metric #1WebAssembly by default cannot see files or the network without explicit permission
QEMU emulates a full machinecompatibility is higher, but startup is slower
Key metric #3Apple Container runs Linux containers on a Mac inside lightweight virtual machines

Coding agents like Claude Code and Codex can do more than offer advice. They can run commands on your computer themselves: install packages, run tests, create and delete files. When everything goes well, this is convenient.

But if the agent makes a mistake, it can wipe the wrong folder, read keys from environment variables, or run a script from an untrusted repository. Simon Willison, a well-known developer and author of a blog about practical work with LLMs, has described a way to prevent this: an "external sandbox." The agent itself still runs on your Mac, but the code it writes and wants to execute goes to a separate isolated environment: WebAssembly, QEMU, or Apple Container.

Demos for Claude Code, Codex, and Pi are attached to the description.

The idea in a simple example

Imagine the agent is an intern who sits at your desk, but is only allowed to run experiments in the neighboring lab behind thick glass. They see your task, write code, send it to the lab, and get the result back. If the script breaks the system or tries to access something it shouldn't, the damage falls on the lab, not on the desk with your documents, SSH keys, and tokens.

This differs from the popular approach of running the entire agent inside a container or VM. Here the agent and its interface stay on the host machine, where they are familiar, and only code execution is isolated. The practical benefit: you don't need to move your whole setup, editor, and credentials into the sandbox.

Three isolation options

The three technologies mentioned offer different trade-offs between speed and reliability.

WebAssembly is a compact format for executable modules with a strict access model: by default, a program sees neither files nor the network until you explicitly grant permission. This option suits small scripts and computations, but not every Python or Node.js code can simply be run in this environment.

QEMU is full machine emulation. You can run a regular Linux system with the full set of familiar tools, so compatibility is higher and the boundary between guest and host is stronger. The cost is more resources and a longer startup time.

Apple Container is Apple's tool for running Linux containers on a Mac, where each container runs in a lightweight virtual machine. For Mac owners, this is probably the most natural path: the environment is close to what you would later see in production on Linux.

The fact that demos were made for Claude Code, Codex, and Pi at once shows that the pattern is not tied to a single vendor. If an agent can execute commands through a configurable layer, that layer can be directed into a sandbox.

What this means in practice

For a team adopting coding agents, a few simple rules follow. First, don't let the agent execute generated code on a machine that holds production keys and access. Second, decide what the sandbox can see: which project folders are mounted, whether there is internet access, which secrets are passed inside. The less, the safer. Third, choose the isolation level based on the task: for quick computations, WebAssembly; for a full environment for builds and tests, a VM or container.

Limitations

The post itself is only a brief announcement; the details, configurations, and limitations are in Willison's linked material. A sandbox reduces risk but does not eliminate it: if you pass in a working directory with write access and network access, the agent can still corrupt project files or send data outward. In addition, isolation adds friction: startup delays, environment mismatches, and fiddling with dependencies.

Still, the direction is clear. As agents are trusted with more autonomous work, safe code execution is moving from an exotic practice to a mandatory part of engineering hygiene, and ready-made demos for popular agents lower the barrier for those who want to try it.

Story

Key Questions Answered

What are the key details on The idea in a simple example?

Imagine the agent is an intern who sits at your desk, but is only allowed to run experiments in the neighboring lab behind thick glass. They see your task, write code, send it to the lab, and get the result back. If the script breaks the system or tries to access something it shouldn't, the damage falls on the lab, not on the desk with your documents, SSH keys, and tokens. This differs from the popular approach of running the entire agent inside a container or VM.

What are the key details on Three isolation options?

The three technologies mentioned offer different trade-offs between speed and reliability. WebAssembly is a compact format for executable modules with a strict access model: by default, a program sees neither files nor the network until you explicitly grant permission. This option suits small scripts and computations, but not every Python or Node.js code can simply be run in this environment. QEMU is full machine emulation.

What this means in practice?

For a team adopting coding agents, a few simple rules follow. First, don't let the agent execute generated code on a machine that holds production keys and access. Second, decide what the sandbox can see: which project folders are mounted, whether there is internet access, which secrets are passed inside. The less, the safer. Third, choose the isolation level based on the task: for quick computations, WebAssembly; for a full environment for builds and tests, a VM or container.

ZK
Zhemal Khamidun — CPO at Alpina Digital, product manager of AlpinaGPT. Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Hands-On AI Engineering · Hamidun Academy

Build & Ship Production AI Agents Without Boilerplate Code

Start your free 72-hour trial at Hamidun Academy (academy.hamidun.com) — interactive lessons on Claude Code & Cursor, live Tech Radar, and production agent templates.

Start 72h Free Trial →Vibe-Coding Intensive
What do you think?
Loading comments…