Claude Code Rm Guard — Development skill for Claude Code
Stop Claude Code from accidentally running rm -rf ~ or other catastrophic commands.
How to install Claude Code Rm Guard
This entry records only its repository, not the path inside it, so there is no
exact command to give. Open elertan/claude-code-rm-guard and copy the folder into
~/.claude/skills/, or the file into ~/.claude/agents/.
What Claude Code Rm Guard does
Stop Claude Code from accidentally running rm -rf ~ or other catastrophic commands.
Alternatives in Development
- Maestro Guard — Manage editing boundary restrictions 530 ★
- Voice Guard — Use to check ONE already-written piece of copy against a voice guide before it ships — it spawns ONE fresh sib 130 ★
- Check Gitignore — Check and update .gitignore to exclude Plan Cascade temporary files 123 ★
README
claude-code-rm-guard
**Important to note:** Claude Code's sandboxing feature (https://code.claude.com/docs/en/sandboxing) seems like a much better way to solve this problem, or otherwise using devcontainers. If that isn't what you want, then maybe this hook will help!
🛡️ Security hook for [Claude Code](https://docs.anthropic.com/en/docs/claude-code) that prevents destructive file operations outside your working directory.
Stop Claude from accidentally running `rm -rf ~/` or other catastrophic commands.
Quick Install
curl -fsSL https://raw.githubusercontent.com/elertan/claude-code-rm-guard/main/install.py | python3
The installer will:
- Download the hook to
~/.claude/hooks/validate-rm.py - Add the hook configuration to
~/.claude/settings.json - Optionally add ask permissions for rm/unlink/rmdir (recommended)
**Uninstall:**
curl -fsSL https://raw.githubusercontent.com/elertan/claude-code-rm-guard/main/install.py | python3 - --uninstall
Features
- Path Validation: Blocks
rm,unlink,rmdir, andshredcommands targeting paths outside your project directory - Shell-Aware Parsing: Uses Python's
shlexwithpunctuation_chars=Truefor proper handling of pipes, chains, and quoted arguments - Recursive Analysis: Detects dangerous commands hidden in
sudo,xargs,find -exec,bash -c, and other wrappers - Safety-First Blocking: Commands with unresolvable paths (variables, globs, command substitution) are blocked by default
- Zero Dependencies: Pure Python 3, no external packages required
How It Works
When Claude Code attempts to run a Bash command:
- Hook Receives Input: Claude Code sends JSON via stdin with
tool_name,tool_input.command, andcwd - Command Parsing: The script uses
shlexto tokenize the command, splitting on;,|,&&,|| - Recursive Analysis: Each subcommand is analyzed, unwrapping
sudo,bash -c, etc. - Path Resolution: Target paths
Related Skills
PM Guard
Never accidentally npm install in a pnpm project again — guards npm, yarn, pnpm, bun, and deno.
Claude Code Japanese Guard
Claude Code の応答が英語に切り替わったら、日本語で書き直させる Stop hook
8sync
One Rust binary that runs Anthropic's Claude Code on autopilot, with rails: five levels of hands-off work (/do
Enable Auto Mode
Stop auto-guard prompts for one category so auto mode can cover it — /enable-auto-mode
Guard
Safety guardrails — blocks destructive commands (rm -rf, DROP TABLE, force-push) and optionally restricts edit
Skill S05 Stage Machine Guard
SKILL_S05: stage-machine-guard
Related Agents
Part 11: Auto-Capture Hook (Stop Manually Writing Memory)
By Terp - Terp AI Labs --- The vault system from Part 9 is powerful, but there's a gap: you have to manually w
Book Genesis Blind Reader
Blind reader for the book-genesis skill. Reads only the prose it is handed and reports where a reader would st
Mission Planner.Agent
Breaks a LongRun mission into phases, workstreams, artifact expectations, and verifiable stop conditions.