A jail for your AI coding agent
ai-jail runs Claude Code, Codex and other AI coding agents inside an OS sandbox on Linux and macOS. The project stays writable. Your files and credentials stay out of reach, except for the invoked agent's own login.
ai-jail claudeGive the agent the project, not the whole machine. ai‑jail makes that boundary real.
How a good agent goes wrong
All day the agent reads text you did not write: web pages, issues, READMEs, packages. One page with instructions hidden in it is enough, and the agent does not need to be hostile to follow them.
↔ Swipe sideways to see the full diagram
Your agent runs as you
A coding agent is a program under your user account. So is every script, package and MCP server it starts; an MCP server is a helper program that gives the agent extra tools. All of them can open anything you can open.
Start it through ai-jail
Type
ai-jailin front of the command. The agent starts in its own namespaces, with your project mounted at the same path.Your home is not mounted
The agent gets a fresh, empty home directory. SSH keys (the files that log you in to your servers), cloud credentials, browser profiles and your other projects do not exist in there.
Secrets, network and devices are closed
ai-jail cuts environment variables down to an allowlist, so your shell secrets stay in your shell. The network is closed, except the agent's own API host and, on Linux, the package registries your toolchains fetch from. The Docker socket, the screen and the clipboard are off.
Open what the task needs
Claude Code, Codex, Gemini, Grok and Devin start logged in and reach their own API host. A flag, an option you type after
ai-jail, opens more:--allow-hostadds hosts,--networkopens all of it.
The wall goes around the whole harness
Agents that ship a sandbox put it around the commands the model runs. The agent process, its file tools, its MCP servers and its hooks (scripts the agent runs at set moments) stay outside, under your account. ai-jail starts all of them inside. A prompt asks a person, and a person can be rushed or fooled. A sandbox asks the kernel, the core of the operating system, which gives the same answer every time.
↔ Swipe sideways to see the full diagram
What you get with no configuration
Everything that reaches your machine is off until you turn it on, except the agent's own login, its own API host, your toolchains (on Linux) and their package registries, each with a --no- switch. Writes outside the project land in memory and vanish when the session ends.
Inside the jail
- Your project, read and write, at its real path
- Your toolchains, read only, with a cache the jail owns (Linux)
- The agent's own login, such as
~/.claude, so it starts signed in - A known agent's own API host, and the package registries on Linux
- A fresh home directory and a private
/tmp
Out of reach
~/.ssh,~/.aws,~/.gnupg, browser profiles- Your shell secrets, except the agent's own API key
- Other processes, host IPC,
ptraceandbpf
Off until you ask
--allow-hostfor more hosts,--forward-portfor one local service,--networkfor all of it--ssh,--gpu,--display,--dockerand more
ai-jail is one small program with no daemon and no root. On Linux it builds the walls from kernel features: bubblewrap for the namespaces and mounts, plus Landlock, seccomp and resource limits where the kernel has them. On macOS it translates what the platform supports into a thinner sandbox-exec profile. The agent uses the compilers and runtimes already on your machine, and by default a .ai-jail file inside a repository can tighten the jail and never open it.
Questions people ask first
Does it slow the agent down?
Which agents does it support?
ai-jail bash gives you a shell inside the jail to look around.Does it work on Windows?
My agent needs the internet. Is the jail still useful?
--allow-host adds the hosts you name. With --network on instead, the agent can still only read your project, so your keys and the rest of your home are not there to send. What it can read, it can send, which is why masking secrets inside the project matters. See how to mask them.Is it free?
Put your agent behind bars
ai-jail is a single binary that needs no daemon and no root. You add one word in front of the command you already run.
brew tap akitaonrails/tap && brew install ai-jailai-jail claude