Skip to content
$ shellfirm

Upgrading from 0.3.10 to 0.4.0

The steps to take after upgrading, and what changed in shellfirm 0.4.0.

shellfirm 0.4.0 is a large release. Project and org policies are now enforced, the AI-agent hooks cover more tools and fail closed, the parser follows far more shell forms, and every command reports problems instead of hiding them.

Upgrading the package (npm, Homebrew, cargo) only replaces the binary. shellfirm does not migrate a 0.3.10 setup by itself: follow the checklist once.

Already on 0.4.0?

0.4.1 is a bug-fix release with no checklist: upgrade the package. The shell hooks did not change (HOOK_VERSION is still 14). It asks less often for routine commands (git merge --no-ff, stash pop, worktree add, rm -rf node_modules, real dry runs, chmod 600 .env, read-only forms), and the AI-agent hooks no longer ask when shellfirm's settings or hook text only appears as data. It adds three checks (docker:compose_rm_volumes, database:side_effect_function, psql:client_file_write) and widens two (gh gist create|edit of a secret file, lvreduce). See What is new in 0.4.1.

Upgrading from 0.4.1 to 0.4.2

No checklist is needed: upgrade the package. If you connected Windsurf or Cline, re-run shellfirm connect windsurf / shellfirm connect cline: they used to register the MCP server only, and now also install a blocking hook (your MCP entry is kept; --mcp-only keeps the old behaviour). For Cline, turn on Enable Hooks in its VS Code settings. In both, risky commands are blocked rather than asked, because their hooks cannot ask. If you connected Cursor, Gemini CLI or Qwen Code, re-run shellfirm connect cursor / gemini / qwen too: running connect again upgrades shellfirm's entries in place, which adds Cursor's beforeReadFile hook (reads of private keys and credential files) and the read_many_files matcher of Gemini CLI and Qwen Code. New in this release: blocking hooks for Codex CLI, Gemini CLI, Qwen Code, Copilot CLI and OpenCode, shellfirm sandbox, shellfirm audit replay, and 31 new checks (see What is new in 0.4.2).

Upgrading from 0.4.2 to 0.4.3

0.4.3 is a bug-fix release with no checklist: upgrade the package. Two checks are new (fs:interpreter_delete_home, terraform:piped_yes_approve), an AI agent can no longer turn off the audit log or the agent protection with shellfirm config set (it is denied, not asked), and shellfirm check -c "" is now a usage error (exit 2) instead of "nothing risky". If a CI step checks a variable that can be empty, make sure it is set. See What is new in 0.4.3.

Who is affected

WhoWhat breaksFix
CI jobs, git hooks and scripts that run shellfirm check --exit-codeA risky command now exits 10 (ask) or 11 (deny); 2 is a usage error (0.3.10: 2 = risky). A gate that fails only on exit 2 lets every risky command throughFail on any non-zero exit, or use --fail-on (step 4)
Everyone who changed a setting with 0.3.xThe settings file lists the 0.3 check groups, so the new default groups shell (curl … | bash) and exfil stay offRun the command shellfirm status prints (step 5)
elvish, xonsh and nushell usersThe hook 0.3.10 pasted into the rc file does not protect you (a risky command runs)shellfirm init <shell>, answer y (step 2)
Claude Code usersThe hook no longer auto-approves safe commands (ls), so Claude Code's own permission rules decide. Risky commands are still deniedIntended. Add allow rules in Claude Code for commands you trust
Agent users (Claude Code, Cursor)The 0.3.10 hook keeps working, but PowerShell, Monitor and file edits are not checkedshellfirm connect <agent> (step 3)
Teams with a .shellfirm.yaml or org policyPolicies now win over personal ignores, disabled_groups and min_severityIntended. Change the policy, not your ignores (policies)
Scripts that read check output or JSONThe text report is on stdout (was stderr); JSON allowed is true only for decision: allowRead stdout; key on decision (JSON)

Everyone else only restarts their terminals.

Checklist

