Safety and productivity hooks for Claude Code.
A hook system that intercepts Claude Code's PreToolUse, PostToolUse, and Notification events to enforce safe coding practices, block dangerous operations, and provide desktop integration. Written in Rust for minimal latency on every tool call.
- Dangerous command blocking — prevents
sudo, destructiverm,chmod 777,ddto block devices,mkfs/wipefs, fork bombs, and more - Tool enforcement — blocks
grep/find/catand suggestsrg/fd/dedicated tools; blocks hardcoded/tmppaths (usemktemp); blocks uselesscatpatterns - Sensitive file protection — guards SSH keys, cloud credentials,
.envfiles, GPG keyrings, shell history, password databases, and more across Read/Write/Edit/Grep/Bash tools - Python prevention — blocks
.pyfile creation and inlinepythonusage - Desktop notifications — Hyprland-aware notifications via
notify-sendwhen Claude finishes work in an unfocused window - Shell syntax checking — validates commands with
bash -n,shellcheck, andshfmtbefore execution - File operation sandboxing — restricts
rm/mv/cpto project directories,~/.claude/, and/tmp/ - Cargo auto-approval — allows
cargocommands to proceed without prompting
- Rust 1.87.0+ (2024 edition)
- shellcheck
- shfmt
- rg (ripgrep)
- fd
Optional (Hyprland-only):
hyprctlandnotify-send— desktop notifications when Claude finishes work in an unfocused window. Requires Hyprland for window-focus detection.
Install script (recommended) — auto-detects architecture and installs to ~/.local/bin:
curl -fsSL https://raw.githubusercontent.com/RichAyotte/rich-blocks-claude/main/install.sh | shSet INSTALL_DIR to change the install location:
curl -fsSL https://raw.githubusercontent.com/RichAyotte/rich-blocks-claude/main/install.sh | INSTALL_DIR=/usr/local/bin shBuild from source:
cargo install --git https://github.com/RichAyotte/rich-blocks-claudeThen register the plugin manually:
claude plugin marketplace add RichAyotte/claude-plugins
claude plugin install rich-blocks-claude@rich-plugins --scope userThe install script handles this automatically; these commands are only needed for build-from-source installs.
Behavior can be customized via ~/.config/rich-blocks-claude/settings.json (or $XDG_CONFIG_HOME/rich-blocks-claude/settings.json). All fields are optional — missing fields use defaults, and a missing or malformed file uses all defaults.
{
"notify_cmd": "notify-send",
"file_ops_allowed": ["$HOME/.claude/", "/tmp/", "./src/", "./tests/", "./target/", "./docs/"],
"shellcheck_exclude": "SC1091,SC2086,SC2046,SC2035",
"auto_approve_prefixes": ["cargo clippy", "cargo check", "cargo fmt", "cargo test", "cargo build", "cargo run", "cargo doc", "cargo clean", "cargo update", "cargo tree", "cargo metadata"]
}| Field | Default | Description |
|---|---|---|
notify_cmd |
"notify-send" |
Command used for desktop notifications. Set to "" to disable. |
file_ops_allowed |
(see above) | Paths where rm/mv/cp are permitted. $HOME is expanded. |
shellcheck_exclude |
"SC1091,SC2086,SC2046,SC2035" |
Comma-separated shellcheck error codes to suppress. |
auto_approve_prefixes |
(see above) | Commands matching these prefixes skip the permission prompt. |