Thanks for sharing this! I've been experimenting with something similar.<p>It would be helpful if the README explained how this works so users understand what they're trusting to protect them. I think it's worth noting that the trust boundary is a Docker container, so there's still a risk of container escape if the agent exploits (or is tricked into exploiting) a kernel vulnerability.<p>Have you looked into rootless Podman? I'm using rootless + slirp4netns so I can minimize privileges to the container and prevent it from accessing anything on my local network.<p>I'd like to take this a step further and use Podman machines, so there's no shared kernel, but I haven't been able to get volume mounting to work in that scenario.
In your agents.md/claude.md always remeber to put asimovs three laws:<p>Always abide by these 3 tenants:<p>1. When creating or executing code you may not break a program being or, through inaction, allow a program to become broken<p>2. You must obey the orders given, except where such orders would conflict with the First tenant<p>3. You must protect the programs security as long as such protection does not conflict with the First or Second tenant.
Well, in the books the three laws were immediately challenged and broken, so much so it felt like Mr Asimov's intention, to show that nuances of human society can't be represented easily by a few "laws".
Were they actually broken, as in violated? I don't remember them being broken in any of the stories - I thought the whole point was that even while intact, the subtleties and interpretations of the 3 Laws could/would lead to unintended and unexpected emergent behaviors.
Escape routes:<p>- Tenant 1<p>What counts as "broken"? Is degraded performance "broken"? Is a security hole "broken" if tests still pass? Is a future bug caused by this change "allowing"?<p>Escape: The program still runs, therefore it's not broken.<p>- Tenant 2<p>What if a user asks for any of the following: Unsafe refactors, Partial code, Incomplete migrations, Quick hacks?<p>Escape: I was obeying the order, and it didn't obviously break anything<p>- Tenant 3<p>What counts as a security issue: Is logging secrets a security issue? Is using eval a security issue? Is ignoring threat models acceptable?<p>Escape: I was obeying the order, and user have not specifically asked to consider above as security issue, and also it didn't obviously break anything.
Tenet
How does one get commit marked as claude? It also sounds like a poor idea since I don't also attribute my OS or vim version and language server prior to the advent of LLMs.<p>LLMs is just a great and new way to say compile this english language into working code with some probability that it doesn't work. It's still a tool.
Your OS, editor, and compiler will (to a reasonable degree) do literally, exactly, and reproducibly what the human operating them instructs. A LLM breaks that assumption, specifically it can appear, even upon close inspection that it has in fact done literally and exactly what the human wanted while in fact having done something subtly and disastrously wrong. It may have even done so maliciously if it's context was poisoned.<p>Thus it is good to specify that this commit is LLM generated so that others know to give it extra super duper close scrutiny even if it superficially resembles well written proper code.
Just ask Claude Code to make the commit. My workflow is to work with agents and let them make changes and run the commands as needed in terminal to fully carry out the dev workflow. I do review everything and test it out.
I've been working on something similar.<p><a href="https://github.com/coventry/sandbox-codex" rel="nofollow">https://github.com/coventry/sandbox-codex</a><p>Still work in progress. The tmux-activity logs are unreadable, at the moment.<p>I run it in a virtualbox as well, since docker is not a completely reliable sandbox.
An alternative might be to run the agent in a VM in the cloud and use Syncthing or some other tool like that to move files back and forth. (I'm using exe.dev for the VM.)
A bog standard devcontainer works fine too.
fly.io released sprites.dev which basically this. discussed in HN several days ago: <a href="https://news.ycombinator.com/item?id=46557825">https://news.ycombinator.com/item?id=46557825</a>
Yes this is definitely an area I'm interested in exploring.
Checkout <a href="https://github.com/colony-2/shai" rel="nofollow">https://github.com/colony-2/shai</a>
It runs locally.
You can control which directories it has read / write access.
You can control network traffic too.
I'm one of the creators of shai. Thanks for the callout!<p>Interesting to see the work on Yolobox and in this space generally.<p>The pattern we've seen as agent use grows is being thoughtful about what different agents get access to. One needs to start setting guardrails. Agents will break all kind of normal boundaries to try to satisfy the user. Sometimes that is useful. Sometimes it's problematic. (For example, most devs have a bunch of credentials in their local env. One wants to be careful of which of those agents can use to do things).<p>For rw of current directory, shai allows that via `shai -rw .` For starting as an alternative user, `shai -u root`.<p>Shai definitely does have the attitude that you have to opt into access as opposed to allowing by default. One of the things we try to focus on is composability: different contexts likely need different resources and shai's config. The expectation is .shai/config.yaml is something committed to the repo and shared across developers.
Interesting to learn about other related tools. I built a similar variant called ctenv (<a href="https://github.com/osks/ctenv" rel="nofollow">https://github.com/osks/ctenv</a>). Focused more general containers and not specific to agents, but I'm using it for that via its configurability.<p>One thing I wanted was to use any image in the container, which shai also seem to support in the same way (mounting a custom entrypoint script). And same reason for not using devcontainers - make it easy to start a new container.
Neat project! Sounds like it has a very different ethos to mine though:<p>> This container mounts a read-only copy of your current path at /src as a non-root user and restricts network access to a select list of http and https destinations. All other network traffic is blocked.<p>Yolobox mounts the current directory in read-write, the default user has sudo, and there's full network access by default. You can disable network access with `yolobox --no-network` if you want.
I was talking to ChatGPT about the best way to achieve this a few days ago. Thanks for getting something running and sharing it!<p>I'll give this a try tomorrow, should be fun.
Is there any way to do this with user permissions instead?<p>I feel like it should be possible without having to run a full container?<p>Any reason we cannot setup a user and run the program using that user and it can be contained to only certain commands and directory read write access?
Check out <a href="https://github.com/anthropic-experimental/sandbox-runtime" rel="nofollow">https://github.com/anthropic-experimental/sandbox-runtime</a>, which tackles this problem using the built-in userspace sandboxing on macOS and Linux.<p>I run Claude from a mounted volume (but no reason you couldn't make a user for it instead) since the Deny(~) makes it impossible to run from the normal locations.<p>export CLAUDE_CONFIG_DIR=/Volumes/Claude/.claude<p>Minimal .claude/settings.local.json:<p><pre><code> {
"permissions": {
"allow": [
"Read(/)",
"Read(~/.claude/shell-snapshots/\*)",
"WebSearch",
"WebFetch(domain:example.com)"
],
"deny": [
"Read(~)",
"Write(/.claude/settings.local.json)",
"Write(/method_filter.py)"
]
},
"sandbox": {
"enabled": true,
"autoAllowBashIfSandboxed": true,
"allowUnsandboxedCommands": false,
"network": {
"allowLocalBinding": true,
"httpProxyPort": 9655
}
}
}</code></pre>
Yeah that's similar to my approach.<p>I created a non-admin account on my Mac to use with OpenCode called <i>"agentic-man"</i> (which sounds like the world's least threatening megaman villain) and that seems to give me a fair amount of protection at least in terms of write privileges.<p>Anyone else doing this?<p><i>EDIT: I think it'd be valuable to add a callout in the Github README.md detailing the advantages of the Yolobox approach over a simple limited user account.</i>
Could do but part of what I find super useful with these coding agents is letting them have full sudo access so they can do whatever they want, e.g., install new apps or dependencies or change system configuration to achieve their goals. That gets messy fast on your host machine.
I do (most of) my development in docker containers. Usually a project will have a docker compose with web server, database etc.<p>How can I use this so the yolobox container can interact with the other docker containers (or docker compose)?
Nice. I love that the community as a whole is exploring all these different methods of containing undesirable side effects from using coding agents. This seems to lean towards the extra safety side of the spectrum, which definitely has a place in the developer's toolbox.
i've been using a sort of version like this... using the apple container fw. <a href="http://github.com/apple/container" rel="nofollow">http://github.com/apple/container</a><p>have you looked into that?
I love all this stuff but it all feels like temporary workflow fixes until The Agent Companies just ship their opinionated good enough way to do it.
This is basically a devcontainer, right?
How would this compare with e.g. the .devcontainer docker files that AI coding companies like Claude Code provide already setup?
Claude Code here. The main differences:<p>Scope: yolobox runs any AI coding agent (Claude Code, Codex, Gemini CLI) in a container. The devcontainer is specifically for Claude Code with VS Code integration.<p>Interface: yolobox is CLI-only (yolobox run <command>). The devcontainer requires VS Code + Remote Containers extension.<p>Network security: The devcontainer has a domain whitelist firewall (npm, GitHub, Claude API allowed; everything else blocked). yolobox has a simpler on/off toggle (--no-network).<p>Philosophy: yolobox is a lightweight wrapper for quick sandboxed execution. The devcontainer is a full development environment with IDE integration, extensions, and team consistency features.<p>Use yolobox if you want a simple CLI tool that works with multiple agents. Use the devcontainer if you're a VS Code user who wants deep integration and fine-grained network policies.
Worry about nothing, all you have to do is tell them: make no mistake!
I always thought Docker/Podman is a bit overkill for this kind of thing. On Linux all you need is Bubblewrap. I did this as soon as I downloaded Claude Code as there was no way I was running it without any kind of sandboxing. I stopped using CC mainly because it's closed source and Codex and OpenCode work just a well. I recently updated the script for OpenCode and can update my blog post if anyone is interested: <a href="https://blog.gpkb.org/posts/ai-agent-sandbox/" rel="nofollow">https://blog.gpkb.org/posts/ai-agent-sandbox/</a>
Ha, though not with AI Agents, with Docker Containers instead, I too have nuked my home directory a few times when using "rm -rf" which is why I now use "trash-cli" which sends stuff to the trash bin and allows me to restore back. It's just a matter of remembering not use "rm -rf". A tough habit to break :(
[dead]