<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Nate Silva</title>
  <subtitle>Notes, writing, and other things by Nate Silva.</subtitle>
  <link href="https://natesilva.dev/feed.xml" rel="self" />
  <link href="https://natesilva.dev/" />
  <updated>2026-06-10T05:08:00Z</updated>
  <id>https://natesilva.dev/</id>
  <author>
    <name>Nate Silva</name>
  </author>
  <entry>
    <title>The Easy Way to Run Your AI Agent in a Sandbox</title>
    <link href="https://natesilva.dev/2026/06/the-easy-way-to-run-your-ai-agent-in-a-sandbox/" />
    <updated>2026-06-10T05:08:00Z</updated>
    <id>https://natesilva.dev/2026/06/the-easy-way-to-run-your-ai-agent-in-a-sandbox/</id>
    <content type="html">&lt;p&gt;Your developers should be running Claude Code in a container. Are they?&lt;/p&gt;
&lt;p&gt;In my experience few developers do this. This leaves you open to prompt injection attacks, NPM script injection attacks, and just simple destructive errors that AI agents can make.&lt;/p&gt;
&lt;p&gt;Developers don’t use containers every time because it’s difficult. We need to minimize friction: make the easy path the safe path.&lt;/p&gt;
&lt;p&gt;I’m going to show you how to do this easily — and you don’t even need Docker.&lt;/p&gt;
&lt;!--more--&gt;
&lt;div class=&#34;callout&#34;&gt;
&lt;b&gt;The hard way:&lt;/b&gt; Here’s an actual command that an LLM recommended for running Claude Code in a container. You don’t want your developers wasting their time debugging this.
&lt;pre&gt;&lt;code class=&#34;language-shell&#34;&gt;# Don’t do it like this! I’m going to show you the easy way.
docker run --rm -it \
  --network=none \                      # or a custom bridge with an egress proxy
  --read-only \
  --tmpfs /tmp:size=512m \
  -v &amp;quot;$PWD&amp;quot;:/workspace:rw \
  -v ~/.claude-sandbox-auth:/auth:ro \  # only the API key, nothing else
  -w /workspace \
  --user 1000:1000 \
  --cap-drop=ALL \
  --security-opt=no-new-privileges \
  claude-code-sandbox:latest
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h2&gt;Why to do this&lt;/h2&gt;
&lt;p&gt;First, let’s briefly review what could happen if you don’t run your AI agent in a container:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.tomshardware.com/tech-industry/artificial-intelligence/claude-powered-ai-coding-agent-deletes-entire-company-database-in-9-seconds-backups-zapped-after-cursor-tool-powered-by-anthropics-claude-goes-rogue&#34;&gt;It could delete your database by accident&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://arstechnica.com/security/2026/05/fed-up-with-vibe-coders-dev-sneaks-data-nuking-prompt-injection-into-their-code/&#34;&gt;It could delete source code intentionally (malicious prompt injection)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.reddit.com/r/ClaudeAI/comments/1pgxckk/claude_cli_deleted_my_entire_home_directory_wiped/&#34;&gt;It could wipe your Mac&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://thenextweb.com/news/ai-agents-hijacked-prompt-injection-bug-bounties-no-cve&#34;&gt;It could leak your credentials&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://arxiv.org/html/2601.17548v1&#34;&gt;That repo you cloned from GitHub could be installing malware&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I doubt I need to convince you. If you’re a developer, or on an engineering team, you’ve seen the news stories. You already know it’s a risk.&lt;/p&gt;
&lt;h2&gt;The Easy Way&lt;/h2&gt;
&lt;p&gt;The simple mitigation for this problem is to &lt;strong&gt;run the AI Agent in a Docker Sandbox&lt;/strong&gt;, or &lt;code&gt;sbx&lt;/code&gt; for short.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.docker.com/products/docker-sandboxes/&#34;&gt;Docker Sandboxes&lt;/a&gt; is a new tool from the Docker people, but it’s not based on Docker. You don’t even need to have Docker installed, because it uses lightweight but secure &lt;strong&gt;microVM containers&lt;/strong&gt;. You can &lt;a href=&#34;https://www.docker.com/blog/why-microvms-the-architecture-behind-docker-sandboxes/&#34;&gt;read more about microVMs here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It could not be easier to use:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-shell&#34;&gt;cd ~/dev/my-project
sbx run claude
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That’s all you need to do. All the hard work is done for you:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A microVM container is started.&lt;/li&gt;
&lt;li&gt;Claude is installed and configured in the container.&lt;/li&gt;
&lt;li&gt;An optional network policy is installed in the container (egress firewall).&lt;/li&gt;
&lt;li&gt;Claude has access to the files in your project, but nothing else on your system.&lt;/li&gt;
&lt;li&gt;When you authenticate Claude, &lt;code&gt;sbx&lt;/code&gt; persists your credentials securely so that you do not need to re-authenticate in every sandbox.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;No &lt;code&gt;Dockerfile&lt;/code&gt; is needed, and the project directory stays clean: &lt;code&gt;sbx&lt;/code&gt; itself doesn’t add or modify any files in your project.&lt;/p&gt;
&lt;p&gt;As if that wasn’t enough:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Within the container, Docker is available. Your AI agent can spin up its own Docker containers. This is the case even though the sandbox itself is not running under Docker.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Running Other Agents, or a Shell&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;sbx&lt;/code&gt; command knows how to run several popular AI agents, including Claude, Codex, Copilot, Cursor, OpenCode, and more. For example, run Codex like this:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-shell&#34;&gt;sbx run codex
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To work directly from a command prompt, start a shell in a container:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-shell&#34;&gt;sbx run shell
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;The Sandbox Lifecycle&lt;/h2&gt;
&lt;p&gt;The workflow could not be simpler, but a valid concern is what residue this leaves behind on a developer’s PC.&lt;/p&gt;
&lt;p&gt;With traditional containers, each project can leave behind Docker-managed resources like containers, images, and volumes. These are large, and over time they can clutter your system and need to be cleaned up.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;sbx&lt;/code&gt; makes this easy to manage with built-in commands to list and delete sandboxes. See &lt;a href=&#34;https://docs.docker.com/ai/sandboxes/usage/&#34;&gt;Usage&lt;/a&gt; for details. There’s another way to manage sandboxes, though, and that’s to run the &lt;code&gt;sbx&lt;/code&gt; command with no arguments. This starts a TUI (a “text GUI”):&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;/static/images/sbx-tui.webp&#34; alt=&#34;The Docker Sandboxes TUI (“text GUI”), showing easy management of multiple sandboxes.&#34;&gt;&lt;/p&gt;
&lt;p&gt;From here you can visually manage, create, activate, or remove sandboxes.&lt;/p&gt;
&lt;h2&gt;No excuses&lt;/h2&gt;
&lt;p&gt;With containerization this easy, there’s no reason to ever run a “naked” AI agent again. There are a handful of similar tools out there: you can use the &lt;a href=&#34;https://github.com/devcontainers/cli&#34;&gt;Dev Container CLI&lt;/a&gt;; or one of many homegrown utilities, like my own &lt;a href=&#34;https://github.com/natesilva/focus&#34;&gt;focus&lt;/a&gt;. Right now, none of them come close to the ease-of-use and smooth developer experience that Docker Sandboxes provides. Try it out and share this with your team today.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Docker Sandboxes &lt;a href=&#34;https://www.docker.com/products/docker-sandboxes/&#34;&gt;https://www.docker.com/products/docker-sandboxes/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
  </entry>
  <entry>
    <title>AI Policy</title>
    <link href="https://natesilva.dev/ai-policy/" />
    <updated>2026-06-10T04:24:00Z</updated>
    <id>https://natesilva.dev/ai-policy/</id>
    <content type="html">&lt;p&gt;The content here is &lt;strong&gt;human-written&lt;/strong&gt; by me 🙋🏻‍♂️, not by AI 🤖.&lt;/p&gt;
