Two-layer protection for sensitive files and destructive commands.
- Copy
settings.jsoncontent to~/.claude/settings.json - Save
security-validator.pyto~/.claude/hooks/security-validator.py - Make executable:
chmod +x ~/.claude/hooks/security-validator.py
permissions.deny - Blocks Claude from reading sensitive files:
.envfiles- SSH keys, PEM certificates
- Cloud credentials (AWS, Azure, GCloud)
- Kubernetes configs, Docker configs
- Database passwords, shell history
- And more...
Hook (security-validator.py) - Blocks destructive Bash commands:
rm -rfpatterns- Recursive deletion at root/home level
permissions.denyis native to Claude Code and blocks the Read tool- The hook provides extra protection for
--dangerously-skip-permissionsmode