Skip to content
$ shellfirm

Rolling out to a team

One page, in order — install shellfirm on every machine, set up the hooks, ship an org policy, commit project policies and agent hooks, validate in CI, check fleet health and collect the audit log.

This page puts the pieces together for a team or a fleet. Each step links to the page with the details. Every command shown here was run against shellfirm 0.4.0; outputs are real.

StepWhatCommand
1Pilot with a few developers—
2Install the binary on every machinenpm, brew, cargo or a release binary
3Set up the shell hook for each usershellfirm init <shell> --yes
4Ship an org baseline/etc/shellfirm/policy.yaml
5Commit project policies and agent hooks.shellfirm.yaml, connect claude-code --scope project, connect cursor --scope project
6Validate policies in CIshellfirm policy validate --strict
7Check every machineshellfirm doctor --format json
8Collect the audit logaudit.log per user
9Announce itwhat developers will see
10Upgrade and uninstallinit, connect, doctor

1. Pilot

Start with a handful of developers for a week, with the default settings. Their audit logs show which checks fire most often in your codebase, which is the input for the org policy (what to deny, what to raise) and for any personal ignores you want to recommend.

2. Install the binary

Use the install method your machines already use for developer tools, and pin the version so every machine runs the same checks and a new release does not change behaviour overnight:

npm install -g @shellfirm/cli@0.4.3      # npm
cargo install shellfirm --version 0.4.3  # Cargo (builds from source)

Homebrew and the GitHub release binaries work too. Not every install method supports every OS and CPU; check Supported platforms before you pick one for the fleet. For what is (and is not) published to verify a download, see Security & trust.

Node version managers

A binary installed with npm install -g under nvm, fnm or volta belongs to one Node version. If a developer switches Node versions, shellfirm can drop off PATH and the hook stops checking commands (it warns once per session). For a fleet, prefer a system-wide install (Homebrew, a package, or a release binary in /usr/local/bin).

3. Set up the shell hook for each user

The hook lives in each user's rc file (~/.zshrc, ~/.bashrc, …), so it must be installed as that user, not as root. --yes installs without a terminal and without questions, which is what a provisioning script needs:

shellfirm init zsh --yes
Output
  ✓ zsh          → /home/dev/.zshrc

  Protection level: Balanced (Recommended: medium-risk and above). Change it with `shellfirm config severity`.
1 shell protected (1 new, 0 already set up).
  Restart your shell to activate protection:

    exec zsh
  • Run it again any time: it is idempotent ((already set up)), and it upgrades an older hook in place.
  • shellfirm init --all --yes sets up every shell found on the machine.
  • --yes gives a settings file without a protection level the recommended Balanced level (min_severity: Medium).
  • The new hook is active in new shells. Open terminals keep running unchecked until they restart.

Per-shell details: Shell setup.

4. Ship an org baseline

An org policy applies in every directory of a machine, and personal settings cannot weaken it.

PlatformPath
Linux, macOS/etc/shellfirm/policy.yaml
Windows%ProgramData%\shellfirm\policy.yaml

Install it owned by root and not writable by users, from MDM, Ansible, Chef or a package:

sudo install -d -o root -g root -m 0755 /etc/shellfirm
sudo install -o root -g root -m 0644 policy.yaml /etc/shellfirm/policy.yaml

The same with Ansible, including the per-user hook from step 3:

shellfirm.yml
- name: shellfirm org policy
  ansible.builtin.copy:
    src: files/shellfirm-policy.yaml
    dest: /etc/shellfirm/policy.yaml
    owner: root
    group: root
    mode: "0644"
  become: true

- name: shellfirm hook for each developer
  ansible.builtin.command: shellfirm init zsh --yes
  become: true
  become_user: "{{ item }}"
  loop: "{{ developers }}"
  register: sf_init
  changed_when: "'1 new' in sf_init.stderr"

init prints its summary (1 shell protected (1 new, 0 already set up).) on stderr; stdout is empty. That is why changed_when reads sf_init.stderr.

Then, on the machine:

shellfirm policy validate --strict
Output
/etc/shellfirm/policy.yaml: valid

--strict also fails when the current user can write the org file, so a mis-deployed file is caught.

5. Commit project policies and agent hooks

In each repository, commit:

  • a .shellfirm.yaml project policy (shellfirm policy init scaffolds one);
  • the Claude Code hook and MCP server, in the repository instead of each user's home directory:
shellfirm connect claude-code --scope project --dry-run
Output

