HookPartly tested (needs an account)
Block dangerous commands
cc-safety-net
A safety hook that checks every shell command your agent wants to run and blocks destructive ones, such as deleting your home folder or a hard git reset.
- Works with
- Claude Code, Codex CLI, Gemini CLI
- Good for
- Security testing, Everyone
What it does
CC Safety Net is a guard for your AI assistant. Before the assistant runs a command in the terminal, the guard checks what the command would do. If the command is dangerous, the guard blocks it. The assistant then gets a message that says why.
The guard looks at the real meaning of a command. It does not only match words. A dangerous command stays blocked if the assistant hides it inside bash -c or python -c, or if it changes the order of the flags. Since version 2.6.19 it also blocks Python, Perl, Node or Ruby code that deletes the root folder or your home folder with everything inside, for example shutil.rmtree('/'), at every safety level.
Three groups of actions are blocked. The first group is destructive commands, such as git reset --hard, git push --force, and rm -rf on risky targets. The second group is access to secrets. This covers SSH keys, .env files (files that hold passwords), ~/.aws, and the login files of coding tools.
The third group came in version 2.7.0. It blocks commands that read a cloud metadata address, where cloud servers hand out their credentials. It blocked curl and wget commands that send data or a file to a host that is not your own computer (localhost). Since version 2.7.3 this rule works only at the Strict and Paranoid levels. It also blocks unshare options that make a user namespace, a way to act as root inside a private space. The guard now also checks shell scripts that a command runs from a file, such as sh evil.sh.
Version 2.7.1 (30 October 2026) blocks code that comes from the internet and goes straight into a program, for example curl … | python3 - or irm … | iex in PowerShell. It also blocks a file that is downloaded and then run in the same command. Assistants that can ask you show a question; modes that cannot ask, such as bypassPermissions, refuse. Version 2.7.2 (2 November 2026) closes a gap: secret reads hidden behind env, sudo or command options, such as env -i bash -c 'cat ~/.npmrc', are now blocked too.
Version 2.7.3 (4 November 2026) changes the upload rule. At the default Standard level, curl and wget uploads to other hosts are allowed again. The release says this "clears false positives on read-only JSON-RPC, GraphQL, and webhook requests". It also says uploads of secret files such as .env stay blocked at every level. Strict and Paranoid still block all uploads to other hosts. To block them at Standard too, turn on network.upload-remote. The same release blocks deletes such as rm -rf "$X" when the terminal is in your home folder, and makes Paranoid at least as strict as Strict for script files.
Version 2.7.4 (6 November 2026) teaches the guard PowerShell here-strings, blocks of text between @' and '@. Text inside them, such as source code piped to python -, is no longer blocked as if it were a command, when the guard reads the command as PowerShell. Destructive commands that came after a here-string or went through Invoke-Expression are now blocked.
Version 2.7.6 (8 November 2026) fixes your own user and project rule files on Windows. With Node.js 22.12 to 22.17, 23.x or 24.0 to 24.3 they failed to load, and the guard used a fallback setup. Version 2.7.7 (9 November 2026) lets ssh -i <key file> run at the Standard level, and 2.7.8 (9 November 2026) does the same for scp -i and sftp -i. Strict and Paranoid still block them.
You can set how strict the guard is. Run npx cc-safety-net gui to open a settings window. Pick the Standard, Strict, or Paranoid preset, or turn single rules on and off. The guard needs Node.js 22 or newer since version 2.7.0. Check your version with node --version before you install or update.
Who it is for
People who let an assistant run commands and cannot check every command by hand. It suits beginners most. It is a second line of defence. It is not a sandbox, so it does not replace backups or git.
Example prompts
Type these into your assistant after you install the guard. The guard works in the background, so you do not need a special phrase.
- "Delete everything in my project folder that I do not need."
- "Undo my last changes with a hard reset." The guard should block this command and tell the assistant why.
- "Show me what is inside my .env file." The guard should block this request.
- "Why was my last command blocked?"
How to install
npx -y cc-safety-net@latest installnpx -y cc-safety-net@latest doctorHow to use it
Run the install command once, then restart your agent. After that the hook checks each shell command. To see how a command would be judged without running it, use npx -y cc-safety-net@latest explain "your command".
Check it works
Run this command in your terminal:
npx -y cc-safety-net@latest doctorThe command checks that the protection is active. To see how the guard would judge one command without running it, use explain:
npx -y cc-safety-net@latest explain "rm -rf ~"Common problems
- An old version runs after an update: Always keep
@latestin the command. The namecc-safety-netalone can run an older copy from the npx cache. - The guard blocks a command that you want: Run
npx cc-safety-net gui. Change the preset or turn off the rule that blocks it. - Nothing is blocked after you install: Restart your assistant. Then run the
doctorcommand again. - The install or update command fails: Check your Node.js version with
node --version. It must be 22 or newer since version 2.7.0. The release says: "Installing on Node.js 20 currently fails withCannot read properties of null (reading 'edgesOut')because of an upstream optional peer dependency." Install Node.js 22 or newer, then run the command again — https://github.com/kenryu42/cc-safety-net/releases/tag/v2.7.0 - A download piped into python, node or PowerShell is blocked: Since 2.7.1 the guard also stops lines such as
curl … | python3 -,irm … | iex, and a file that is downloaded and run in the same command. Read the script first. If you trust it, run the line yourself in a normal terminal. - An upload command that worked before is now blocked: From 2.7.0 to 2.7.2 the
network.upload-remoterule blockedcurl -d,-For-Tstyle uploads andwget --post-datato any host that is not localhost, at every level. Since 2.7.3 it blocks them only at Strict and Paranoid, so update first. If you still see the block, runnpx cc-safety-net guiand turn offnetwork.upload-remote, or add"network.upload-remote": "off"underdestructive_command_protection.overridesin~/.cc-safety-net/policy.json— https://ccsafetynet.com/docs/reference/blocked-commands - You want uploads blocked at Standard: Since 2.7.3 Standard allows them. Run
npx cc-safety-net guiand turn onnetwork.upload-remote, or add"network.upload-remote": "on"underdestructive_command_protection.overridesin~/.cc-safety-net/policy.json. - Your own rules do nothing on Windows —
Unable to access user policy filesystem safely.— Update to 2.7.6 or later withnpx -y cc-safety-net@latest update, then restart your assistant — https://github.com/kenryu42/cc-safety-net/releases/tag/v2.7.6 - A command with Windows line endings is blocked: Since 2.6.13 the guard refuses commands that contain a carriage return or an unusual space character outside quotes. Save the script with plain line endings, or run it from a file.
- An install command from a website is blocked: Since 2.6.17 the guard blocks remote install one-liners such as
bash -c "$(curl -fsSL https://…)"in every mode, as it already did forcurl … | bash. Read the script first, or run the install command yourself in a normal terminal.
What to watch out for
- The install command changes your agent's hook settings. It runs a program on every shell command, so a bug in the tool could block normal work.
- It is a safety net, not a sandbox. It cannot stop every harmful action. Keep backups and use version control.
- Versions before 2.7.2 let some secret reads through when a wrapper option came first, such as env -i, sudo -u or command -p (release 2.7.2). Update to 2.7.3 or later.
- Versions before 2.7.3 allowed deletes with a variable or wildcard target, such as rm -rf "$X", at the Standard level when the terminal was in your home folder (release 2.7.3).
- Since 2.7.3 the default Standard level allows curl and wget commands that send data or upload a file to another host (release 2.7.3). The release says files with secrets, such as .env, stay blocked. To block all uploads, choose Strict or turn on network.upload-remote.
- Before 2.7.4, some destructive PowerShell commands were not checked. A command after a here-string (text between @' and '@) with an apostrophe in it, such as Remove-Item -Recurse -Force C:\, was allowed, and so was a destructive here-string passed to Invoke-Expression (release 2.7.4). Update to 2.7.4 or later if you use Windows PowerShell.
- Since 2.7.7 the default Standard level no longer blocks ssh -i with a key file, such as ssh -i ~/.ssh/deploy_key host uptime. The release says ssh only uses the key to sign in and never prints it. Strict and Paranoid still block it, and -F, -o IdentityFile= and your own denyPaths stay checked (release 2.7.7).
- Since 2.7.8 the Standard level also allows scp and sftp with -i and a key file, such as scp -i ~/.ssh/deploy_key deploy@host:/srv/app/file.tar.gz . The key stays checked when it is a file to copy, with -S, when another option takes the -i as its value, and inside -F or -o values such as IdentityFile= or ProxyCommand=. Strict and Paranoid are unchanged (release 2.7.8).
Licence and author
- Licence
- MIT
- Author
- kenryu42
- Source code
- github.com/kenryu42/cc-safety-net
How we tested it
We installed it on an empty test computer on 12 Oct 2026. Partly tested: installed in a clean test system, but its main features need an account or key we did not use.
We did not run it inside a live agent session, so we did not see a real block. Version tested: 2.6.9. We ran only the Claude Code integration.
Technical details of the test
- Date
- 12 Oct 2026
- Method
- In a clean container with no account we ran npx -y cc-safety-net@latest install --claude-code and then doctor. The install reported success and doctor reported no findings. The explain command blocked "rm -rf ~" and allowed "ls -la". We also installed the plugin version with the Claude Code command line, which worked.
Checked again on 10 Nov 2026
Alternatives
- snyk-agent-scan: Scans your installed assistant add-ons for security problems. It does not block commands while they run.
- Built-in permission prompts: Each assistant can ask before it runs a command. These prompts depend on you to read them. The guard blocks without a question.
FAQ
How do I update or remove it?
First run node --version. It must show 22 or newer. To update, run npx -y cc-safety-net@latest update. To remove it, run npx -y cc-safety-net uninstall.
Which assistants does it support? The README lists Claude Code, Codex, Gemini CLI, and many other tools. It runs on Windows, macOS, and Linux. The install command adds the guard to the coding tools it finds on your computer.
Can it stop every harmful action? No. The README says it is not a sandbox. It does not limit processes, file permissions, or network traffic. Keep backups and use git.
Can a broken settings file block my work? No. The README says a broken config file never blocks anything.
Is it free? Yes. The licence is MIT.
Sources
- github.com/kenryu42/cc-safety-net
- github.com/kenryu42/cc-safety-net/releases/tag/v2.6.17
- github.com/kenryu42/cc-safety-net/releases/tag/v2.6.19
- github.com/kenryu42/cc-safety-net/releases/tag/v2.7.0
- github.com/kenryu42/cc-safety-net/releases/tag/v2.7.1
- github.com/kenryu42/cc-safety-net/releases/tag/v2.7.2
- github.com/kenryu42/cc-safety-net/releases/tag/v2.7.3
- github.com/kenryu42/cc-safety-net/releases/tag/v2.7.4
- github.com/kenryu42/cc-safety-net/releases/tag/v2.7.6
- github.com/kenryu42/cc-safety-net/releases/tag/v2.7.7
- github.com/kenryu42/cc-safety-net/releases/tag/v2.7.8