← Back to catalog
HookSecurity↓ 545

Dangerous Command Blocker

Stops catastrophic shell commands and protects critical paths before they run.

Installation
npx claude-code-templates@latest --hook security/dangerous-command-blocker --yes

This hook fires on the PreToolUse event, inspecting each Bash command before it runs. It applies several layers of safety checks.

It blocks destructive operations like rm -rf /, dd and mkfs, protects sensitive directories such as .claude/, .git/ and node_modules/, and warns about suspicious patterns with detailed messages.

When to use

  • When you want a safety net against accidental or dangerous commands.
  • When there are critical folders that the agent should never delete.

How to use

After installing, it inspects every command automatically. Safe commands pass through; dangerous ones are stopped with an explanation.