Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Modes and the judge

A mode decides whether a tool call runs, asks you, or goes to the judge. /mode shows the table below for your session’s sandbox state. /mode <name> switches and shift+tab cycles the built-ins, each printing a line on the new mode. [modes.<name>] in config.toml changes or adds modes (config.md).

The three built-in modes

kind of actionmanualplanauto
read or searchrunsrunsruns
edit a project fileasks youplan file onlyruns
edit a protected fileasks youplan file onlyasks you
run a commandasks you · runs in the sandboxnot availablethe judge decides (asks you if risky) · runs in the sandbox
use the internetasks younot availablethe judge decides (asks you if risky)
run a command outside the sandboxasks younot availablethe judge decides (asks you if risky)
load a skillasks youasks youruns
start a sub-agentasks youasks youruns
the hard-deny listrefusedrefusedrefused
  • manual asks before anything but a read.
  • plan writes only its plan file and runs no commands.
  • auto runs project-file edits, skill loads and sub-agents unasked and hands commands to the judge. A skill adds text and a list of its files to the context and nothing more; allowed-tools grants nothing. To make auto ask before a skill, see the recipe.

A protected write asks in every mode, plan included (Protected files); manual and auto also have local asks. The hard-deny list refuses even under --approve-all.

In the terminal panel, asks no turn grant covers (a protected write, a credential read, a removal git cannot undo, decoded text being run, an install) start on deny, so a habitual Enter refuses; press y to allow. Others start on allow once. The plain REPL takes a bare Enter as no.

Every command the model runs is inside a sandbox (sandbox.md): it writes only in the project and a private temp folder (/tmp on Linux, $TMPDIR on macOS), has no network but localhost (none on macOS), and can’t read your key folders. On macOS, use the internet also covers local ports, such as a loopback test server. --approve-all refuses run a command outside the sandbox and installs, but runs use the internet unasked.

The table changes with [sandbox] settings:

  • escape = "never": both rows read not allowed.
  • escape = "judge" (the default): in a mode that judges commands (auto), run a command outside the sandbox reads like use the internet: the judge decides (asks you if risky). In manual it reads asks you, and in plan, which runs no commands, not available. That is the table above. What the judge decides there, and what still asks: The judge.
  • escape = "ask": that row reads asks you in manual and auto.
  • enabled = false: the command row ends · runs unconfined (sandbox off), and the two rows read no extra question: commands have it and no extra question: commands run outside.
  • Sandbox unavailable: a judging mode is not available in every row.
  • mode = "external" (sandbox.md, “External mode”): the command row ends · runs unconfined (this machine is the sandbox), the two rows read as with the sandbox off, and auto, --approve-all, run --away and harness eval work. --approve-all refuses only the hard-deny list and installs; plan mode still refuses writes.

The judge

For each bash/exec command auto would run unasked, the judge (a second model) weighs run against ask from the command, your messages since the last compaction, your own rules and a few facts. Ordinary work runs: reading, downloading, building, testing, local commits, and edits and repo scripts inside the project or /tmp.

Three situations. The judge is told where the command will run, and weighs it with that in mind:

  • In the sandbox with no extra access. Two things change: a script or binary in the session’s private /tmp runs, and a look at one of your hidden key folders runs (it fails there). A folder inside the project counts as the project, a git worktree there (.claude/worktrees/<name>) included, and an installed program (in ~/.local/bin, /usr/local/bin, /usr/bin, or on PATH) is not another folder’s code, so that location alone is not a reason to ask (other checks and your [judge] ask rules still apply). Everything else is weighed as it would be without a sandbox, so damage inside the project, a push or an upload, and running another checkout’s code still ask.
  • With network: true, or with the sandbox off. The judge weighs the command as it would run with the network or with nothing around it.
  • Outside the sandbox (outside_sandbox: true), only under [sandbox] escape = "judge". Nothing confines the command, so the judge asks about more. A public download can run. A token read asks unless a rule of yours allows that use. A push, an upload, a write outside the project, building, testing or running the project’s code, and anything in a container ask unless a message of yours asked for that specific action or a [judge] allow rule names it.