shellfirm — connecting Claude Code integration (dry run)

  Would create /home/dev/projects/webapp/.claude/settings.json:
    - add hooks.PreToolUse entry (matcher "Bash|PowerShell|Monitor") running `shellfirm check --hook claude-code`
    - add hooks.PreToolUse entry (matcher "Write|Edit|MultiEdit|NotebookEdit") so edits to shellfirm, policy, agent-settings and shell startup files need approval
  Would create /home/dev/projects/webapp/.mcp.json:
    - add mcpServers.shellfirm = {"type":"stdio","command":"shellfirm","args":["mcp"],"env":{}}

Dry run: no changes were made. Run without --dry-run to apply.

Run it without --dry-run and commit .claude/settings.json and .mcp.json.

For Cursor, the same works with --scope project:

shellfirm connect cursor --scope project --dry-run
Output

shellfirm — connecting Cursor integration (dry run)

  Would create /home/dev/projects/webapp/.cursor/hooks.json:
    - add hooks.beforeShellExecution entry running `shellfirm check --hook cursor`
    - add hooks.preToolUse entry (matcher "Write|Delete") so agent edits to shellfirm, policy, agent-settings and shell startup files are blocked
    - add hooks.beforeReadFile entry so agent reads of private keys and credential files are blocked
  Would create /home/dev/projects/webapp/.cursor/mcp.json:
    - add mcpServers.shellfirm = {"command":"shellfirm","args":["mcp"]}

Dry run: no changes were made. Run without --dry-run to apply.

Run it without --dry-run and commit .cursor/hooks.json and .cursor/mcp.json. The other hooked agents take --scope project too (.codex/hooks.json, .gemini/settings.json, .qwen/settings.json, .github/hooks/shellfirm.json, .windsurf/hooks.json, .clinerules/hooks/PreToolUse, .opencode/plugins/shellfirm.js). The Windsurf, Cline and Zed MCP registrations are set up per user; see AI agents.

6. Validate policies in CI

Add shellfirm policy validate --strict to every repository with a .shellfirm.yaml, so a typo never lands and silently leaves a rule unapplied. The workflow and its exit codes are on CI validation.

7. Check every machine

shellfirm doctor checks the hook for one shell: the binary, the rc file, and a new interactive shell whose Enter key must run through shellfirm. Run it as the user, with --shell and --format json, from your compliance or MDM script. It exits 0 when nothing is wrong and 1 when commands typed in that shell may run unchecked.

Healthy (abridged with jq):

shellfirm doctor --shell zsh --format json | jq -c '{ok, enter_routes_through_shellfirm, hook_version, rc_installed: .rc_file.installed, failed: [.findings[]|select(.status=="fail")|.id]}'
Output
{"ok":true,"enter_routes_through_shellfirm":true,"hook_version":"14","rc_installed":true,"failed":[]}

After a user removed the hook from ~/.zshrc (exit code 1):

Output
{"ok":false,"enter_routes_through_shellfirm":false,"hook_version":null,"rc_installed":false,"failed":["rc_file","hook_loaded"]}
FieldMeaning
okfalse when any finding failed (same as exit code 1)
enter_routes_through_shellfirmA new interactive shell sends Enter through shellfirm
hook_version / hook_version_expectedThe hook a new shell loads, and the one this binary ships; a mismatch means an old embedded hook (re-run init)
rc_file.installedThe rc file loads the hook
session_hookedWhether the shell that ran doctor is hooked; null when doctor was started from a script with --shell
findings[]Each check with id, status (ok, info, warn, fail) and message

For a summary of every shell and the policies in force, use shellfirm status --format json (abridged):

shellfirm status --format json | jq -c '{version, hooks: [.hooks[]|select(.installed)|.shell], policy: .policy.sources, audit: .audit.path}'
Output
{"version":"0.4.0","hooks":["zsh"],"policy":[],"audit":"/home/dev/.config/shellfirm/audit.log"}

A user can always opt out

The hook runs in the user's own shell, so a developer can remove it from their rc file, or start a shell without rc files. shellfirm does not prevent that; it is a guard against mistakes, not a control a user cannot switch off. Detect it with the health check above (rc_file.installed: false), and by machines whose audit log stops receiving records.

8. Collect the audit log

Each user has their own log, one JSON object per line (format):