StepDo thisWhy
1Restart your shells (exec $SHELL, or open new terminals)The shell hooks changed (HOOK_VERSION 14)
2elvish, xonsh, nushell: shellfirm init <shell>, answer yReplaces the 0.3.10 hook pasted into the rc file
3Re-run shellfirm connect <agent>Upgrades the agent hook in place: more matchers, fail closed
4Fix CI gates that test for exit code 2Risky commands now exit 10 / 11
5Run the shellfirm config groups --enable … command that shellfirm status printsTurns on the new default groups shell and exfil
6Run shellfirm doctor in a new shellConfirms commands really go through shellfirm

Upgrading a team or a fleet? See Rolling out to a team → Upgrades for pinning, re-running init and connect as each user, and checking every machine.

Upgrade steps

Restart your shells

The shell hooks changed (HOOK_VERSION 14). In bash, zsh, fish and Oils a new shell picks them up automatically, because the hook line in your rc file (eval "$(shellfirm init <shell>)", shellfirm init fish | source) loads the current hook each time. A shell that was open during the upgrade keeps running the 0.3.10 hook. It still checks commands, but shellfirm doctor in it reports [XX] session … has NOT loaded the shellfirm hook. Restart that shell (or open a new terminal):

exec $SHELL

Re-running shellfirm init is safe: it changes nothing that is already up to date.

# in a typed line

In zsh without setopt interactivecomments (the zsh default; oh-my-zsh turns it on) and in bash with shopt -u interactive_comments, # in a typed line is not a comment but an argument. It is now checked as one, so a line with a # may be prompted.

elvish, xonsh and nushell: replace the pasted hook

0.3.10 pasted the whole hook into the rc file (rc.elv, .xonshrc, config.nu), and that hook does not protect you: elvish reports Multiple parse errors in ~/.config/elvish/rc.elv, nushell nu::shell::column_not_found, and in xonsh the command runs after you cancel the challenge. shellfirm status still says installed for these shells.

Run shellfirm init <shell> and answer y (to Modify this file?, or to Also add the hook for: nushell, elvish, xonsh? when you run plain shellfirm init). It replaces the pasted hook with a loader line. Then restart that shell.

A hook you saved to a file by hand is not seen by init: generate the file again instead. See Add the hook by hand.

Re-run shellfirm connect for each agent

Run it once for every agent you connected (claude-code, cursor, …):

shellfirm connect claude-code
shellfirm connect cursor

It upgrades the hook in place and writes a backup first. For Claude Code it adds the Bash|PowerShell|Monitor and Write|Edit|MultiEdit|NotebookEdit matchers, "timeout": 30 and "onFailure": "block" (fail closed). Cursor gains a preToolUse hook only this way.

The 0.3.10 hook line keeps working until you do this, and shellfirm status reports it as a legacy hook (legacy hook: re-run `shellfirm connect` to upgrade). Restart running agent sessions afterwards.

Claude Code no longer auto-approves safe commands

The 0.3.10 hook answered "permissionDecision": "allow" for a safe command such as ls -la, which skipped Claude Code's own permission prompt. Now the hook prints nothing for a safe command, so Claude Code's permission rules decide whether it asks you. Risky commands are still denied. Add allow rules to Claude Code's permissions for commands you trust.

Cursor shows fail-closed no

That is expected. Cursor's failClosed treats shellfirm's silent answer for a safe command as a failure and would block every command, so connect cursor leaves it off (and removes it from older shellfirm hooks). If the Cursor hook itself fails or times out, Cursor runs the command. Claude Code does the same for a hook connected with --no-fail-closed (for Claude Code before 2.1.295).

See Claude Code and Cursor and other agents.

shellfirm check prints its report on stdout

It used to print on stderr. Scripts that read the text from stderr should read stdout, or use --format json. Warnings and errors still go to stderr.

Check the new exit codes

A risky command now exits 10 (ask) or 11 (deny), and 2 is a usage error (0.3.10: exit 2 for a risky command). A gate that tests for exit 2 lets every risky command through. Test for any non-zero exit, or use --fail-on:

# before (0.3.10)
shellfirm check -c "$cmd" --exit-code; [ $? -eq 2 ] && exit 1
# after (0.4.0)
shellfirm check -c "$cmd" --exit-code || exit 1      # ask or deny
shellfirm check -c "$cmd" --fail-on high || exit 1   # High and above (a deny always fails)

Other new exit codes:

