$git clone https://github.com/kaplanelad/shellfirmThink before you execute.
| 1 | <p align="center"> |
| 2 | <img src="https://github.com/kaplanelad/shellfirm/actions/workflows/ci.yaml/badge.svg"/> |
| 3 | <img src="https://github.com/kaplanelad/shellfirm/actions/workflows/release.yml/badge.svg"/> |
| 4 | </p> |
| 5 | |
| 6 | # shellfirm |
| 7 | |
| 8 | **Think before you execute.** |
| 9 | |
| 10 | Humans make mistakes. AI agents make them faster. shellfirm intercepts dangerous shell commands before the damage is done. |
| 11 | |
| 12 | ``` |
| 13 | $ rm -rf ./src |
| 14 | ============ RISKY COMMAND DETECTED ============ |
| 15 | Severity: Critical |
| 16 | Blast radius: [PROJECT] — Deletes 347 files (12.4 MB) in ./src |
| 17 | Description: You are going to delete everything in the path. |
| 18 | |
| 19 | Solve the challenge: 8 + 0 = ? (^C to cancel) |
| 20 | ``` |
| 21 | |
| 22 | ``` |
| 23 | $ git push origin main --force |
| 24 | ============ RISKY COMMAND DETECTED ============ |
| 25 | Severity: High |
| 26 | Blast radius: [RESOURCE] — Force-pushes branch main (3 commits behind remote) |
| 27 | Description: This command will force push and overwrite remote history. |
| 28 | Alternative: git push --force-with-lease |
| 29 | (Checks that your local ref is up-to-date before force pushing, preventing accidental overwrites of others' work.) |
| 30 | |
| 31 | Solve the challenge: 3 + 5 = ? (^C to cancel) |
| 32 | ``` |
| 33 | |
| 34 | --- |
| 35 | |
| 36 | ## Features |
| 37 | |
| 38 | - **100+ patterns** across 9 ecosystems (filesystem, git, Kubernetes, Terraform, Docker, AWS, GCP/Azure, Heroku, databases) |
| 39 | - **8 shells** — Zsh, Bash, Fish, Nushell, PowerShell, Elvish, Xonsh, Oils |
| 40 | - **Context-aware escalation** — harder challenges when connected via SSH, running as root, on protected git branches, or in production Kubernetes clusters |
| 41 | - **Safe alternative suggestions** — actionable safer commands shown alongside every warning |
| 42 | - **Severity levels** with configurable thresholds (`Critical`, `High`, `Medium`, `Low`, `Info`) |
| 43 | - **Project policies** — share team safety rules via `.shellfirm.yaml` (additive-only, never weakens) |
| 44 | - **Audit trail** — every intercepted command and decision logged as JSON-lines |
| 45 | - **Blast radius detection** — runtime context signals feed into risk scoring |
| 46 | - **MCP server** — expose shellfirm as an AI tool for Claude Code, Cursor, and other agents |
| 47 | |
| 48 | --- |
| 49 | |
| 50 | ## AI Tool Integration |
| 51 | |
| 52 | ### Claude Code |
| 53 | |
| 54 | One command sets up both automatic safety (hooks) and on-demand analysis (MCP): |
| 55 | |
| 56 | ```bash |
| 57 | shellfirm connect claude-code |
| 58 | ``` |
| 59 | |
| 60 | This adds: |
| 61 | - **Hooks** — every Bash command is checked before execution; risky commands are blocked |
| 62 | - **MCP** — Claude can call shellfirm tools to explain risks and suggest alternatives |
| 63 | |
| 64 | ### MCP Tools |
| 65 | |
| 66 | | Tool | Description | |
| 67 | |------|-------------| |
| 68 | | `check_command` | Check if a command is risky — returns severity, matched rules, and alternatives | |
| 69 | | `suggest_alternative` | Get safer replacement commands | |
| 70 | | `explain_risk` | Detailed explanation of why a command is dangerous | |
| 71 | | `get_policy` | Read the active shellfirm configuration and project policy | |
| 72 | |
| 73 | --- |
| 74 | |
| 75 | ## Installation |
| 76 | |
| 77 | ### npm |
| 78 | |
| 79 | ```bash |
| 80 | npm install -g @shellfirm/cli |
| 81 | ``` |
| 82 | |
| 83 | ### Homebrew |
| 84 | |
| 85 | ```bash |
| 86 | brew tap kaplanelad/tap && brew install shellfirm |
| 87 | ``` |
| 88 | |
| 89 | ### Cargo |
| 90 | |
| 91 | ```bash |
| 92 | cargo install shellfirm |
| 93 | ``` |
| 94 | |
| 95 | Or download the binary from the [releases page](https://github.com/kaplanelad/shellfirm/releases). |
| 96 | |
| 97 | --- |
| 98 | |
| 99 | ## Quick Start |
| 100 | |
| 101 | **1. Install the shell hook** (auto-detects your shell): |
| 102 | |
| 103 | ```bash |
| 104 | shellfirm init |
| 105 | ``` |
| 106 | |
| 107 | **2. Restart your shell** (or `source` your rc file). |
| 108 | |
| 109 | **3. Try it:** |
| 110 | |
| 111 | ```bash |
| 112 | git reset --hard # Should trigger shellfirm! |
| 113 | ``` |
| 114 | |
| 115 | For manual setup, shell-specific instructions, and Oh My Zsh plugin, see the [shell setup docs](https://shellfirm.vercel.app/docs/getting-started/shell-setup). |
| 116 | |
| 117 | --- |
| 118 | |
| 119 | ## Documentation |
| 120 | |
| 121 | Full documentation is available at **[shellfirm.vercel.app](https://shellfirm.vercel.app)**: |
| 122 | |
| 123 | - [Configuration](https://shellfirm.vercel.app/docs/configuration) — challenge types, severity thresholds, custom checks |
| 124 | - [Context-Aware Protection](https://shellfirm.vercel.app/docs/context-aware) — SSH, root, git branches, Kubernetes, environment variables |
| 125 | - [Team Policies](https://shellfirm.vercel.app/docs/team-policies) — `.shellfirm.yaml` project-level rules |
| 126 | - [AI Agents & Automation](https://shellfirm.vercel.app/docs/agents-and-auto |