Skip to content

Modes

jai has three execution modes. Each trades off convenience, confidentiality, and compatibility differently. All three modes use a private PID namespace, so jailed processes cannot kill or ptrace anything outside the jail.

Casual mode

The default for unnamed jails. Think of casual mode as "easy integrity protection."

bash
jai codex          # casual by default
jai -mcasual codex # explicit
  • Your home directory is mounted as a copy-on-write overlay. The jailed process sees your real files, but writes go to $HOME/.jai/default.changes instead of modifying originals.
  • Your current working directory has full read/write access (unless suppressed with -D).
  • /tmp and /var/tmp are private.
  • The rest of the filesystem is read-only.

Casual mode does not protect confidentiality. The jailed process runs as your user and can read most of your files. It is designed to prevent easy filesystem damage, not to hide secrets.

You can hide specific files with the --mask option or by deleting them from the overlay home at /run/jai/$USER/*.home.

Strict mode

The default for named jails. Think of strict mode as "a real confidentiality step-up."

bash
jai -n claude claude          # strict by default (named jail)
jai -mstrict codex            # explicit
  • The process runs as the unprivileged jai system user, not as you.
  • Home directory is an empty private directory at $HOME/.jai/<name>.home.
  • Granted directories (via -d or cwd) are exposed with id-mapped mounts — files look like they are owned by jai inside the jail.
  • Because the process has a different UID, it cannot read files that are only accessible to your user — this is where confidentiality comes from.

Strict mode requires the jai system user to exist. It does not work with NFS filesystems, because NFS does not support id-mapped mounts.

Bare mode

A compatibility fallback. Bare mode exists for systems where strict mode is not available — primarily NFS-backed home directories.

bash
jai -mbare codex
  • Home directory is an empty private directory, like strict mode.
  • But the process runs as your user, not as jai.
  • This means it cannot provide confidentiality — the process can still read any file accessible to your UID outside the home directory.

Use bare mode when you need strict-like home isolation but your filesystem does not support id-mapped mounts.

Default mode selection

ScenarioDefault mode
No -n flag (unnamed jail)Casual
-n flag and jai user existsStrict
-n flag but no jai userBare (fallback)

You can always override with -m casual, -m strict, or -m bare.

Comparison

CasualStrictBare
Home directoryCopy-on-write overlay of your real homeEmpty private homeEmpty private home
Process UIDInvoking userUnprivileged jai userInvoking user
ConfidentialityWeak — jailed code reads your filesStrong — separate UID blocks accessWeak — same UID as you
IntegrityOverlay captures writes; originals safeFull isolation; empty homeFull isolation; empty home
NFS supportYesNo (id-mapped mounts unsupported)Yes
PID namespacePrivatePrivatePrivate
Best use caseQuick sandboxing, casual coding helpMulti-tool isolation, API key separationNFS home directories

Which mode should I use?

  • Casual if you want the least friction and mostly care about preventing agents from clobbering files. This is the right default for quick interactive work.
  • Strict if you are jailing multiple tools that should not see each other's credentials, or if you want to meaningfully limit what the jailed process can read.
  • Bare if you need strict-like home isolation but your home directory is on NFS.

If none of these are sufficient — if you need real multi-tenant isolation or defense against a determined attacker — use a proper container or VM. See the Security Model for more.

Stanford SCS