# Claude Code Safety Net — Block Destructive Commands > cc-safety-net adds a safety gate for Claude Code tool calls: explain/score risky commands (rm -rf, git resets) and validate custom rules (1,330★). ## Install Save the content below to `.claude/skills/` or append to your `CLAUDE.md`: ## Quick Use ```bash npx cc-safety-net doctor npx cc-safety-net explain "rm -rf /" npx cc-safety-net explain --json "git checkout -- file.txt" npx -y cc-safety-net --verify-config ``` ## Intro cc-safety-net adds a safety gate for Claude Code tool calls: explain/score risky commands (rm -rf, git resets) and validate custom rules (1,330★). **Best for:** Teams letting agents run shell commands but needing guardrails, auditability, and consistent “deny by default” rules **Works with:** Claude Code native hooks/plugins, npx-based installs, and JSON outputs for automated gating **Setup time:** 5-12 minutes ## Main - **Command risk UX**: provides explainers for destructive commands before execution. - **Custom rules**: supports defining policy rules (block global npm installs, dangerous docker actions, etc.). - **Validation gate**: documents a `--verify-config` step so config changes are checked before you rely on them. - **Agent-friendly outputs**: includes JSON mode so an agent runner can decide allow/deny deterministically. ### FAQ - **Is this only for Claude Code?**: It is designed around Claude Code hooks/commands, but the patterns are reusable for other agent runners. - **How do I start safely?**: Run `doctor`, then try `explain` on a few commands you commonly see in agent sessions. - **Why validate configs?**: A broken rule file can silently disable protections; validation keeps the gate trustworthy. ## Source & Thanks > Source: https://github.com/kenryu42/claude-code-safety-net > License: MIT > GitHub stars: 1330 · forks: 62 --- ## Quick Use ```bash npx cc-safety-net doctor npx cc-safety-net explain "rm -rf /" npx cc-safety-net explain --json "git checkout -- file.txt" npx -y cc-safety-net --verify-config ``` ## Intro cc-safety-net 为 Claude Code 的工具调用加安全闸:解释/评估高风险命令(rm -rf、git reset 等),支持自定义规则校验并提供 JSON 输出(1,330★)。 **Best for:** 允许 agent 执行 shell 命令但需要护栏、可审计与一致规则(默认拒绝危险动作)的团队 **Works with:** Claude Code 原生 hooks/plugins、npx 安装方式,以及可用于自动化的 JSON 输出 **Setup time:** 5-12 minutes ## Main - **命令风险解释**:在执行前解释高风险命令的影响,减少误操作。 - **支持自定义规则**:可配置策略(例如阻止全局 npm 安装、危险 docker 指令等)。 - **配置校验闸门**:提供 `--verify-config`,避免手改规则导致失效。 - **JSON 友好**:支持 JSON 模式,让 allow/deny 决策更可复现。 ### FAQ - **只适用于 Claude Code 吗?**:主要围绕 Claude Code hooks/commands,但思路也可迁移到其他 agent runner。 - **如何安全起步?**:先跑 `doctor`,再对常见命令做 `explain` 看看风险分类是否符合预期。 - **为什么要校验配置?**:规则文件一旦写错可能导致护栏失效;校验能保证闸门可信。 ## Source & Thanks > Source: https://github.com/kenryu42/claude-code-safety-net > License: MIT > GitHub stars: 1330 · forks: 62 --- Source: https://tokrepo.com/en/workflows/claude-code-safety-net-block-destructive-commands Author: Script Depot