Cc Safety Net
Block destructive AI agent commands before they run
Replaces —

Who it's for
When an AI coding agent runs without per-command confirmation, there is no human review before `git reset --hard` or `git push --force` executes. CC Safety Net adds a deterministic check that fires even when the agent's own permission prompts are disabled.
You review every agent command manually in a default-mode CLI
Committing `.cc-safety-net/` to the repository distributes the same ruleset to every contributor and to cloud-based CI or agent sessions that clone the repo, without requiring each developer to configure the tool individually.
You are working alone on a single machine
On machines where `.env` files, SSH keys, or cloud credentials are present, CC Safety Net blocks reads of those files from the shell and from the agent's file tools the moment it is installed, without requiring per-CLI deny-list configuration.
Your agent runs in a fully isolated environment with no credentials present
The `checkCommand` function is callable from Node.js without installing the shell hook, so security checks can be embedded directly in tooling that wraps or orchestrates agent commands.
The problem
AI coding agents operating in autonomous or semi-autonomous modes can run destructive commands like `git reset --hard`, `git push --force`, or `rm -rf` that permanently discard uncommitted work or rewrite remote history. They can also read sensitive files such as `.env`, SSH keys, and cloud credentials. Built-in permission systems in individual CLIs match command strings against patterns, which means reordered flags or shell wrappers can slip past them. CC Safety Net addresses this by parsing what each command would actually do and blocking it before execution, across all supported coding agents under one policy.
How it works
The hook parses what a command does rather than matching its string. `bash -c 'git reset --hard'` is unwrapped and evaluated the same as the bare command, so flag reordering and shell wrappers do not bypass the check.
Reads of `.env` files, SSH private keys, `~/.aws/credentials`, and coding agent auth tokens are blocked in the shell and in the agent's own read, edit, write, and search tools, as soon as the hook is installed.
One installer covers Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot CLI, Devin CLI, Factory Droid, and nine more CLIs on macOS, Linux, and Windows as of v2.7.13.
Running `npx cc-safety-net gui` opens a dashboard on 127.0.0.1 where you can switch between Standard, Strict, and Paranoid presets and toggle individual rules. Nothing leaves the machine.
Every allow and deny decision is written to `~/.cc-safety-net/logs` as a JSONL file with timestamp, agent name, tool name, command, and rule ID. Secrets in commands are redacted in the log.
Official rulebooks are available for Terraform, AWS, gcloud, and Azure. Custom rulebooks can be added in JSON. The `.cc-safety-net/` directory can be committed so clones and cloud sessions share the same policy.
Features
- Command intent parsing
- Secret file protection
- 16 coding agent CLIs supported
- Local policy GUI
- Offline audit log
- Rulebook extensions
How to install
npx -y cc-safety-net@latest install
Recommended for this setup
Strengths
- Works in bypassPermissions mode: Tested against Claude Code 2.1.251, CC Safety Net's denials fire in default, auto, and bypassPermissions modes. The classifier-based protection in Claude Code's auto mode has a published 17% false-negative rate; CC Safety Net's checks are deterministic.
- No network requests at check time: The hook decides offline. Only a few commands you run yourself go online: `doctor` checks the npm registry for a newer version, the GUI fetches the GitHub star count, and rulebook sync downloads rulebooks from GitHub. Your commands and file contents are never sent anywhere.
- Covers gaps that sandboxes leave open: Sandboxes restrict writes to the project directory and limit network access, but `git reset --hard` and `rm -rf .` write inside that directory and `git push --force` goes to a remote the sandbox already allowed. CC Safety Net blocks those operations regardless of the execution environment.
- Worktree mode for legitimate local discards: Worktree mode allows local discards like `git reset --hard` inside a verified linked Git worktree, so you can tune the policy to match your workflow rather than applying a blanket block.
Trade-offs
- Not a sandbox: CC Safety Net does not contain processes, set filesystem permissions, or watch network egress. It blocks specific destructive patterns but does not prevent an agent from exfiltrating data over the network or running arbitrary code outside the blocked rule set.
- Requires Node.js 18 or later: The hook and installer depend on Node.js 18 or higher. Machines without a compatible Node.js runtime need one installed before setup.
- Paranoid level may block legitimate one-liners: The paranoid preset blocks `python -c` and `node -e` one-liners and `rm -rf` inside the project directory. Teams that use inline scripts as part of their workflow will need to adjust the policy or drop to a lower preset.
- Covers shell commands and file tools, not every agent capability: Protection is scoped to shell command execution and file tool calls. Agent behaviors that do not go through those surfaces, such as making API requests or writing to agent-specific state stores, are outside the hook's reach.
Tech stack
FAQ
Yes. Tested against Claude Code 2.1.251, CC Safety Net's denials fire in default, auto, and bypassPermissions modes. Claude Code's auto mode classifier has a published 17% false-negative rate on real overeager actions; CC Safety Net's checks are deterministic and not affected by the classifier.
It can at higher presets. The default Standard level blocks recognized destructive patterns and allows ordinary commands and deletions inside the project. Strict also blocks commands it cannot fully analyze. Paranoid adds blocking of `rm -rf` inside the project and `python -c` or `node -e` one-liners. You can tune individual rules on or off in the GUI (`npx cc-safety-net gui`) or in `policy.json`.
Not entirely. Sandboxes limit writes to the project directory and restrict network access, but `git reset --hard`, `rm -rf .`, and `git push --force` are permitted inside that scope. CC Safety Net blocks those operations. If your primary concern is prompt injection, malicious dependencies, or data leaving over the network, a sandbox addresses that; the two are complementary.
No commands or file contents are sent anywhere. Decisions are made offline and logged locally under `~/.cc-safety-net/logs`. Only three self-initiated actions go online: `doctor` checks the npm registry for a newer version, the GUI fetches the GitHub star count, and rulebook sync downloads rulebooks from GitHub.
Run `npx -y cc-safety-net@latest install` to hook into the coding CLIs on your machine, then run `npx -y cc-safety-net@latest doctor` to confirm the hook is active. Node.js 18 or higher is required. Keep the `@latest` qualifier to avoid running an older copy from the npx cache.