PreToolUsematcher: Bash
Block rm -rf
Refuse destructive recursive deletes before Bash runs them.
Pre-tool guard that inspects Bash invocations and blocks dangerous `rm -rf` patterns against $HOME or /.
Install via CLI
npx hookyard install block-rm-rf
Or paste into ~/.claude/settings.json
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "node -e \"const i=JSON.parse(require('fs').readFileSync(0,'utf8'));const c=i.tool_input?.command||'';if(/rm\\s+-rf?\\s+(\\/|\\$HOME|~)/.test(c)){console.error('blocked: rm -rf on root/home');process.exit(2)}\""
}
]
}
]
}
}#security#guard
By developersdigest