by kaplanelad
Safety guardrails for ai coding agents and human terminal commands
# Add to your Claude Code skills
git clone https://github.com/kaplanelad/shellfirmshellfirm is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by kaplanelad. Safety guardrails for ai coding agents and human terminal commands. It has 954 GitHub stars.
shellfirm's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/kaplanelad/shellfirm" and add it to your Claude Code skills directory (see the Installation section above).
shellfirm is primarily written in Rust. It is open-source under kaplanelad on GitHub, so you can review or fork the full source.
Yes. AgentsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh shellfirm against similar tools.
No comments yet. Be the first to share your thoughts!
Unlocks once the catalog security scan passes (runs nightly).
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
Think before you execute.
Humans make mistakes. AI agents make them faster. shellfirm intercepts dangerous shell commands before the damage is done.
% 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, 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)
This is real output, captured in zsh with default settings on the protected
main branch. (In bash the banner starts after a blank line. Off a protected branch the challenge is not escalated, and the banner
also tells you how to stop being asked: shellfirm config ignore <id>; that
hint is left out when the context raised the challenge.) The
exact output depends on the command, your settings and where you run it. The
challenge is a small math problem, pressing Enter, or typing yes: the higher
the severity and the riskier the context (protected branch, SSH, root,
production cluster), the stricter the challenge. Commands on a deny list are
blocked outright. Prefer no math? See Accessibility.
curl … | bash (shell), credential exfiltration (exfil), …), all on by default. List them with shellfirm check --list --all; the generated check catalogue has the exact, current count.shellfirm status shows which shells have the hook installed.--force-with-lease)Critical, High, Medium, Low, Info).shellfirm.yaml with rules that everyone in the repo gets, or install an org-wide baseline at /etc/shellfirm/policy.yaml. Policies are additive and enforced: personal settings cannot weaken them. See docs/team-policies.md.shellfirm audit show --since 7d --outcome denied. See docs/audit.md.shellfirm audit replay reads the session transcripts Claude Code and Codex CLI keep on disk and reports what shellfirm would have blocked or asked about, worst first, without running anything or writing anywhere. Before you connect the hook, it shows what the hook would catch; --redact makes a shareable summary and --fail-on deny fits CI. See docs/audit.md.blast_radius_budget_ms, default 400 ms, at most 5000; shellfirm config impact-budget <ms>) so the prompt never waits long; a count that runs out of time says more than 120,000 files (stopped counting), a step it could not start says skipped, no time left. When it takes longer than 200 ms a transient shellfirm: checking impact… (Ctrl-C cancels) line shows; Ctrl-C there cancels the command and records it in the audit logmin_severity still asks✓ approved — running: <command> (dim, on the terminal only), so a slow command such as helm uninstall does not look hung. Turn it off with shellfirm config approved-notice offshellfirm config llm; used only to review AI-agent commands when agent.llm_review is enabledOne command sets up both automatic safety (hooks) and on-demand analysis (MCP):
shellfirm connect claude-code
This adds:
To see what the hook would have caught in your earlier sessions, run
shellfirm audit replay (read-only; nothing is executed).
Safe commands get no answer from the hook, so Claude Code's own permission
rules decide whether it asks you (the shellfirm 0.3.10 hook approved them
outright). After upgrading from 0.3.10, re-run shellfirm connect claude-code; see Upgrading from 0.3.10.
To enforce the hook for every user of a machine, put it in Claude Code's
managed settings (connect does not write that file):
docs/agents.md has the entry, and
shellfirm status lists it as claude-code (managed).
The hooks read the command text; a script or child process that opens
~/.ssh/id_rsa at runtime never shows up in it. Turn on the agent's own OS
sandbox and deny it the credential files shellfirm protects:
shellfirm sandbox claude-code # settings.json `sandbox`: enabled + denyRead/denyWrite
shellfirm sandbox codex # ~/.codex/config.toml permission profile
shellfirm sandbox --list # supported agents and the denied paths
Existing settings are merged, --dry-run shows the change and --remove
takes out only what shellfirm added. Settings of yours that re-open a denied
path, or a project file that turns the sandbox off or re-opens one, are
reported by the command and by shellfirm status / doctor. Other agents (Gemini CLI,
Copilot CLI, Cursor, …) are not supported; shellfirm sandbox <agent> says
why. See Agent sandbox.
shellfirm connect <agent> installs a hook that runs before the agent's
shell commands (and, where the agent has them, file edits and reads) and
blocks what shellfirm denies. Where the agent can ask you, risky commands
ask; where it cannot, they are blocked with the reason and a safer
alternative, so you can run them yourself.
| Agent | connect |
Hook | Risky (ask) |
Written to (user scope) |
|---|---|---|---|---|
| Claude Code | claude-code |
PreToolUse |
asks | ~/.claude/settings.json ($CLAUDE_CONFIG_DIR) |
| Cursor | cursor |
beforeShellExecution, preToolUse, beforeReadFile |
asks (commands) | ~/.cursor/hooks.json |
| OpenAI Codex CLI ≥ 0.124 | codex |
PreToolUse (Bash, apply_patch) |
blocked | ~/.codex/hooks.json |
| Gemini CLI ≥ 0.36 | gemini |
BeforeTool |
asks | ~/.gemini/settings.json |
| Qwen Code | qwen |
PreToolUse |
asks | ~/.qwen/settings.json |
| GitHub Copilot CLI ≥ 1.0.4 | copilot |
preToolUse |
asks | ~/.copilot/hooks/shellfirm.json |
| Windsurf (Cascade) | windsurf |
pre_run_command, pre_write_code, pre_read_code |
blocked | ~/.codeium/windsurf/hooks.json |
| Cline ≥ 3.36 | cline |
PreToolUse script |
blocked (cancels the task) | ~/Documents/Cline/Hooks/PreToolUse |
| OpenCode | opencode |
plugin (tool.execute.before) |
blocked | ~/.config/opencode/plugins/shellfirm.js |
| Zed | zed |
MCP tools only (advisory) | — | ~/.config/zed/settings.json |
Claude Code, Cursor, Windsurf and Cline also get shellfirm's MCP server.
--scope project writes the hook into the repository for the whole team,
--dry-run shows the change first, --uninstall removes only shellfirm's
entries, and shellfirm status / shellfirm doctor show what is installed.
Codex runs a new hook only after you trust it (it asks when it starts), and
Cline's VS Code extension needs "Enable Hooks" turned on. Details per agent:
docs/agents.md.
| Tool | Description |
|---|---|
check_command |
Check if a command is risky — returns severity, matched rules, and alternatives |
suggest_alternative |
Get safer replacement commands |
explain_risk |
Detailed explanation of why a command is dangerous |
get_policy |
Read the active shellfirm configuration |
Upgrading from 0.3.10? Upgrading the package only replaces the binary. Read Upgrading from 0.3.10: restart your shells, re-run shellfirm init <shell> for elvish, xonsh and nushell and shellfirm connect <agent> for each agent, fix CI scripts for the new exit codes, and enable the new default groups (shellfirm status shows the command).