Claude Code is powerful. It can write code, run commands, push to git, and modify any file on your system.
That last part should concern you.
By default, Claude Code has no safety rails. No command is blocked. No file is protected. A user recently lost their entire C:\Users directory when Claude ran rm -rf that followed NTFS junctions.
Here's how to fix that in 60 seconds.
npx cc-safe-setupThis installs 8 hooks that:
- Block
rm -rf /,git reset --hard,git clean -fd - Prevent pushes to main/master
- Stop
git add .envfrom leaking secrets - Catch syntax errors after every file edit
- Warn when context window is running low
npx cc-safe-setup --doctor13 automated checks. Everything should show a checkmark.
npx cc-safe-setup --simulate "rm -rf /"
# BLOCK — destructive-guard
npx cc-safe-setup --simulate "git status"
# This command would trigger a permission promptThat's it. 60 seconds. Your Claude Code session is now protected against the most common accidents.
Reduce permission prompt fatigue:
npx cc-safe-setup --install-example auto-approve-readonlyAuto-approves cat, ls, grep, git log — commands that can't modify anything. Reduces prompts by ~80%.
Maximum safety for overnight sessions:
npx cc-safe-setup --shieldWhy hooks instead of CLAUDE.md rules?
CLAUDE.md rules live in the AI's context. When context fills up and gets compressed, rules can be lost. Hooks run at the process level — outside the AI's context. They can't be forgotten, ignored, or "interpreted as an exception."
Exit code 2 from a hook = the tool call is physically blocked. The AI cannot bypass it.
cc-safe-setup is open source (MIT). 718 hooks, 9,200+ tests.
GitHub: github.com/yurukusa/cc-safe-setup