Block destructive commands before your AI agent runs them.
CC Safety Net is a pre-execution hook for AI coding agents like Claude Code, Codex, and Cursor. It blocks destructive git and filesystem commands and secret file reads before they run, instead of trusting the agent to follow guidelines.
- MIT licensed
- Latest release v2.6.18, Oct 23, 2026
- 1,753 GitHub stars as of Oct 23, 2026
Works with every major coding agent
As of v2.6.18, one installer covers all 16 supported coding agents on macOS, Linux, and Windows.
It reads what the command does.
Wrapping a command in bash -c or reordering its flags doesn't hide it, and the safer version still goes through.
cc-safety-net · pre-exec hook
$ git push --force
✖ BLOCKEDgit.push-force
git push --force destroys remote history. Use --force-with-lease for safer force push.
$ git push --force-with-lease
✔ ALLOWED
Refuses to push when the remote moved since your last fetch.
Your secrets are off-limits. Even for reads.
Env files, SSH keys, cloud credentials, and coding agent tokens stay blocked in the shell and in the agent's own read, edit, write, and search tools.
$ cat .env
blocked
Reason: reads API keys and tokens from an environment file.
$ cp ~/.ssh/id_rsa /tmp/key
blocked
Reason: copies a private SSH key out of your key directory.
$ cat ~/.aws/credentials
blocked
Reason: reads AWS access keys from the credential store.
$ grep token ~/.claude/.credentials.json
blocked
Reason: reads your coding agent's own auth token.
Precise by default, strict when you need it
Pick a safety preset and switch protections on or off in a local dashboard instead of hand-editing JSON.
127.0.0.1:52341/?token=f3a9…
- $ $TOOL --force✔ allowed
- $ rm -rf ./build✔ allowed
- $ python -c "shutil.rmtree('build')"✔ allowed
Three examples. The preset applies to every command your agent runs.
Your commands never leave your machine.
The hook decides offline, the audit log stays in ~/.cc-safety-net, and there's no telemetry.
~/.cc-safety-net/logs/…/2026-10-01-a1b2c3.jsonl
{
"ts": "2026-10-01T13:16:56.213Z","decision": "deny","agent": "claude-code","toolName": "Bash","command": "GITHUB_TOKEN=<redacted> git push --force","ruleId": "git.push-force",…}Install in one command
The installer finds the coding agents on this machine and hooks into the ones you pick.
Questions, answered
What developers ask before they let an agent near their repository.
What is CC Safety Net?
CC Safety Net is a pre-execution hook for AI coding agents like Claude Code, Codex, and Cursor. It reads each shell command and file tool call before it runs, and blocks the ones that destroy work or expose secrets: git reset --hard, git push --force, rm -rf on your home directory, and reads of .env files, SSH keys, and cloud credentials. It supports 16 coding agent CLIs on macOS, Linux, and Windows, and is free and MIT licensed. It is not a sandbox.
How do I stop Claude Code, Codex, or Cursor from running git reset --hard or rm -rf?
git reset --hard or rm -rf?Install CC Safety Net with npx -y cc-safety-net@latest install, then run npx -y cc-safety-net@latest doctor to confirm the hook is active. It needs Node.js 18 or later. From then on, git reset --hard, git checkout -- ., git clean -f, git stash clear, and git push --force are denied, and the agent is told why and what safer command to use. rm -rf is blocked on your home directory, the filesystem root, and paths outside the project. Deleting inside the project is allowed unless you turn on the paranoid level.
Don't Claude Code's permission deny rules already do this?
It depends. Deny rules are deterministic and still apply in bypassPermissions mode, so if you only need to block a few exact commands in one CLI, they may be enough. Their limit is that they match the command string against a wildcard pattern. Reordered flags (rm -r -f), a shell wrapper (sh -c "..."), or an interpreter can slip past. CC Safety Net parses what the command does, so those variants are still caught. It also gives you one policy and one audit log across 16 CLIs instead of a separate format per tool. Many setups use both.
Doesn't Claude Code's auto mode already block git reset --hard?
git reset --hard?Partly. As of October 2026, Claude Code's auto mode uses a classifier model that blocks git reset --hard, git clean -fd, git stash clear, and similar commands by default. That's a judgment call, and Anthropic publishes a 17% false-negative rate for the classifier on real overeager actions. bypassPermissions mode asks about nothing. A CC Safety Net denial is a deterministic check: tested against Claude Code 2.1.251, it fires in default, auto, and bypassPermissions modes. If you review every command yourself in default mode, you may not need it.
Do I still need CC Safety Net if I run my agent in a sandbox or container?
If you care about uncommitted work, probably yes. A sandbox like Claude Code's or Codex's limits writes to the project directory and restricts network access. But git reset --hard and rm -rf . write inside that directory, and git push --force goes to a remote you allowed, so the sandbox permits all three. CC Safety Net blocks them. It does not contain processes or control the network. If your main worry is prompt injection, malicious dependencies, untrusted code, or data leaving over the network, a sandbox is the better choice. Use both.
Can I undo a destructive command with Claude Code checkpoints?
Not reliably. As of October 2026, Claude Code's checkpointing docs say checkpoints don't track files changed by bash commands. Only edits made through Claude's file editing tools can be rewound. git reset --hard, git clean, and rm all run as bash commands, so the work they discard is outside what a rewind restores. Containers have the same gap: a mounted working tree holds your real uncommitted work, and a push still reaches your real remote. Blocking the command before it runs is the safer layer, with Git commits for long-term history.
Does Claude Code block reading .env or ~/.aws/credentials by default?
.env or ~/.aws/credentials by default?No. As of October 2026, Claude Code's sandboxing docs say there is no built-in credential deny list, and its default read access still allows files such as ~/.aws/credentials and ~/.ssh/. Other CLIs offer opt-in deny settings that you write per tool. CC Safety Net blocks reads of .env files, SSH private keys, cloud credential stores, and coding agent auth tokens as soon as it is installed. That covers shell commands like cat .env and the agent's own read, edit, write, and search tools. You can add your own deny paths.
Does CC Safety Net send my commands anywhere? Is it free?
It is free and open source under the MIT license. The hook makes no network requests when it checks a tool call. Decisions are logged on your machine under ~/.cc-safety-net/logs. 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. Rulebook sync downloads rulebooks from GitHub. None of these sends your commands or file contents.
Will CC Safety Net block commands I actually need, and how do I tune it?
It can, so the levels are adjustable. The default standard level blocks recognized destructive patterns and lets ordinary commands and deletions inside the project run as usual. strict also blocks commands it cannot fully analyze. paranoid adds blocking rm -rf inside the project and python -c or node -e one-liners. Choose a level and turn individual rules on or off in npx cc-safety-net gui or in policy.json. Worktree mode allows local discards like git reset --hard inside a verified linked Git worktree. npx cc-safety-net explain shows why a command was blocked.

CC Safety Net
