Recipes
Practical examples for common jai setups. All examples assume you have already run jai --init.
Claude Code
Install Claude Code in its own jail
curl -fsSL https://claude.ai/install.sh | jai -D -mstrict -n claude bash-Dsuppresses granting the current directory (you're installing, not coding)-mstrictuses strict mode with a separate user ID-n claudecreates a named jail calledclaude- The installer runs inside the jail and writes to
$HOME/.jai/claude.home
Run Claude Code from that jail
If $HOME/.local/bin is already on your PATH:
jai -n claude claudeOtherwise:
PATH=$HOME/.local/bin:$PATH jai -n claude claudeMake jai claude use the claude jail by default
Create $HOME/.jai/claude.conf:
conf .defaults
name claude
# Mode already defaults to strict for named jails
mode strict
command PATH=$HOME/.local/bin:$PATH "$0" "$@"Now you can simply run:
jai claudejai will find claude.conf, use the claude jail in strict mode, and prepend the install path to PATH.
Codex
Run Codex in casual mode
If Codex stores configuration in ~/.codex, expose that directory so settings persist across jail invocations:
jai -d ~/.codex codexMake jai codex do this by default
Create $HOME/.jai/codex.conf:
conf .defaults
mode casual
dir .codexNow jai codex automatically exposes ~/.codex.
OpenCode
Run OpenCode in casual mode
OpenCode uses two directories for state:
jai -d ~/.config/opencode -d ~/.local/share/opencode opencodeMake jai opencode do this by default
Create $HOME/.jai/opencode.conf:
conf .defaults
mode casual
dir .config/opencode
dir .local/share/opencodePython virtualenv
Run Python with a jailed virtualenv
Create $HOME/.jai/python.conf:
conf default.conf
mode strict
dir venv
name python
command source $HOME/venv/bin/activate; "$0" "$@"Now jai python enters strict mode, exposes the venv directory, activates the virtualenv, and runs whatever Python command you provide.
Multiple named jails
Named jails let you isolate tools from each other. Each gets its own home directory:
jai -n claude claude # strict jail named "claude"
jai -n codex codex # strict jail named "codex"
jai -n scratch bash # strict jail named "scratch"Each jail has independent state:
- Strict/bare home:
$HOME/.jai/<name>.home - Casual overlay changes:
$HOME/.jai/<name>.changes - Private tmp:
/run/jai/$USER/tmp/<name>
Cleanup and reset
Tear down all jails
jai -uThis unmounts all overlay directories from /run/jai, cleans up .work directories, and destroys private /tmp and /var/tmp contents. Run this when:
- You want to start from scratch
- You changed
--maskoptions in a config file (masks are only applied when the overlay is first created) - You need to edit files in
$HOME/.jai/*.changesdirectly - Overlay mounts are behaving strangely
Recover changes from casual mode
If jailed software modified config files in your home directory, you'll find those changes in:
$HOME/.jai/default.changes/(Or $HOME/.jai/<name>.changes/ for named jails.)
To move these changes into your real home:
- Run
jai -uto unmount the overlay - Copy the changed files from the
.changesdirectory to your home - Re-run
jai— optionally adding-dflags for directories the tool needs to write to directly