Skip to the content.

bash-guard

PreToolUse hook that denies destructive shell commands before Claude Code runs them: recursive delete of / or home, force-push, hard reset to the remote default branch, git clean -f, curl | sh, chmod 777, raw disk writes, mkfs, and destructive SQL.

Install: claude plugin install bash-guard@ralpberry-plugins

Per-project rules in .claude/bash-guard.json:

{
  "deny": [{ "pattern": "\\bterraform\\s+destroy\\b", "reason": "Destroy only runs from the pipeline." }],
  "ask":  [{ "pattern": "\\bkubectl\\s+delete\\b", "reason": "Deleting cluster resources." }],
  "disable": ["chmod-777"]
}

Limits: matches command text with regular expressions. It is a guard rail against accidents, not a sandbox against deliberate obfuscation.