&lt;p&gt;That’s because this web site is a way for me to communicate my ideas, findings, and thoughts. It doesn’t feel genuine to have someone else (or something else) write &lt;em&gt;my&lt;/em&gt; thoughts. I use AI tools for research, but the ideas are mine, and the writing is mine.&lt;/p&gt;
&lt;p&gt;At the same time, as a software engineer, I believe that LLMs (AIs) are a powerful tool that engineers can and should use to boost productivity. In my career I’ve been an advocate and helped other engineers adopt these tools. You’ll see this reflected in articles that I post about AI topics that I care about — like Spec-Driven Design or &lt;a href=&#34;/2026/06/the-easy-way-to-run-your-ai-agent-in-a-sandbox/&#34;&gt;agent sandboxing&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;See that em-dash (—) in the previous paragraph? That’s my own. I’m told I write like an AI, but I think that AI writes like me. I was an early contributor to web sites that were later used to train the first generation of AI, including sites like Stack Overflow (where I was in the top 1% of contributors), GitHub, Wikipedia, early Reddit, and more. LLMs learned their style — especially for technical content — from the highest-rated posts and articles on those sites.&lt;/p&gt;
&lt;p&gt;So there you have it: I’m an advocate for using AI in software engineering, but there’s a place for human-written content. This site is mine.&lt;/p&gt;
</content>
  </entry>
</feed>