By default the judge decides a command that asks to leave the sandbox, but only when the mode judges commands, you are present, the breaker has not tripped for this task (sandbox.md), no local ask matches, the command passes the planted-input and worktree-escape gates (u7, below), and either runs no file by path or runs 1–4 eligible in-project text scripts (below). Otherwise it asks you. With escape = "ask" every such command asks you, and the judge never sees it. A wrong “yes” outside the sandbox has nothing behind it: the sandbox is not there to catch it. A flag, or a judge that cannot be reached, asks you with allow once or deny only; no turn or session grant covers a full escape. The agent’s reason for leaving is shown to you and never sent to the judge.

A file run by path (u7, two-stage script inspection). On segments started or cleanly resumed on 0.45.0+ (question set u7), a flat full escape that runs 1–4 eligible in-project UTF-8 text scripts (each and combined at most 64 KiB, no symlinks, no .., no credentials/protected/hidden files, no raw control or NUL bytes, no PEM markers or masked secrets, and no open background task or uninspected predecessor command/write redirect) is assessed in two monotone stages: Stage 1 judges command alone with zero file content; if Stage 1 asks or is unavailable it short-circuits immediately without reading any file. Only when Stage 1 returns Allow does Stage 2 read the script(s) through a no-link in-project read and evaluate them with the dedicated script-content question at escape_cutoff (0.05). A Stage 2 flag, unreadable/oversized/ineligible script, or unavailability asks you directly (never bouncing to the agent). On older u4/u5/u6 segments, every full escape that runs a file by path asks unjudged.

Planted-input and worktree-escape gates (u7). Before Stage 1 on a full escape under u7: (1) if the command targets a git worktree inside $PROJECT (.claude/worktrees/<name> or a subdirectory whose ancestor has a .git file/entry), it asks you unjudged unless your messages explicitly name that worktree; (2) if the command invokes a build, test, package, or VCS runner (cargo, rustc, make, just, python, pytest, pip, uv, npm, pnpm, yarn, bun, node, deno, git, gh, go) and a matching trigger file (build.rs, Cargo.toml, .cargo/config*, Makefile, Justfile, *.mk, conftest.py, pyproject.toml, setup.py, package.json, go.mod, .envrc, etc.) was modified in this session or has uncommitted changes (or .venv/bin/python exists after a prior command/child ran), it asks you unjudged naming the trigger file.