CommandNew exit codeMeaning
check, policy validate74The result could not be written (for example a full disk)
check --strict78Your settings, custom checks or an applicable policy have errors or warnings. It replaces the decision's 10 / 11
pre-command3Allowed after a passed challenge, only when the caller sets SHELLFIRM_SIGNAL_PROMPTED=1
pre-command74No terminal to ask on: blocked (fail closed)
config setters2A usage error (config impact-budget abc, config challenge Foo, an unknown check id), like every other usage error

The shell hooks set SHELLFIRM_SIGNAL_PROMPTED for each call (bash, zsh, fish, elvish) and accept exit 3 in every shell. Do not export SHELLFIRM_SIGNAL_PROMPTED in your shell profile or environment.

The full tables are in Exit codes.

Turn on the new default groups

Settings saved by 0.3.x list the check groups of that time in enabled_groups (its setters wrote the whole file), so the groups added since, shell (curl … | bash) and exfil, stay off. shellfirm status shows them with the command to enable them:

Output
Not enabled:         docker, exfil, shell (default groups; enable: `shellfirm config groups --enable docker --enable exfil --enable shell`)

shellfirm doctor repeats it as [!!] groups. A group you disabled yourself (docker here) is listed too: leave it out of the command. See Check groups.

New settings and defaults

The settings file stays sparse, so no migration is needed.

  • approved_notice (default on) prints ✓ approved — running: <command> after a passed challenge. Change it with shellfirm config approved-notice on|off. See Challenges.
  • blast_radius_budget_ms (default 400, at most 5000) is the total time spent measuring a command's impact before the prompt. Change it with shellfirm config impact-budget <ms>. 0 turns the measurement off. It is the one switch: the settings editor toggle writes it too, and a non-zero budget clears an older blast_radius: false. See Blast radius.
  • shellfirm status and shellfirm config show show both.
  • Before a slow measurement you may briefly see shellfirm: checking impact… (Ctrl-C cancels) (or shellfirm: checking <file>… while a SQL file is read). It is erased before the banner and never shown under TERM=dumb.
  • The shell check group is on by default for fresh installs (an upgraded settings file: see Turn on the new default groups). It covers remote scripts: curl … | bash and a downloaded script run on the same line. A curl … | sh install line now asks first. Download the script, read it, and run it in a separate command, or approve the prompt.
  • New checks prompt where 0.3.10 was silent. Among them: migration and ORM resets, MySQL DELETE IGNORE, SET SQL_SAFE_UPDATES = 0, Supabase, Firebase, Cloudflare D1 / KV / R2, Neon, PlanetScale, Turso and Railway deletes, SQL run through heroku run / heroku pg:psql --command / fly ssh console -C, terraform apply <planfile>, and disk tools on cloud device names (mkfs -t xfs /dev/xvdf). A CI job that runs check --fail-on high may now fail on them.
  • A SQL file over about 6 MB given to a client (psql -f F) can be Medium (database:sql_from_file, took too long to check) at the default 400 ms budget instead of its real severity. Raise the budget (shellfirm config impact-budget 2000) or run the client through shellfirm wrap.

JSON consumers

  • check --format json has "allowed": true only for decision: allow. Key on decision. schema_version is 2.
  • The new keys version, shell, not_applied and skipped_missing_paths are additive.
  • Audit records are schema_version: 4 (new version field). Older records stay readable.

See shellfirm check and Audit log format.

shellfirm init --yes sets the Balanced level

When your settings do not choose a level, init --yes now sets the recommended Balanced level (min_severity: Medium). init --uninstall removes that default file again when it removes the last hook; settings you chose are kept.

Project and org policies are enforced

Your personal ignores (ignores_patterns_ids), min_severity and a lower challenge no longer weaken a check that a project or org policy enforces. Run this in each repository that has a .shellfirm.yaml:

shellfirm policy validate

It shows problems and what the policy enforces. See Team policies.

Verify with shellfirm doctor

shellfirm doctor

Run it in a new shell. It reports a shell that still runs an old hook, whether commands really go through shellfirm, and default groups that are off. Then shellfirm status shows hooks, agent integrations and groups. See shellfirm doctor.

What's new in 0.4.0

