Skip to content
0.4.3532 checks · blocking hooks for 9 AI agents · enforced team policiesUpgrading from 0.3.10? →

Think before you execute.

Humans make mistakes. AI agents make them faster. shellfirm stops risky shell commands before they run: you get a short challenge, an AI agent gets a clear allow, ask or deny.

60-second quick start

or brew tap kaplanelad/tap && brew install shellfirm · cargo install shellfirm --locked (no Node.js launcher, so the fastest)

You, in zsh, on main

zsh
~/projects/webapp % git push origin main --force
============ RISKY COMMAND DETECTED ============
Command: git push origin main --force
Check: git:force_push
Severity: HIGH
Blast radius: [PROJECT] — Force-pushes to origin/main
Context: branch=main, target=main
Description: This force-pushes and can overwrite remote history.
Alternative: git push --force-with-lease
(Checks that your local ref is up-to-date before force pushing, …)
Escalated to Yes (from Math): protected branch `main`
 
[HIGH] Type `yes` to continue (Esc or Ctrl-C to cancel) yes
✓ approved — running: git push origin main --force

Real shellfirm 0.4.0 output with default settings; long lines trimmed where marked with …

Protected in 60 seconds.

Bash, Zsh, Fish, Elvish and Xonsh are tested end to end; Nushell with a limitation; PowerShell and Oils hooks ship but are not yet tested end to end.

  1. Step 1: Install

    $ npm install -g @shellfirm/cli

    or Homebrew, Cargo, or a release binary

  2. Step 2: Hook your shell

    $ shellfirm init

    asks for a challenge type and a protection level (--yes picks Balanced)

  3. Step 3: Restart the shell

    $ exec zsh

    or exec bash, exec fish, … or open a new terminal

  4. Step 4: Check it works

    $ shellfirm doctor

    then try git reset --hard in a scratch repo and press Esc

Step 4: shellfirm doctor

zsh
~ % shellfirm doctor
shellfirm doctor — zsh (from parent process)
 
[ok] session this zsh session has loaded the shellfirm hook
[ok] rc_file ~/.zshrc loads the hook
[ok] hook_loaded hook loaded (version 13)
[ok] enter Enter runs commands through shellfirm
[ok] settings …/shellfirm/settings.yaml is valid
…

Using an AI coding agent?

zsh
~ % shellfirm connect claude-code
shellfirm — connecting Claude Code integration
 
~/.claude/settings.json:
- add hooks.PreToolUse entry (matcher "Bash|PowerShell|Monitor") …
- add hooks.PreToolUse entry (matcher "Write|Edit|MultiEdit|NotebookEdit") …
✓ written
~/.claude.json:
- add mcpServers.shellfirm = …
✓ written

Also shellfirm connect for Cursor, Codex CLI, Gemini CLI, Qwen Code, Copilot CLI, Windsurf, Cline and OpenCode.

One command. No undo.

A tired human, a wrong tab, an AI agent that misread the task, a script with an empty variable. The shell runs whatever it is given. shellfirm asks first.

$ rm -rf ~ /tmp/build

One stray space, and the first target is your home directory.

$ git push origin main --force

Overwrites the remote history your team pushed.

$ kubectl delete namespace prod

Typed in the terminal that is still pointed at production.

$ supabase db reset --linked

Resets the linked remote database, not your local one.

$ curl -fsSL https://… | bash

Runs a script nobody has read, as you.

$ terraform apply plan.out

Applies a saved plan without asking — maybe a destroy plan.

One engine. Two answers.

The same checks run whether you typed the command or an AI agent generated it. You get a challenge you can solve; an agent gets a decision it must follow. shellfirm check shows both, without running anything.

In your terminal

zsh
~/projects/webapp % git reset --hard
============ RISKY COMMAND DETECTED ============
Command: git reset --hard
Check: git:reset
Severity: HIGH
Blast radius: [PROJECT] — Discards changes in 1 modified file (README.md)
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'.)
Not risky for you? Stop asking with `shellfirm config ignore git:reset`.
 
[HIGH] Solve the challenge: 7 + 8 = ? (Esc or Ctrl-C to cancel)
<Esc>
shellfirm: cancelled, command not run.
shellfirm: the line is kept for editing (Ctrl-U clears it).

No math? Screen reader or plain terminal? Accessibility →

Ask first: shellfirm check

zsh (in a project that has node_modules)
~/projects/webapp % 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 200 files (808K)
> Safe alternative: trash <path> (Moves to trash instead of permanent deletion.)
 
Shell (you, in a terminal): would challenge (Math)
AI agent (hooks, MCP): ask — Matched risky pattern(s) (severity MEDIUM, below the auto-deny threshold HIGH); confirm before running

Math, Enter or Yes

The riskier the command and the context, the stricter the challenge. Wrong answers just ask again.

Blast radius

What the command would touch: files and sizes, branches, namespaces, containers. Measured in at most 400 ms.

Safer alternative

Many checks suggest one: --force-with-lease, git stash, trash, a dry run or a backup first.

Why shellfirm

Stricter where it matters.

The same command is riskier on production. shellfirm reads where it runs and raises the challenge, never lowers it. The banner says why:Escalated to Yes (from Math): protected branch `main`.

