Implement guardrail hooks for dangerous operation prevention
- Add PreToolUse hook intercepting Bash, Write, Edit - Block catastrophic commands (rm -rf /, mkfs, etc.) - Require confirmation for operations outside safe paths - Git-aware: operations in git repos are allowed - Session allowlist for user-confirmed operations - Audit logging to logs/guardrail.jsonl - Clear session allowlist on SessionEnd Config: state/guardrails.json Scripts: hooks/scripts/guardrail.py, guardrail-confirm.py 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -132,6 +132,17 @@
|
||||
"to-do",
|
||||
"pending"
|
||||
]
|
||||
},
|
||||
"guardrails": {
|
||||
"description": "PreToolUse hook that prevents dangerous operations (rm -rf, system commands, etc.)",
|
||||
"script": "~/.claude/hooks/scripts/guardrail.py",
|
||||
"config": "~/.claude/state/guardrails.json",
|
||||
"triggers": [
|
||||
"guardrail",
|
||||
"safety",
|
||||
"block dangerous",
|
||||
"protect"
|
||||
]
|
||||
}
|
||||
},
|
||||
"commands": {
|
||||
|
||||
Reference in New Issue
Block a user