Breaking changes

  • Policies are enforced. Project policies (.shellfirm.yaml) and the new org policy (/etc/shellfirm/policy.yaml, plus SHELLFIRM_ORG_POLICY) can no longer be weakened by personal ignores_patterns_ids, disabled_groups, enabled_groups or min_severity. Nested policies merge up to the outermost repository root, and a command aimed at another repository (git -C repo, cd repo && …, path arguments) gets that repository's policy. See Team policies and Org policy.
  • check exit codes: a risky command exits 10 (ask) or 11 (deny); 2 is a usage error (0.3.10: 2 = risky).
  • check: text goes to stdout, --format json has allowed: true only for allow and schema_version: 2, and --strict exits 78.
  • Claude Code hook no longer auto-approves safe commands; Claude Code's permission rules decide.
  • elvish, xonsh and nushell: the hook 0.3.10 pasted into the rc file must be replaced with shellfirm init <shell>.
  • SHELLFIRM_CONFIG_DIR sets the configuration directory for every command (--config-dir wins; a missing directory is a usage error, exit 2).
  • connect claude-code installs matcher Bash|PowerShell|Monitor, a file-tool group, timeout and onFailure: block. connect cursor adds a preToolUse hook for Write|Delete.
  • The shell and exfil groups are enabled by default. A settings file with an enabled_groups list from 0.3.x keeps them off until you enable them.
  • Audit records: one record per decision, written after the outcome; user comes from the real uid.

Added

  • Around the challenge: the approved line, one impact time budget per command, and the transient checking impact… line (Ctrl-C there cancels the command and writes a cancelled audit record).
  • Commands: policy show and policy validate --strict, status (--format json), doctor, audit show filters and formats, audit clear --yes, config reset --yes, config edit, config approved-notice, config impact-budget, config context …, config escalation …, and check --strict, --fail-on, --list, --no-context, --hook claude-code | cursor. See the CLI reference.
  • Checks: the catalogue grew to 496 entries in 23 groups (499 in 0.4.1). New among them:
    • Infrastructure: Vault, Consul, Nomad and Velero; Kubernetes node and control-plane operations; istioctl uninstall --purge, cilium uninstall, Argo CD prune / delete / cluster removal. See Kubernetes and Terraform.
    • Databases: MySQL DELETE IGNORE and unfiltered multi-table deletes, SET SQL_SAFE_UPDATES = 0, migration and ORM resets (EF Core, Ecto, golang-migrate, goose, Flask/Alembic, Django and more), redis-cli --scan … | xargs redis-cli del. See Databases.
    • Hosting platforms: Supabase, Firebase, Cloudflare (D1, KV, R2), Neon, PlanetScale, Turso and Railway. See Hosting platforms.
    • Disks: sgdisk --zap-all, blkdiscard, mdadm --zero-superblock. See Filesystem.
    • git and GitHub: GitHub API deletes, git push --prune, force pushes whose target is only known when the line runs. See Git.
    • Security: reverse shells, credential exfiltration, lock-outs, and agent commands that edit shell startup files. See Shell and exfiltration.
  • Agents: self-protection for shellfirm's own settings, the agents' settings, persistence files, agent instruction files and the org policy. MCP tools take cwd and carry version. See Agent decisions.
  • Audit: user, host, cwd, git repository and branch, escalation_reasons, deny_reason, policy_sources, secret redaction, an 8 KiB command cap with a hash, and rotation (audit_max_files). See Audit log.

Changed

  • The impact measurement has one budget for the whole command, and its wording says when it stopped early (more than 120,000 files (stopped counting), skipped, no time left).
  • Shell hooks follow function calls within a budget (64 functions, 64 KB, 16 KB for one body). Past it, the line gets the Medium shell:function_depth_limit challenge instead of a silent skip.
  • A recursive delete of a folder with uncommitted or untracked work is High, so a relaxed min_severity still asks. See Uncommitted work.
  • kubectl rollout restart is Medium on a non-production context, and kubectl delete pod NAME is Medium.
  • Check regexes are anchored at the command name: mygit push -f no longer matches, sudo docker … still does.
  • Settings setters write sparse YAML atomically, keep comments and unknown keys, and reject unknown ids and groups with suggestions. An invalid settings file is never overwritten.
  • Output: one colour rule, an ASCII fallback under a non-UTF-8 locale, word-wrapped reports. See Accessibility.

The complete list, including every parser fix, is in the CHANGELOG.