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
| Who | What breaks | Fix |
|---|---|---|
CI jobs, git hooks and scripts that run shellfirm check --exit-code | A 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 through | Fail on any non-zero exit, or use --fail-on (step 4) |
| Everyone who changed a setting with 0.3.x | The settings file lists the 0.3 check groups, so the new default groups shell (curl … | bash) and exfil stay off | Run the command shellfirm status prints (step 5) |
| elvish, xonsh and nushell users | The 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 users | The hook no longer auto-approves safe commands (ls), so Claude Code's own permission rules decide. Risky commands are still denied | Intended. 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 checked | shellfirm connect <agent> (step 3) |
Teams with a .shellfirm.yaml or org policy | Policies now win over personal ignores, disabled_groups and min_severity | Intended. Change the policy, not your ignores (policies) |
Scripts that read check output or JSON | The text report is on stdout (was stderr); JSON allowed is true only for decision: allow | Read stdout; key on decision (JSON) |
Everyone else only restarts their terminals.
Checklist
| Step | Do this | Why |
|---|---|---|
| 1 | Restart your shells (exec $SHELL, or open new terminals) | The shell hooks changed (HOOK_VERSION 14) |
| 2 | elvish, xonsh, nushell: shellfirm init <shell>, answer y | Replaces the 0.3.10 hook pasted into the rc file |
| 3 | Re-run shellfirm connect <agent> | Upgrades the agent hook in place: more matchers, fail closed |
| 4 | Fix CI gates that test for exit code 2 | Risky commands now exit 10 / 11 |
| 5 | Run the shellfirm config groups --enable … command that shellfirm status prints | Turns on the new default groups shell and exfil |
| 6 | Run shellfirm doctor in a new shell | Confirms 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 $SHELLRe-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 cursorIt 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:
| Command | New exit code | Meaning |
|---|---|---|
check, policy validate | 74 | The result could not be written (for example a full disk) |
check --strict | 78 | Your settings, custom checks or an applicable policy have errors or warnings. It replaces the decision's 10 / 11 |
pre-command | 3 | Allowed after a passed challenge, only when the caller sets SHELLFIRM_SIGNAL_PROMPTED=1 |
pre-command | 74 | No terminal to ask on: blocked (fail closed) |
config setters | 2 | A 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:
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 withshellfirm 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 withshellfirm config impact-budget <ms>.0turns the measurement off. It is the one switch: the settings editor toggle writes it too, and a non-zero budget clears an olderblast_radius: false. See Blast radius.shellfirm statusandshellfirm config showshow both.- Before a slow measurement you may briefly see
shellfirm: checking impact… (Ctrl-C cancels)(orshellfirm: checking <file>…while a SQL file is read). It is erased before the banner and never shown underTERM=dumb. - The
shellcheck group is on by default for fresh installs (an upgraded settings file: see Turn on the new default groups). It covers remote scripts:curl … | bashand a downloaded script run on the same line. Acurl … | shinstall 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 throughheroku 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 runscheck --fail-on highmay 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 throughshellfirm wrap.
JSON consumers
check --format jsonhas"allowed": trueonly fordecision: allow. Key ondecision.schema_versionis2.- The new keys
version,shell,not_appliedandskipped_missing_pathsare additive. - Audit records are
schema_version: 4(newversionfield). 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 validateIt shows problems and what the policy enforces. See Team policies.
Verify with shellfirm doctor
shellfirm doctorRun 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, plusSHELLFIRM_ORG_POLICY) can no longer be weakened by personalignores_patterns_ids,disabled_groups,enabled_groupsormin_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. checkexit 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 jsonhasallowed: trueonly forallowandschema_version: 2, and--strictexits 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_DIRsets the configuration directory for every command (--config-dirwins; a missing directory is a usage error, exit 2).connect claude-codeinstalls matcherBash|PowerShell|Monitor, a file-tool group,timeoutandonFailure: block.connect cursoradds apreToolUsehook forWrite|Delete.- The
shellandexfilgroups are enabled by default. A settings file with anenabled_groupslist from 0.3.x keeps them off until you enable them. - Audit records: one record per decision, written after the outcome;
usercomes 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 acancelledaudit record). - Commands:
policy showandpolicy validate --strict,status(--format json),doctor,audit showfilters and formats,audit clear --yes,config reset --yes,config edit,config approved-notice,config impact-budget,config context …,config escalation …, andcheck --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 IGNOREand 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.
- Infrastructure: Vault, Consul, Nomad and Velero; Kubernetes node and control-plane operations;
- Agents: self-protection for shellfirm's own settings, the agents' settings, persistence files, agent instruction files and the org policy. MCP tools take
cwdand carryversion. 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_limitchallenge instead of a silent skip. - A recursive delete of a folder with uncommitted or untracked work is High, so a relaxed
min_severitystill asks. See Uncommitted work. kubectl rollout restartis Medium on a non-production context, andkubectl delete pod NAMEis Medium.- Check regexes are anchored at the command name:
mygit push -fno 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.