Make Claude Code safe in 5 minutes. No coding required. Works on macOS, Linux, and Windows (WSL).
Hooks need jq to read JSON. Check if you have it:
jq --version
If not installed:
# macOS
brew install jq
# Ubuntu / Debian
sudo apt install jq
# Windows (in WSL)
sudo apt install jq
This installs 8 safety hooks and configures your settings.json:
npx github:yurukusa/cc-safe-setup
You'll see a list of hooks. Press Y to install.
Hooks load on startup. Close Claude Code and reopen it:
# In your terminal, exit Claude Code (Ctrl+C or type /exit)
# Then start it again
claude
Run the diagnostic to confirm everything is set up:
npx github:yurukusa/cc-safe-setup --doctor
All items should show ✓. If any show ✗, the doctor tells you how to fix it.
See how hooks react without actually running the command:
npx github:yurukusa/cc-safe-setup --simulate "rm -rf /"
You should see: ✗ BLOCK — destructive-guard
npx github:yurukusa/cc-safe-setup --simulate "git status"
You should see: → This command would trigger a permission prompt
Tired of approving ls, cat, and git log? This hook auto-approves commands that can't modify anything:
npx github:yurukusa/cc-safe-setup --install-example auto-approve-readonly
Reduces permission prompts by about 80%. Only commands that write, delete, or push still require approval.
npx github:yurukusa/cc-safe-setup --install-example auto-approve-test
npm test, pytest, go test, cargo test — all auto-approved.
For autonomous sessions where Claude runs unattended:
npx github:yurukusa/cc-safe-setup --shield
Installs everything from steps 1-6 plus: scope guard, memory write guard, skill gate, and project-specific hooks based on your tech stack.
The hooks run silently in the background. You won't notice them until they block something dangerous. When they do, you'll see a clear message explaining what was blocked and why.
--dangerously-skip-permissions. That was wrong. Measured on Claude Code
2.1.278 with a control: under that flag the guard was consulted and refused the command, exit 2.
What it removes is the human prompt, not your hooks.
--restricted and --safe-mode — and their environment-variable forms,
CLAUDE_CODE_RESTRICTED=1 and CLAUDE_CODE_SAFE_MODE=1, which behave
identically but are far easier to set once and forget. Under --restricted you can
pass hooks back in with --settings; under --safe-mode you cannot, and
the dangerous tools keep working normally.
--bare says in its own help that it skips hooks. We have not measured it: it reads
only ANTHROPIC_API_KEY or an apiKeyHelper, never OAuth, so on a
subscription login it exits with Not logged in before any of this matters.
See the README section “Four ways your guards stop running at all”.
npx cc-health-check for a free safety score, or get a Professional Safety Audit (from $50) — custom hooks and recommendations for your workflow.
Learn more: Security Checkup (6 questions) · Hook Selector (5 questions) · Token Consumption Fix · Token Book (¥2,500) · Safety Guide · All Tools