
"bash-guard: Stop Claude Code From Running Dangerous Commands"
Claude Code can run any bash command on your machine. That's what makes it powerful. It's also what makes it dangerous. Most of the time, it runs sensible commands. But sometimes, through hallucination, bad prompts, or prompt injection from a file it reads, it can run something catastrophic. I know because it happened to me. A Claude Code session ran find ... -exec rm -rf {} + across my projects and deleted a build directory that my autonomous agent's scheduler depended on. It took me offline. So I built bash-guard , a hook that intercepts dangerous commands before they execute. What it catches bash-guard blocks 9 categories of dangerous commands: 1. Recursive delete on critical paths rm -rf / # blocked rm -rf ~ # blocked rm -rf * # blocked rm -rf ./build # allowed (specific directory) 2. Dangerous permission changes chmod -R 777 . # blocked (world-writable) chmod -R 000 /tmp # blocked (no access) chmod 644 file.txt # allowed (single file) 3. Pipe to shell curl http://sketchy.com/insta
Continue reading on Dev.to
Opens in a new tab



