Exit codes
Every exit code of every shellfirm command, for scripts, CI and hook integrations.
All commands use 0 for success and 2 for a usage error (a bad flag, a bad
value, a missing --config-dir directory). The other codes depend on the
command.
shellfirm check
Without --exit-code or --fail-on, check exits 0 whenever it could
answer, whatever the decision.
| Code | Meaning |
|---|---|
| 0 | Allowed: nothing risky matched (or below --fail-on) |
| 1 | Error: empty, unreadable or malformed input (also --stdin with {"command": ""}), internal failure |
| 2 | Usage error (also an empty or whitespace-only -c, and an unknown group in --list -g) |
| 10 | Risky: needs human confirmation (decision ask) |
| 11 | Blocked (decision deny). Deny-listed commands exit 11 whatever --fail-on says (78 instead with --strict when the configuration has problems). |
| 74 | The result could not be written to stdout (for example, a full disk) |
| 78 | --strict: the settings, custom checks or an applicable policy have errors or warnings. Replaces 10 / 11, also for a deny-listed command. |
--fail-on compares the severity after context escalation: as root or
with a production environment variable, a Medium match counts as High. See
Results that depend on the runner.
Details: shellfirm check.
shellfirm check --hook (agent hooks)
| Code | Meaning |
|---|---|
| 0 | Always, when the answer was written. The decision is in the JSON answer, in the agent's own protocol. |
| 2 | Windsurf: the action is blocked (the reason is on stderr). Every agent: the answer could not be written, which blocks the tool call in every agent but Cline (its hook script answers {"cancel": true} for shellfirm). |
The old 0.3.10 hook line (check --stdin --format json --exit-code) still
works. On that exact command line, input it cannot use (broken JSON, empty
stdin) exits 2, the only code that blocks a Claude Code hook.
shellfirm pre-command (shell hooks)
| Code | Meaning |
|---|---|
| 0 | Allowed: no risky check matched, or the challenge was passed |
| 3 | Allowed after a passed challenge. Only when the caller sets SHELLFIRM_SIGNAL_PROMPTED=1 (the shell hooks do, per call) |
| 65 | Challenge cancelled or failed. With --test: would need a challenge |
| 74 | No terminal to prompt on; the command is blocked (fail closed) |
| 77 | Denied by your deny list or a policy. With --test: would be denied |
The shell hooks treat any other non-zero code as "do not run the command". Details: shellfirm pre-command.
shellfirm policy validate
| Code | Meaning |
|---|---|
| 0 | Valid |
| 2 | Usage error (a bad flag or --format) |
| 65 | Invalid, or applied with errors (or warnings with --strict; also when FILE is a directory) |
| 66 | No policy file found, or FILE does not exist |
| 74 | The result could not be written |
Details: shellfirm policy.
shellfirm audit replay
Without --fail-on, audit replay exits 0 whatever it found.
| Code | Meaning |
|---|---|
| 0 | Done (with --fail-on: nothing at or above that decision was found) |
| 2 | Usage error, also an invalid or future --since, or an empty --project or one that is not a directory |
| 10 | --fail-on ask: an ask was found (and no deny) |
| 11 | --fail-on deny or ask: a deny was found |
| 66 | --fail-on, nothing found at or above that decision, but a transcript file or directory (the agent's folder, such as ~/.claude, included) could not be read, or a compressed Codex rollout in the window was not read: … the replay is incomplete on stderr, so an unreadable source never passes silently |
Findings are counted after --min-severity and before --limit. Details:
Replay agent sessions.
shellfirm audit show
An invalid or future --since exits 2, as for audit replay.
shellfirm doctor
| Code | Meaning |
|---|---|
| 0 | Nothing is wrong (warnings may still be listed). Also on a machine with AI-agent hooks in order and no shell hook at all (the shell findings are warnings there) |
| 1 | A check failed: commands typed in this shell may run unchecked |
| 64 | Usage error (for example, the shell could not be detected) |
Details: shellfirm doctor.
shellfirm config
| Code | Meaning |
|---|---|
| 0 | Done |
| 2 | Usage error: a bad value (config impact-budget abc, config impact-budget 9000, config challenge Foo) or an unknown check id or group. Nothing is written. |
| 78 | The settings file is invalid, so the setter refuses to change it. Fix it with shellfirm config edit or shellfirm config reset. |
$ shellfirm config impact-budget abc; echo $?
shellfirm: error: invalid impact budget 'abc': give milliseconds from 0 (off) to 5000, e.g. `shellfirm config impact-budget 400`
2Other commands
init, status, connect, sandbox, audit, mcp, wrap and completions exit 0
on success and 2 on a usage error. An error such as an unwritable file exits
1 (for example shellfirm connect when it cannot write the agent's settings
file, and connect --scope project or sandbox --scope project|local when a
settings file or a directory on its path is a symlink out of the project).
shellfirm audit clear without a terminal and without --yes refuses and
exits 64:
Refusing to delete the audit log without confirmation. Re-run in a terminal, or pass --yes.What changed in 0.4.0
checkandpolicy validate: 74 when the result cannot be written.check --strict: 78 replaces the decision's 10 / 11.pre-command: 3 after a passed challenge (only withSHELLFIRM_SIGNAL_PROMPTED=1), and 74 when there is no terminal.- Usage errors in
configsetters exit 2, like every other usage error.
Do not use $? after a blocked interactive line
In bash, zsh and fish, $? ($status in fish) after a line that shellfirm
blocked or you cancelled is still the previous command's status. The line
never ran, and a key binding cannot set the status. nushell sets
$env.LAST_EXIT_CODE = 1. The line is kept in the editor instead (Ctrl-U
clears it).
Scripts and CI should call shellfirm directly and read its exit code:
shellfirm check -c "$CMD" --exit-code # 10 = ask, 11 = deny
shellfirm check -c "$CMD" --fail-on high # non-zero only for High and Critical (after context escalation)
shellfirm policy validate --strict # 65 on any problem