Skip to content
$ shellfirm

What is shellfirm?

A safety net that stops risky shell commands, typed by you or run by an AI agent, before they do damage.

shellfirm reads every command before your shell runs it. If the command is risky, shellfirm stops it and shows what it would do, why that is risky, and a safer alternative. To go on, you solve a small challenge. AI agents get an allow, ask or deny answer instead of a prompt.

git push origin main --force, in zsh on the protected main branch
============ 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, preventing accidental overwrites of others' work.)
Escalated to Yes (from Math): protected branch `main`

[HIGH] Type `yes` to continue (Esc or Ctrl-C to cancel)

At a glance

  • Open source: Apache-2.0 licensed, written in Rust. Source on GitHub.
  • Runs locally: every check runs on your machine. Nothing is sent anywhere unless you turn on the optional LLM analysis.
  • Platforms: macOS, Linux and Windows. See supported platforms for which install method covers which.
  • Not a sandbox: a guard against mistakes. See What shellfirm is not.
  • Trust: how to report a vulnerability and what data it keeps are on the Security page. Want to add a check? See Contributing.

How it works

The hook sends the command to shellfirm. A shell hook (bash, zsh, fish, …) or an agent hook (Claude Code, Cursor, Codex CLI, Gemini CLI and five more) passes the command to shellfirm before it runs. Aliases, history references and small shell functions are expanded first, so shellfirm checks what will really run.

shellfirm matches it against the checks. There are 532 built-in checks in 23 groups, plus your own custom checks and your team's policy checks.

It looks at the context. An SSH session, root, a protected git branch, a production Kubernetes context or a production environment variable makes the challenge stricter.

It measures the blast radius. It counts the files, branches or resources the command would touch, within a time budget (400 ms by default).

It decides. Safe commands run without delay. Risky ones get a challenge (Math, Enter or Yes). Commands on a deny list are blocked. AI agents get allow, ask or deny.

The details are in The check pipeline.

Key features

FeatureWhat you get
532 built-in checks, 23 groupsFilesystem and disks, git, GitHub, Docker, Kubernetes and Helm, Terraform and HashiCorp tools, AWS, GCP, Azure, databases, migrations and ORMs, hosting platforms (Heroku, Railway, Supabase, Firebase, Cloudflare, Neon, PlanetScale, Turso, Vercel, Netlify, Fly.io), npm, network, remote scripts (curl … | bash) and credential exfiltration. All are on by default. See Protection coverage.
Context-aware challengesStricter challenges over SSH, as root, on protected branches, in production clusters, and when a recursive delete would destroy uncommitted work. See Context-aware protection.
Blast radiusShows what a command would affect (Deletes directory node_modules with 200 files (808K)) before you confirm. See Blast radius.
Safer alternativesMany checks suggest a safer command, such as git push --force-with-lease.
AI agent protectionOne command (shellfirm connect <agent>) installs a blocking hook in Claude Code, Cursor, Codex CLI, Gemini CLI, Qwen Code, GitHub Copilot CLI, Windsurf, Cline or OpenCode. See AI agents.
Agent sandboxshellfirm sandbox claude-code (or codex) turns on the agent's own OS sandbox and denies it your SSH keys and cloud credentials. See Agent sandbox.
Session replayshellfirm audit replay shows what shellfirm would have blocked or asked about in your past Claude Code and Codex CLI sessions, without running anything. See Replay agent sessions.
Fast and predictableOne native binary, with no daemon, server or model to keep running. A safe line costs a few milliseconds, and the same command always gets the same decision, with the rule id and the reason. See Performance.
Database sessionsshellfirm wrap psql (and mysql, sqlite3, redis-cli, mongosh, sqlcmd, …) checks each statement before the client runs it. See Database wrapper.
Team and org policiesCommit a .shellfirm.yaml or install an org policy. Personal settings cannot weaken it. See Team policies.
Audit logEvery decision as JSON lines, with user, host, repository, branch and outcome, and with secrets redacted. See Audit log.

Shells

shellfirm ships hooks for 8 shells. Not all are tested to the same level:

ShellStatus
Bash, Zsh, Fish, Elvish, XonshTested end to end: risky commands are challenged before they run.
NushellTested, with a limitation: Nushell built-in commands (rm, mv, …) only get a warning and still run. External programs are challenged.
PowerShell, Oils (osh)Hooks are shipped but not yet tested end to end.

See Shell setup for details.

What shellfirm is not

shellfirm is a guard against mistakes, not a sandbox. It reads the command line before it runs. It cannot see what a program does once it has started, and it does not read the contents of scripts you run (./cleanup.sh). Known limitations lists the gaps.

How it fits with agent permissions and sandboxes

shellfirm works alongside the tools you may already use. It does not replace them.

ToolWhat it doesWhat it does not do
Agent permission rules (Claude Code allow/deny lists, Cursor allowlists)Allow or block tools and command prefixes for one agentUnderstand what a command does: rm -rf ./build and rm -rf ~ look alike to a prefix rule, and the rules do not cover you in your own terminal
shellfirmReads the command, its context (branch, cluster, root, uncommitted work) and its blast radius, then challenges you or answers the agent with allow, ask or deny. One policy for people, agents and CIContain a program once it runs, or read scripts it runs (for Claude Code and Codex CLI, shellfirm sandbox turns on the agent's own sandbox for that)
Sandboxes and containersLimit what a program can reach, whatever it doesTell a mistake from intended work inside what they allow

Use the agent's permission rules for what the agent may do at all, a sandbox to limit the damage, and shellfirm to catch the destructive command before it starts.

Who it is for

  • Developers who want a second look before rm -rf, git reset --hard or DROP TABLE.
  • DevOps and SRE teams who work on production clusters, databases and cloud accounts.
  • Teams using AI coding agents who want risky agent commands blocked or sent back to a human.
  • Security and platform teams who need shared policies and an audit log.

Start here

Upgrading from shellfirm 0.3.10? See Upgrading to 0.4.0.