Context-aware escalation

  • Protected git branches

    Pushing to, rewriting or deleting main, master, production or release/* asks you to type yes.

  • Production clusters and clouds

    Kubernetes contexts and namespaces, AWS profiles, Terraform workspaces, gcloud projects and Azure subscriptions named prod, production, prd or live.

  • Root, sudo and SSH

    Root needs yes; an SSH session needs at least math.

  • Production environment variables

    NODE_ENV, RAILS_ENV or ENVIRONMENT set to production, plus the variables you add with shellfirm config context env.

  • Uncommitted work

    A recursive delete of a folder with uncommitted or untracked files is High: git cannot bring them back.

How escalation works →

Fast, and tells you what it is doing

  • A few milliseconds per Enter

    With the native binary (Homebrew, Cargo or a release binary) a safe command costs about 2–3 ms: one short-lived process, no context lookups. The hook adds about 4–10 ms to shell startup. The npm launcher adds about 17 ms per call; numbers and method on the performance page.

  • A time budget, not a wait

    The impact measurement gets 400 ms per command by default (at most 5000). Change it with shellfirm config impact-budget.

  • Says when it is counting

    After 200 ms you see “shellfirm: checking impact… (Ctrl-C cancels)”. Ctrl-C cancels the command.

  • Honest numbers

    A count that ran out of time says “more than 120,000 files (stopped counting)”.

  • Feedback after you confirm

    “✓ approved — running: helm uninstall web”, so a slow command does not look hung. Turn it off with shellfirm config approved-notice off.

Performance numbers →Blast radius and the impact budget →

AI agents can't solve a math problem. So they get a decision.

Blocking hooks for nine coding agents. With the hook installed, every command line the agent runs is checked first (not the contents of scripts it writes and then runs). Below High it is ask (the agent asks you, or blocks it where its hooks cannot ask); at High or above, or on a deny list, it is deny. Safe commands pass silently. Every decision names the rule and the reason (and a safer alternative when the check has one), and is written to the audit log. What it does not catch.

Claude Codehook + MCP

$ shellfirm connect claude-code

PreToolUse hooks for Bash, PowerShell and Monitor commands, file edits and Read. Risky commands ask, dangerous ones are denied. Fail closed: "onFailure": "block". MCP server too.

Cursorhook + MCP

$ shellfirm connect cursor

beforeShellExecution hook for commands, a preToolUse hook for protected file edits and a beforeReadFile hook for credential-file reads, plus MCP. Risky commands ask.

$ shellfirm connect gemini | qwen | copilot

BeforeTool / PreToolUse / preToolUse hooks for shell commands, writes, edits and reads. Risky commands ask in the agent's own prompt; headless and autopilot runs deny them.

$ shellfirm connect codex | windsurf | cline | opencode

Their hooks cannot ask, so risky commands are blocked with the reason and a safer alternative, and you run them yourself if intended. Windsurf and Cline get the MCP server too.

Agent sandboxOS sandbox

$ shellfirm sandbox claude-code | codex

Turns on the agent's own OS sandbox and denies it your SSH keys, cloud credentials and token files, so a script it runs cannot read them either.

$ shellfirm audit replay

Reads Claude Code and Codex CLI session transcripts and shows what shellfirm would have blocked or asked about, worst first. Read-only: nothing is run or written.

MCP tools (shellfirm mcp)

check_command
allow / ask / deny, severity, matched checks, alternatives
suggest_alternative
safer replacement commands
explain_risk
why a command is dangerous, with context
get_policy
the active thresholds, deny lists and project policy

Agent docs →

From solo dev to engineering org.

Commit rules to the repository, roll out an org baseline, keep a log of every decision, and protect live database sessions.

Team policy, enforced

.shellfirm.yaml
version: 1
deny:
- git:force_push
overrides:
- id: git:reset
challenge: Yes
 
~/projects/webapp % shellfirm policy show
…
Your personal settings that the policy overrides (the policy wins):
- `git:reset` is in your ignores_patterns_ids, but the project policy enforces it

Personal ignores can't weaken it. Org baseline at /etc/shellfirm/policy.yaml; CI runs shellfirm policy validate --strict.

Audit log

shellfirm audit show --format jsonl
{"schema_version":4,
"timestamp":"2026-10-27T22:17:14Z",
"command":"git push --force origin main",
"matched_ids":["git:force_push"],
"outcome":"Denied",
"deny_reason":"agent_auto_deny",
"agent_name":"mcp",
"user":"dev", "git_branch":"main", …}

One JSON line per decision, secrets redacted, bounded rotation. Filter with --since 7d --outcome denied.

Database sessions

shellfirm wrap psql
shellfirm: protecting psql (89 checks from database, psql; checking statements ending with ';' on Enter)
DROP TABLE users;
============ RISKY STATEMENT DETECTED (shellfirm wrap:psql) ============
Statement: DROP TABLE users
Check: database:drop_table
Severity: CRITICAL
Escalated to Yes (from Math): severity CRITICAL
 
[CRITICAL] Type `yes` to continue (Esc or Ctrl-C to discard the statement)

psql, mysql, sqlite3, redis-cli, mongosh, sqlcmd and more. Declining discards the statement and keeps the session open.