Quick start
Install shellfirm, set up your shell and see your first challenge in about a minute.
This walkthrough uses bash. Every output on this page is what bash prints after the choices the page tells you to make. In zsh or fish the steps are the same: only the rc file and the restart command change.
Install
npm install -g @shellfirm/cliThe npm package ships binaries for macOS (Apple Silicon and Intel), Linux x64 and Windows x64. For Linux arm64, Alpine and other platforms, and for Homebrew, Cargo and release binaries, see Installation.
Install the shell hook
shellfirm initinit shows the line it adds to your rc file and asks before changing it. Then it offers the other shells it found, and asks two questions. Answer y, then n, then pick Enter and Balanced:
shellfirm — install the hook for bash (your shell, from the parent process)
→ bash → will add hook to /home/dev/.bashrc
+ eval "$(shellfirm init bash)"
Modify this file? [Y/n] y
✓ bash → /home/dev/.bashrc
Also add the hook for: zsh, fish, nushell, elvish, xonsh? [y/N] n
✔ Choose your challenge type: · Enter — just press Enter to confirm
✔ Choose your protection level: · Balanced — catches medium-risk and above (Recommended)
Settings saved to /home/dev/.config/shellfirm/settings.yaml
1 shell protected (1 new, 0 already set up).
Restart your shell to activate protection:
▸ exec bash (bash, your shell)| Question | Choices |
|---|---|
| Challenge type | Math (solve a sum such as 3 + 7 = ?, the default), Enter (press Enter), Yes (type yes) |
| Protection level | Paranoid (everything), Balanced (Medium and above, recommended), Chill (High and Critical), YOLO (Critical only) |
The challenge you pick is the minimum. High and Critical commands, and risky contexts, raise it. See Challenges. Prefer no math at all? See Accessibility.
No questions
For scripts and provisioning, shellfirm init --yes installs without asking and sets the recommended Balanced level. shellfirm init --dry-run shows what would change. Rolling out to many machines? See Rolling out to a team.
Restart your shell
exec bashIn another shell, restart that shell instead (exec zsh, exec fish, exec nu, …), or open a new terminal.
Check it works
shellfirm status # hooks, settings, policy and thresholds
shellfirm doctor # does a new shell really route commands through shellfirm?doctor prints one line per check. [ok] lines passed and [--] lines are information. A [!!] (warning) or [XX] (failed) line says what to fix. All [ok] and [--] means you are protected:
shellfirm doctor — bash (from parent process)
[--] shell bash (detected from parent process)
[ok] session this bash session has loaded the shellfirm hook
[ok] binary /usr/local/bin/shellfirm (v0.4.0)
[ok] rc_file /home/dev/.bashrc loads the hook
[ok] hook_loaded hook loaded (version 14)
[ok] enter Enter runs commands through shellfirm
[ok] fc fc (editor and `fc -s` re-runs, also as `command fc`, `builtin fc`, inside `eval` or in a function) and Ctrl-X Ctrl-E / vi `v` are checked; …
[--] exit_status after a line shellfirm blocked, `$?` still holds the status of the command before it: …
[ok] settings /home/dev/.config/shellfirm/settings.yaml is valid
[ok] custom_checks 0 custom check(s) loaded
Live check ran in a new interactive shell. To check this session (bindings changed after startup):
__shellfirm_doctor_probe | shellfirm doctor --stdinThe fc and exit_status lines appear in bash and zsh (with shell-specific wording). They say that re-running history with fc is checked too, and that $? is not changed by a line shellfirm blocked. See doctor for every line.
Try a risky command, in a throwaway repository
Do not try this in a real project. Make a scratch repository with one modified file, in a new empty folder:
cd "$(mktemp -d)" && git init -q && git checkout -q -b main && echo hi > a.txt && git add a.txt && git -c user.name=demo -c user.email=demo@example.com commit -qm init && echo change >> a.txtThe line works without a git identity set up and with any git version, and each run makes a fresh folder, so you can run it again to start over.
Then run:
git reset --hardshellfirm stops it and shows the banner. git reset --hard is High, so the Enter challenge you chose in the init step is raised to Math:
============ RISKY COMMAND DETECTED ============
Command: git reset --hard
Check: git:reset
Severity: HIGH
Blast radius: [PROJECT] — Discards changes in 1 modified file (a.txt)
Context: branch=main
Description: This discards all uncommitted changes in your working tree.
Alternative: git stash
(Saves your changes to the stash so you can recover them later with 'git stash pop'.)
Escalated to Math (from Enter): severity HIGH
Not risky for you? Stop asking with `shellfirm config ignore git:reset`.
[HIGH] Solve the challenge: 6 + 8 = ? (Esc or Ctrl-C to cancel)Press Esc (or Ctrl-C). The command does not run, and the line stays in the editor:
shellfirm: cancelled, command not run.
shellfirm: the line is kept for editing (Ctrl-U clears it).In zsh the second line can appear below the restored command (git reset --hard is back at the prompt, not run).
The sum is new each time (two numbers from 0 to 9), and a wrong answer asks again. In the scratch repository you can run the command again and solve the sum, which runs it:
[HIGH] Solve the challenge: 6 + 7 = ? (Esc or Ctrl-C to cancel) 13
✓ approved — running: git reset --hard
HEAD is now at 4db3313 initAsk without running
shellfirm check tells you what shellfirm would do with a command, without running it and without a challenge. Still in the scratch repository, create a small node_modules folder and ask about deleting it:
mkdir -p node_modules/pkg && echo x > node_modules/pkg/index.js
shellfirm check -c 'rm -rf node_modules'1 risky pattern(s) matched:
[fs-strict:recursive_deletion] [MEDIUM] This recursively deletes the given files or directories, with everything inside them.
Blast radius: [RESOURCE] — Deletes directory node_modules with 1 file (12K)
> Safe alternative: trash <path> (Moves to trash instead of permanent deletion.)
Shell (you, in a terminal): would challenge (Enter)
AI agent (hooks, MCP): ask — Matched risky pattern(s) (severity MEDIUM, below the auto-deny threshold HIGH); confirm before runningMedium is below High, so your Enter challenge is not raised. An AI agent would be asked to confirm.
Before you create the folder, the same command reports that nothing applies:
1 check matched, but none applies here:
- fs-strict:recursive_deletion: skipped, node_modules does not exist
Shell (you, in a terminal): runs without a challenge
AI agent (hooks, MCP): allowThat is expected: delete checks only apply when there is something to delete. (In your home folder the list is longer, because deleting there also matches other checks.)
Tune it
Run only the commands you want. Each one changes one setting and prints what it changed.
Open the interactive settings editor (q quits):
shellfirm configChange the challenge (Math, Enter or Yes):
shellfirm config challenge Mathchallenge = MathPrompt only for High and Critical commands:
shellfirm config severity Highmin_severity = HIGHOptional: turn one check off, or always block it
shellfirm config ignore <id> stops prompting for a check (for example git:reset, the check you just tried), and shellfirm config deny <id> always blocks it. Use them only for a check you have decided about. shellfirm config ignore --remove <id> undoes an ignore.
Settings live in ~/.config/shellfirm/settings.yaml (macOS: ~/Library/Application Support/shellfirm/settings.yaml). See Configuration.