PlatformPath
Linux~/.config/shellfirm/audit.log
macOS~/Library/Application Support/shellfirm/audit.log
Windows%APPDATA%\shellfirm\audit.log
  • A collector that runs as a service should use a glob over home directories: /home/*/.config/shellfirm/audit.log on Linux, /Users/*/Library/Application Support/shellfirm/audit.log on macOS.
  • The file is created with mode 0600 (-rw-------), readable only by its owner, so the collector must run as root (or as the user).
  • SHELLFIRM_CONFIG_DIR moves the whole configuration directory, the log included. shellfirm status --format json prints the path in use (audit.path).
  • Rotated files (audit.log.1, …) sit next to it; tail only audit.log.

A Fluent Bit input for Linux machines:

fluent-bit.conf
[INPUT]
    Name         tail
    Path         /home/*/.config/shellfirm/audit.log
    Parser       json
    Tag          shellfirm.audit
    DB           /var/lib/fluent-bit/shellfirm.db
    Refresh_Interval 30

Each record carries user, uid, hostname, cwd, the command, the matched check ids and the outcome, so you do not need to add them in the pipeline. A real record:

{"event_id":"70e288cd-ed6f-4d44-ad47-971aff6cae6d","timestamp":"2026-10-27T23:30:01Z","command":"git reset --hard","matched_ids":["git:reset"],"challenge_type":"Math","outcome":"NoTerminal","context_labels":["branch=main"],"severity":"High","blast_radius_scope":"PROJECT","blast_radius_detail":"Discards changes in 1 modified file (README.md)","schema_version":4,"version":"0.4.0","user":"dev","uid":1000,"hostname":"web-fix-b","cwd":"/home/dev/projects/webapp","git_repo":"/home/dev/projects/webapp","git_branch":"main","effective_challenge":"Math","deny_reason":"no_tty"}

What the log can and cannot prove: Audit compliance.

9. Announce it

Tell developers what changes for them before the first challenge surprises them. A text you can adapt:

We are rolling out shellfirm, which asks before risky shell commands run (git reset --hard, rm -rf, kubectl delete, terraform destroy, curl … | bash, …). When a command matches, you see a banner explaining the risk and a short challenge: press Enter, solve a small sum, or type yes for the riskiest ones. Esc cancels and keeps the line for editing. Safe commands are not affected. On protected branches (main) and production clusters the challenge is stricter. Some commands are blocked by our org or project policy; the banner names the file, and changing it goes through code review. AI agents (Claude Code, Cursor) get a decision instead of a challenge: risky commands need your approval, the riskiest are denied. Questions: shellfirm check -c '<command>' explains any decision without running it.

Point people at the Quick start and the FAQ. For readers who need to avoid math challenges, see Accessibility.

10. Upgrades

  1. Read the release notes in the CHANGELOG: new checks can make commands that used to run ask first.
  2. Pilot the new version, then bump the pinned version in your install step.
  3. Re-run shellfirm init <shell> --yes (or --all --yes) as each user. The eval "$(shellfirm init …)" line used by bash, zsh and fish loads the new hook by itself; Nushell, Elvish and Xonsh embed the hook in the rc file, and re-running init replaces the old block in place. A hook a user saved to a file by hand (the nushell and PowerShell recipes in Shell setup) is not seen by init: regenerate that file instead of running init for that shell.
  4. Re-run shellfirm connect claude-code, and shellfirm connect cursor where you set Cursor up, each with the same --scope you installed with: it upgrades older agent hooks in place and writes a backup first. Do not run connect cursor on machines without it: that installs new Cursor hooks. shellfirm status lists which agents are connected.
  5. Check with shellfirm doctor --format json: hook_version should equal hook_version_expected.

Uninstall at scale

connect … --uninstall only looks at the scope you give it (user scope when you give none), so remove each install where you made it.

In each repository where you committed agent hooks (step 5):

# .claude/settings.json and .mcp.json
shellfirm connect claude-code --uninstall --scope project
# .cursor/hooks.json and .cursor/mcp.json
shellfirm connect cursor --uninstall --scope project

Then commit the change (a file that held only shellfirm's entries is deleted).

As each user:

# remove every shell hook
shellfirm init --uninstall --all --yes
# user-scope Claude Code hook and MCP entry, if any
shellfirm connect claude-code --uninstall
# user-scope Cursor hooks, if any
shellfirm connect cursor --uninstall

Without --scope project, the uninstall does not see the files in the repository and reports Nothing to change: no shellfirm configuration found for Claude Code.

init --uninstall --all --dry-run previews it:

Output

shellfirm — dry run: hooks that would be removed (no changes will be made)

  → zsh          → /home/dev/.zshrc (would remove hook)

1 hook(s) would be removed. No changes made. Run without --dry-run to apply.

Then remove /etc/shellfirm/policy.yaml and the binary. Full details: Uninstall.