日本語の無料診断ツール(費用・データ喪失・版の失敗・権限・設定の罠) 診断ツール集を見る →

Stop Claude Code from deleting your files

Claude Code is Anthropic's AI coding agent that runs commands in your terminal. Without guardrails, it can delete files, leak secrets, or force-push to production.

One command installs safety hooks that block destructive commands before they execute. 892 example hooks, 213 test files, 30K+ npm downloads (cumulative).

npx cc-safe-setup

8 core safety hooks installed in under 30 seconds. No config needed.

View on GitHub Try Live Demo Opus 4.7 Survival Guide (66 sections)

Real incidents from GitHub Issues: 50GB data loss, $1,446 unauthorized transfer, production server destroyed

🔥 New: /rewind deleted my code — recover it · Max usage burn check (why am I hitting limits so fast?) · Safety Scorecard (score & share your setup) · Team Governance Scorecard (is your org governed?) · Attack Simulator (10 scenarios) · Risk Assessment · Incident Tracker (90 incidents)

GitHub Stars Weekly installs

1

Install

Run npx cc-safe-setup. 8 hooks installed in 30 seconds.

2

Protect

Hooks intercept rm -rf, force-push, credential leaks before they execute.

3

Monitor

Track token consumption, detect quota drain, get alerts before it's too late.

Safety AND Convenience — our most popular hook auto-approves safe git commands, reducing clicks while blocking dangerous ones.

ONE-TIME · CUT YOUR TOKENS IN HALF

Token Book — $17

800+ hours of data. 48 token drain symptoms. Copy-paste templates.

MONTHLY · STAY AHEAD OF INCIDENTS

CC Safety Lab — ¥500/mo

Monthly digest: 4-8 incidents, hooks, token-saving techniques. First month free.

Tokens disappearing? Take the free Token Checkup — 5 questions, 30 seconds. Find out what's draining your quota. | Token Book — $17 800h of data, copy-paste templates | Safety Lab — ¥500/mo monthly incident digest | Rolling out to a team? org audit, training & CI gates (法人向け 日本語)

Safety Audit

Paste your ~/.claude/settings.json. Nothing leaves your browser.

Hook Builder

Build a custom hook without writing code.

Hooks Cookbook

Copy-paste recipes from real GitHub Issues.

Ecosystem Comparison

All major Claude Code hook projects compared.

ProjectLangHooksInstall
safety-netTS5npx
cc-safe-setupBash707+npx
karanb192JS5+copy
masteryPython12copy
lassoPython1install.sh

Feature Matrix

Featuresafety-netcc-safe-setupkaranb192mastery
rm -rf blocker
Branch guard--
Secret guard--
Syntax check---
Context monitor---
Hook generator---
Dashboard---
GitHub Action---

Hooks Cheat Sheet

Print this page (Ctrl+P) for a quick reference.

Lifecycle

Prompt → PreToolUse → Tool → PostToolUse → Stop

Exit Codes

CodeMeaning
0Allow
2Block

Minimal Block Hook

#!/bin/bash
CMD=$(cat | jq -r '.tool_input.command // empty')
[ -z "$CMD" ] && exit 0
echo "$CMD" | grep -qE 'PATTERN' && echo "BLOCKED" >&2 && exit 2
exit 0

Auto-Approve Hook

#!/bin/bash
CMD=$(cat | jq -r '.tool_input.command // empty')
[ -z "$CMD" ] && exit 0
echo "$CMD" | grep -qE '^git\s+(status|log|diff)' && \
  jq -n '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"allow"}}'
exit 0

Quick Commands

npx cc-safe-setupInstall 8 hooks
--create "desc"Generate hook
--auditScore 0-100
--dashboardLive status
--doctorDiagnose
--benchmarkSpeed test

How healthy is your Claude Code setup?

Run a free 20-check diagnostic. Takes 2 seconds, nothing leaves your machine.

npx cc-health-check

30K+ npm downloads (cumulative) · 892 example hooks · Production Guide (Zenn Book)

Prevent real incidents:

rm -rf disasters Force-push to main Secret leaks git reset --hard Cascading syntax errors Dependency bloat Temp file buildup Auto Mode safety Hook if field (v2.1.85) Shell variable trap Session drift Token waste Cost explosion bash -x debug leak Post-compact push Hook testing guide Autonomous safety CLAUDE.md best practices Co-Authored-By control Fix git show --no-stat Disable auto-compaction WebFetch domain fix Pipe mode safety Session degradation Denied action retry Background agent writes