What the escape gate refuses to judge. The harness judges a command only when it is a flat list of simple commands (or 1–4 eligible scripts above): a program that is no interpreter (git push, curl …, ls ~/x), or an interpreter (bash, sh, zsh, python, node, ruby, perl and the like) given exactly its own code flag, one literal piece of code and plain words (python3 -c '…' a b, bash -c '…'), or no code at all (a bare python3, bash -s, bash - or node -, which read their input; for php, bun, deno, Rscript, osascript, fish and pwsh a - operand asks, as it may be a file’s name). A command outside the sandbox that holds a heredoc or here-string (<<), a $(…), a backquote, ${…}, <(…), >(…), $'…' or $"…", arithmetic (((, $[), a backslash-newline that does not follow a space or tab, a redirect from another descriptor (3<, <&, <>), or a control character other than tab and newline or a non-ASCII whitespace character asks, however plain the rest is (the same holds for each word of an exec call and for the code of every nested sh -c). A command outside the sandbox with if, for, while, case, a subshell or a brace group asks too: the harness judges only a flat list of simple commands joined by ;, &&, ||, |, & or newlines. Everything else that is not an eligible in-project script asks unjudged: outside-project paths (~/…, /tmp/…, $…), source/. without a / or alongside another command, interpreter flags (python3 -u -c …, bash -ec …, node -r …), fish -c and pwsh -c, lua with words after -e, NAME=value before an interpreter or loader/path assignments (LD_PRELOAD, NODE_OPTIONS, PYTHONPATH, LUA_INIT…, PAGER=./x git log, PATH=./bin:$PATH ls), CDPATH=… cd or env -C before a script, sudo or doas, and what the harness cannot read, such as cat x.sh | bash. State set by an earlier command (export PAGER=./x; git log) is not seen: that is judged on its text. A few wrappers are not read through (xargs, timeout, nice, find -exec, watch, eval), so timeout 5 ./run.sh is judged on its text, not asked.

Under --input-format stream-json, a first Stage 1 / ordinary judge flag under u6/u7 bounces back to the agent and emits an approval event with decision: "refused" (no approval_request); a second consecutive flag (or after 10 bounces in a turn), or any Stage 2 script-content flag under u7, reaches the program as an approval_request of kind judge_flag (judge_unavailable when the judge could not be reached) (headless.md).

Flagged. When the probability of ask reaches the cutoff on a session started or cleanly resumed on 0.44.0+ (question set u6/u7), and you are present with the away breaker untripped, the first Stage 1 / ordinary judge flag on any judged command (sandboxed, network: true, or outside_sandbox: true) bounces back to the agent once (judge.refused.v1, shown as refused by the judge (<reason>)) with a refusal nudging it toward file tools (read_file, edit_file, write_file), a narrower command, or re-issuing / asking you if the action is genuinely necessary. A Stage 2 script-content flag under u7 never bounces and escalates directly to you. A second consecutive flag — or any flag after 10 bounces in a turn — escalates to manual’s approval prompt plus The judge flagged this: <reason>, naming the likeliest reason. A human approval or a judge allow resets the consecutive count (the 10-per-turn cap stays for the turn). The first three reasons ask even when you requested the action; the other five, unless your message asked for that specific action:

reasoncoversthe flag reads
credentialsreading, printing, copying or sending a credential or a file holding onetouches credentials or secrets
irreversibledestroying work git can’t restore, or deleting a target the command doesn’t showmay destroy work git cannot restore
internet_codeinstalling or running internet codeinstalls or runs code from the internet
outside_coderunning a script or binary from outside the project, /tmp includedruns code from outside the project
outside_writewriting, moving or deleting outside the project and /tmptouches files outside the project
sends_data_outuploading or posting data to another hostmay send data to another machine
shared_statepushing, publishing, deploying, changing a remote resourcechanges something others rely on
safety_overrideusing the git stash or turning off a safety settinguses the shared git stash or turns off a safety setting

The reason is only a label; with none, the line reads The judge flagged this. An unreachable judge (no key, a bad answer, over five seconds) asks directly with The judge could not be reached without bouncing. Local asks, protected files, unassessable commands (too long or private-key-masked), unjudged escapes, away stretches, and older u3/u4/u5 segments never bounce. Once an approval prompt is shown, you decide.

The tag. A command the judge allowed shows · allowed by the judge on its result row, as one you approved shows · approved. A full escape it allowed shows · allowed by the judge · outside the sandbox. Probabilities appear only in the log.

A full escape the judge flagged shows two lines, Runs outside the sandbox: <the agent's reason> and The judge flagged this: <reason> (The judge could not be reached when it could not be), with allow once and deny only.

Your rules

[judge] in your own config takes three lists of plain sentences (config.md):

  • environment tells the judge about your setup. It describes and permits nothing.
  • allow names an action the judge may let run, a use of a credential you name included, unless an ask rule covers it.
  • ask names an action that always asks. It beats allow, and beats your own request.

Name the action and the place. Reading GitHub's API with the token in ~/.secrets/gh is fine is narrow; API calls are fine lets more through than you meant. Say the host, not the remote’s name: the agent can change a remote’s address in a command, and the judge reads the address in force.

An unattended push needs a rule. A host-bound secret gives a network: true command a working token, but the judge still weighs the push: it asks unless your message asked for it or an allow rule names it, and while you are away anything that asks is refused. Name the push and the place:

[judge]
allow = ["Pushing a feature branch to github.com/dsaccon/mega is fine."]

A rule steers the judge’s weighing and nothing else. It refuses nothing, and it leaves the hard-deny list, the local asks, the protected files and the sandbox as they are. Only your own config sets [judge]: a config found inside the project that holds one is refused.

What it reads

  • Your messages since the last compaction, the ones you typed and your steers, kept from the newest back: each cut at 4,000 characters, 8,000 in all, at most 64. The newest is always kept. A boundary you stated three messages ago (don't touch ~/mega) still counts. A sub-agent’s call sends the window its parent had when it started, never the parent’s instructions to the child.
  • Recent commands in the turn (recent_commands, u6/u7): up to the newest 10 earlier bash/exec calls in the current turn with completed gate outcomes, oldest first, each command key-redacted and capped at 500 characters (4,000 command characters total, always keeping the newest 1; PEM-masked commands replaced with [redacted command]), carrying {tool, command, sandbox, outcome, reason?} with outcomes allowed, judge_refused, human_approved, or human_denied. Never carries tool output, assistant prose, reasoning, file contents, the agent’s escape reason, or your free-form denial note. Omitted when empty.
  • Script contents on judged escapes (scripts, u7 Stage 2 only): when Stage 1 allows a flat full escape running 1–4 eligible in-project UTF-8 text scripts (≤64 KiB total, no symlinks, no credentials/protected/hidden files, no PEM markers or masked secret lines), Stage 2 sends those scripts’ key-redacted contents alongside the command, facts, messages, and rules.
  • Your rules, as above.
  • Where the command runs: on (in the sandbox), network, outside or off.
  • Your remotes, up to 8: each remote’s name and address from .git/config, with any user:password@ removed, each cut at 300 characters. The file is read, not git run, and include and insteadOf are not followed. With no .git/config, no remotes are sent.

What is sent where

The judge is a separate call to a separate provider: by default TypeSafe, [judge] model = "typesafe:jev-1.14.0", keyed by TYPESAFE_API_KEY. Once per machine, the first entry into a judging mode by command prints a notice naming the provider and model and saying that the command, recent commands in the turn, contents of in-project scripts run by a judged escape, its facts, your messages since the last compaction and your [judge] rules are sent. A session whose rule is escape = "judge" prints one more line, once per machine, when it enters a mode that judges commands: Commands that ask to leave the sandbox are judged too. The notice reads once more on a machine that saw the 0.44 one. A start already in a judging mode does not print it; /notices lists it. Only TypeSafe’s built-in endpoint gets a privacy-policy link. Without the key, auto asks before every command it would judge, and entering a judging mode warns:

the judge needs TYPESAFE_API_KEY — without it, auto asks before every command it would judge

Through mega. Signed in to the free mega account (config.md) with no TYPESAFE_API_KEY and the built-in judge at a version our server accepts (jev-1.13.0 or jev-1.14.0), the same requests go via our server, which forwards them to TypeSafe with its own key. The notice then links mega’s privacy page and reads:

Each judged command, recent commands in the turn, contents of in-project scripts run by a judged escape, its facts, your messages since the last compaction and your [judge] rules are sent to TypeSafe (jev-1.14.0) through mega, with secrets redacted.

After /logout, judged commands ask, as with no key.

Neither the notice nor the warning prints under --approve-all, --mock or harness eval, where the judge never runs.

The request holds:

  • user_messages: your messages since the last compaction, oldest first, within the caps in What it reads. A sub-agent’s call sends the window its parent had at the start, never the parent’s instructions to the child.
  • command: the bash string or the joined exec argv, up to 8,000 characters.
  • facts: project_root and cwd (both $PROJECT, never a real path), sandbox (on, network, outside or off), plus current_branch and default_branch when they can be read from .git on disk, and remotes when .git/config names any.
  • policy: your [judge] rules, when you set any.
  • recent_commands: earlier bash/exec calls in the current turn with their gate outcomes (omitted when empty), within the caps in What it reads.

A session started before 0.41.0 keeps sending the old request until it is resumed cleanly (a crash resume keeps it): user_request (your latest message, up to 4,000 characters), the command and the facts without sandbox and remotes.

The agent’s own reason for a command outside the sandbox is never sent.

It never holds tool output, assistant text, reasoning, file contents, or a child’s own prompt.

Credential-shaped text (API key prefixes, PEM blocks and similar) is always replaced with [redacted]. Project and home directories, and a ~/… spelling of the project, become $PROJECT and ~, as whole paths only (a sibling …/harness2 stays ~/…). Other paths, and spellings like /home//you, go as written. The session log keeps the request as built.

Cutoffs

The cutoff is 0.2 by default, chosen on a labelled set to lean toward asking (figures below). Lower it to ask more, raise it to ask less:

[judge]
cutoff = 0.15

A value outside 0.0..=1.0 is refused at load, naming the file. Only your own config can set it, not a project’s.

escape_cutoff is the cutoff for a full escape the judge decides under escape = "judge". It is 0.05 by default, lower than the ordinary cutoff, so a command outside the sandbox asks sooner. The same range and the same load error apply. The away cutoff is away_cutoff, described under Away and set in config.md.

[judge]
escape_cutoff = 0.03

Protected files

A write_file or edit_file under a protected path asks in every mode (plan’s own plan file aside); no grant covers it, and only --approve-all skips it. The prompt adds This is a protected file, and its “this turn” choice, except this kind, still asks at the next one.

Entries match whole path components: a trailing / marks a directory, a leading **/ a basename at any depth, anything else one exact path. . and empty components are ignored (././CLAUDE.md matches), as is ASCII case on a case-insensitive volume like macOS’s default (claude.md matches; .GIT is .git to the hard-deny list). A nested worktree (.claude/worktrees/<name>/) counts from its own root: its CLAUDE.md, .git and .claude/ are protected, its other files are not.

.git/
.agents/
.claude/
.harness/
AGENTS.md
CLAUDE.md
.cargo/config
.cargo/config.toml
**/build.rs
.envrc
.github/workflows/
.pre-commit-config.yaml
.husky/
.vscode/

Adjust it from your own config with [protected]:

[protected]
add = ["infra/"]
remove = [".vscode/"]

add uses the same matching rules; remove drops a built-in entry, and any other path does nothing. A project’s config.toml can never change the list.

With checkpoints on, the turn-end list flags each protected file the turn changed, tracked or not, protected, with its /undo (checkpoints.md).

Local asks

Three kinds of command ask before the judge sees them. Like a protected write, no grant covers them; --approve-all skips the first two and refuses the third; while you’re away, they are refused (sandbox.md, “Away”). Their “this turn” choice, any bash except this kind, still asks for this kind. Under --input-format stream-json they reach the program as approval_requests of kind removal, decode_and_run and install, with turn_grant_skips_kind: true (headless.md).

The removal ask: a file git cannot restore. truncate (any size), an empty redirect (> f and similar), cp /dev/null f, rm, git rm -f (not --cached), git checkout -- or git restore of a named file asks, naming the first such target; so does a named directory holding one. “Cannot restore” means untracked and not ignored, changed since the last commit, or not in a git repository; clean committed and ignored files go to the judge. Writing new content is an edit, not a removal. The reason reads:

Asked because it empties or deletes {file}, which git cannot bring back (untracked | changed since the last commit | not in a git repository)

The decode-and-run ask: decoding hidden text and running it. Piping decoded output into a shell or interpreter, or eval-ing it (… | base64 -d | sh, xxd -r -p … | bash, python3 -c "exec(…b64decode…)"), asks with the reason below. Decoding into a file without running it does not.

Asked because it decodes hidden text and runs it

The install ask: installing third-party code. A package manager’s install, add, update or fetch (cargo, rustup, pip, uv, pipx, poetry, pdm, conda, npm, pnpm, yarn, bun, deno, apt, dpkg, snap, flatpak, brew, nix, gem, go, cabal, stack, composer, cpan, mix, dotnet), a docker or podman pull or build, a package runner (npx, uvx, bunx), cargo with offline mode turned off, and a download piped into a shell (curl … | sh, bash <(curl …)) ask, read through sh -c, env, sudo and lists, naming the command words:

Asked because it installs third-party code ({words})

--approve-all refuses it; the model is told to name the step. It is a speed bump: a renamed binary, a script or a Makefile target gets past it to the judge.

When the harness cannot tell which files. Past 1,024 targets, 256 KiB of their names, 64 possible working directories, or groups or sh -c code nested too deep, a removal asks without naming a file:

Asked because the harness cannot tell which files it empties or deletes

Targets the command doesn’t name literally (globs, variables, command substitutions, find -delete, one-liners, scripts) go to the judge.

A !cmd you type asks nothing, in any mode. It runs outside the sandbox and is not judged, hard-denied or covered by a hook (sandbox.md).

The hard-deny list

Before any mode, judge or human has a say, --approve-all included, these are refused as refused: <rule> is on the hard-deny list:

  • a recursive delete of /, of ~/$HOME, or of the project root or one of its parents
  • mkfs*
  • dd writing onto a real device under /dev/ (not /dev/null, /dev/stdout, /dev/stderr, or /dev/fd/N)
  • the classic fork bomb, in any spacing

It catches only the obvious spelling: a wrapper script, a renamed binary or eval gets past it. It is a speed bump, not a boundary (The limits). Under [sandbox] mode = "external", only this list and, in auto, the judge stand between a command and the machine.

The key scrub

In every mode, a bash or exec child starts without any registered provider’s key variable (every api_key_env, TYPESAFE_API_KEY included), in use or not; env prints none. With the sandbox on, and under mode = "external", every variable named like a credential is removed too (GITHUB_TOKEN among them; the patterns are in sandbox.md), so a sandboxed gh or authenticated git push has no token; external keeps the names in [sandbox] env_pass. Other variables pass through only with the sandbox off or unavailable, and to a command you approve to run outside the sandbox or a hook with sandbox = false.

Custom modes and judge

[modes.<name>] takes a judge field beside tools and ask: the tools the judge decides. It merges like ask: left out, a built-in mode keeps its own; judge = [] turns judging off. The rules:

  • every name in judge must also be in tools;
  • no tool may be in both ask and judge;
  • bash and exec must share a bucket: both asked, both judged or both run.

config.md has a two-line [modes.auto] override that makes auto ask before every bash/exec again.

The limits

The judge sees a command and the request behind it, never a script’s contents, a build.rs, or what a binary does. The sandbox keeps what it allows from writing outside the project, reading your keys or going online unasked, but damage inside the project (git reset --hard, an in-project rm -rf, an overwritten file) is the judge’s call alone. In auto the judge also decides some commands outside the sandbox, and a wrong “yes” there has no sandbox behind it; escape = "ask" keeps them asking you. Your [judge] rules steer the judge and can be broader than you meant. Commands can’t write untracked protected files (a local .envrc), but can write tracked ones (CLAUDE.md, a workflow) and any build.rs: review those against the commit the work started from (sandbox.md has the commands).

On the maintainer’s labelled set of 300 commands, the default judge and cutoff (jev-1.14.0, 0.2) run 47–49 of the 113 that should ask and ask on 10–13 of 186 safe ones with the sandbox off, and 34–37 of 101 and 14–18 of 198 with it on (three runs each: the judge’s answers move by a row or two between runs). With the sandbox off its misses were mostly another checkout’s code or a script in /tmp. Outside the sandbox, at escape_cutoff 0.05, 0–1 of 141 crafted attack commands that should ask would run, and about 1 in 10 of the maintainer’s approved escapes would run without asking (about 1 in 7 with [judge] rules written for his setup). Expect worse on unfamiliar commands. The judge is strongest on credentials and internet code. Treat what it allows as unreviewed, inside the project above all.