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
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.
- Nov 21, 2026Guardian columnist: novice hackers with AI breached 100+ companies at $50 per break-in
- Nov 21, 2026Anthropic Prices Record $81.3B IPO, Shares Jump 18% in First Minutes
- Nov 21, 2026NestJS Releases Cheat Sheets for AI Agents: One Command Teaches Claude Code and Cursor
- Nov 21, 2026Why an AI Agent Writes Slop: Ex-CTO of City Drive Explains How to Prepare a Repository
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.
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.
The AI world, distilled — once a week
Seven stories that actually mattered, hand-picked. No noise, no reposts, no press releases.
Done! Check your inbox for a confirmation.