Install it, look inside, run your agent
ai-jail is one program with no daemon and no root. You install it, put its name in front of the command you already type, and the agent starts inside a sandbox.
Install
Choose the way you already install command line tools. Every method gives you the same single ai-jail program.
brew tap akitaonrails/tap && brew install ai-jailWorks on macOS and on Linux.
yay -S ai-jail-binyay -S ai-jailThe first package is a prebuilt binary for Linux x86_64. The second builds from source.
cargo install --locked ai-jailNeeds a Rust toolchain. --locked builds with the dependency versions the release was tested with.
nix run github:akitaonrails/ai-jail -- claudenix profile install github:akitaonrails/ai-jailThe first line runs an agent without installing anything. The second installs for your user. The flake points ai-jail at its own copy of bubblewrap.
ai-jail-linux-x86_64.tar.gzai-jail-macos-aarch64.tar.gzThe archives are signed, with checksums next to them. Unpack one and put ai-jail somewhere on your PATH. How to check the signature is on the Security page.
cargo build --release --lockedinstall -Dm755 target/release/ai-jail ~/.local/bin/ai-jailNeeds Rust 1.97.1.
What your system needs
Linux
Install bubblewrap, the small program ai-jail uses to build the sandbox. Most distributions package it as bubblewrap.
pacman -S bubblewrapapt install bubblewrapdnf install bubblewrapmacOS
Nothing to install. ai-jail uses sandbox-exec, which ships with macOS. Apple marks that interface as deprecated.
Windows
Not supported. Use WSL2 and follow the Linux steps inside it.
Your first run
Three commands take you from a plan, to a look inside, to a working agent. ai-jail opens nothing until you ask.

See the plan without running anything
Go to your project and ask for a dry run. ai-jail prints the sandbox command it would use and exits. A dry run never writes a file.
cd ~/Projects/my-appai-jail --dry-run claudeLook around inside
Start a plain shell in the jail. Your project is there at its real path and you can edit it. Your home directory is a fresh, empty one, and your shell's tokens are gone. Type
exitto leave.ai-jail bashRun the agent with the two things it needs
An agent that talks to a cloud model needs the network to reach it, and its own saved login to prove who you are. Both are off by default, so you turn them on:
--networkand--agent-state. Since version 1.22, ai-jail prints a warning naming the missing flag if you start a known agent without one of them.ai-jail --network --agent-state claudeMake it the default for that agent
Put the two settings in
~/.ai-jail, your own config file, under the agent's name. After that the short command is enough. The.ai-jailfile that may appear in the project can only tighten the jail. It can never turn the network or a login on, so a repository you clone cannot open the jail for itself.[commands.claude]network = trueagent_state = true # from now on, in any project:# ai-jail claude
What you will see inside
The prompt changes to (jail) and the project is where it always was. The things worth stealing are missing.
$ ai-jail bash# the project is at its real path(jail) ~/Projects/my-app $ pwd/home/you/Projects/my-app# a token exported in your shell did not come along(jail) ~/Projects/my-app $ echo $GITHUB_TOKEN # your keys are not in this home(jail) ~/Projects/my-app $ cat ~/.ssh/id_ed25519cat: /home/you/.ssh/id_ed25519: No such file or directory# the jail has its own hostname(jail) ~/Projects/my-app $ hostnameai-sandboxThis is a Linux session. macOS has no way to build a separate file tree, so there the same paths exist and reading them is refused.

From inside, the project is the only thing of yours that exists. The network stays outside too until you pass --network.
If it does not start
These are the cases the README's troubleshooting covers, plus the two setup rules people trip on.
bwrap: setting up uid map: Permission denied
Ubuntu 24.04 and later and Debian 13 and later ship an AppArmor policy that stops programs from creating user namespaces without root, which is how bubblewrap isolates the jail. It affects every rootless tool of this kind. Relax it for the whole system:
echo 'kernel.apparmor_restrict_unprivileged_userns=0' \ | sudo tee /etc/sysctl.d/60-userns.confsudo sysctl --systemOr keep the policy and exempt only bwrap. Save this as /etc/apparmor.d/bwrap, then run sudo apparmor_parser -r /etc/apparmor.d/bwrap.
abi <abi/4.0>,include <tunables/global>profile bwrap /usr/bin/bwrap flags=(unconfined) { userns,}Your BWRAP_BIN is refused
You can point ai-jail at a specific bubblewrap with BWRAP_BIN. ai-jail accepts it only when it resolves to a program owned by root that other users cannot write, or to one in a standard multi-user /nix/store. It refuses a copy in your own home, because anyone who can replace that file controls the jail.
mise tools are missing inside
ai-jail activates mise when it finds it, but the fresh home has neither mise's config nor its installed tools, so it skips activation. Map both in, read only, from your own config:
[commands.claude]ro_maps = ["~/.config/mise", "~/.local/share/mise"]Failed to create stream fd at startup
This comes from a login script on Ubuntu desktop during mise setup. It is harmless and mise still works. Pass --no-mise to skip mise setup and the message with it.
ai-jail --no-mise claudePer agent
ai-jail knows where each agent keeps its login. --agent-state mounts only the folders of the agent you start, and only if they exist.
| You run | --agent-state mounts | Good to know |
|---|---|---|
ai-jail claude | ~/.claude~/.claude.json | For a second Claude profile, point --claude-dir at its directory. |
ai-jail codex | ~/.codex | After you resize the window, ai-jail sends Codex a redraw key so the screen repaints. |
ai-jail opencode | ~/.config/opencode~/.local/share/opencode | |
ai-jail gemini | ~/.gemini | |
ai-jail ai-memory run claude | The launched agent's folders | ai-jail recognizes the agent that ai-memory launches and applies that agent's settings, with both programs in one jail. |
The same works for crush, grok, jcode, pi, aider, soulforge, omp and the kimi commands. Any other command runs too. It gets the same jail and no login folder.
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