
claude-code-safety-net
Safety net plugin that blocks destructive git and filesystem commands in Claude Code, OpenCode, Gemini CLI, Copilot CLI, and Codex
- Installs
- 76
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/reason-machines/claude-code-skills --skill claude-code-safety-net- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads claude-code-safety-net automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Claude Code Safety Net
Skill by ara.so — Claude Code Skills collection.
A PreToolUse hook plugin that intercepts and blocks destructive git and filesystem commands before they execute. Works across Claude Code, OpenCode, Gemini CLI, Copilot CLI, and Codex.
What It Does
Safety Net analyzes commands before execution and blocks operations that could:
- Delete uncommitted work (
git reset --hard,git checkout -- .) - Force push to remotes (
git push --force) - Remove files recursively (
rm -rf /) - Clear git stashes (
git stash clear) - Execute shell wrappers containing destructive commands (
bash -c "rm -rf /") - Run interpreter one-liners (
python -c 'os.system("rm -rf /")')
It runs before permission rules and provides semantic command analysis that wildcards can't match.
Installation
Claude Code
/plugin marketplace add kenryu42/cc-marketplace
/plugin install safety-net@cc-marketplace
/reload-plugins
Enable auto-updates:
/plugin
# Select Marketplaces → cc-marketplace → Enable auto-update
OpenCode
Add to ~/.config/opencode/opencode.json:
{
"plugin": ["cc-safety-net"]
}
Gemini CLI
gemini extensions install https://github.com/kenryu42/gemini-safety-net
GitHub Copilot CLI
/plugin install kenryu42/copilot-safety-net
Restart Copilot CLI after installation.
Codex
Enable hooks in ~/.codex/config.toml:
[features]
plugin_hooks = true
Add marketplace and install:
codex plugin marketplace add kenryu42/cc-marketplace
In Codex TUI:
- Run
/plugins - Select
[cc-marketplace]and press Enter - Run
/hooks - Select safety-net PreToolUse hook and press
tto trust
Configuration
Status Line Integration
Add to ~/.claude/settings.json:
{
"statusLine": {
"type": "command",
"command": "bunx cc-safety-net --statusline"
}
}
Or pipe with existing status:
{
"statusLine": {
"type": "command",
"command": "git branch --show-current | bunx cc-safety-net --statusline"
}
}
Status indicators:
🛡️ Safety Net ❌- Plugin disabled🛡️ Safety Net ✅- Default mode active🛡️ Safety Net ✅ 🔒- Strict mode enabled🛡️ Safety Net ✅ 👁️- Paranoid mode enabled🛡️ Safety Net ✅ 🌳- Worktree mode enabled
Custom Rules
Create ~/.config/cc-safety-net/rules.json:
{
"rules": [
{
"name": "block-npm-publish",
"pattern": "npm publish",
"action": "block",
"reason": "Use CI/CD pipeline for publishing"
},
{
"name": "allow-temp-cleanup",
"pattern": "rm -rf /tmp/myapp-*",
"action": "allow",
"reason": "Safe to clean temp files"
},
{
"name": "block-production-deploys",
"pattern": "kubectl.*--context=prod",
"action": "block",
"reason": "Production deploys require manual approval"
}
]
}
Rule schema:
interface Rule {
name: string; // Unique identifier
pattern: string; // Regex pattern to match
action: "block" | "allow";
reason: string; // Why this rule exists
}
Matching behavior:
- Rules are evaluated in order
- First matching rule wins
- Custom rules override built-in rules
- Invalid patterns are logged and skipped
Advanced Modes
Strict Mode
Blocks additional destructive operations:
{
"safety-net": {
"strict": true
}
}
Blocked in strict mode:
git clean -fd- Deletes untracked filesgit branch -D- Force deletes branchesgit remote remove- Removes remote repositories
Paranoid Mode
Blocks all potentially destructive commands, even if they have safe variants:
{
"safety-net": {
"paranoid": true
}
}
Blocked in paranoid mode:
- All
git checkoutcommands (including safe branch switches) - All
git resetcommands (including--soft) - All
rmcommands with-rflag
Worktree Mode
Provides additional protection when using git worktrees:
{
"safety-net": {
"worktree": true
}
}
Blocks worktree-specific destructive operations:
- Removing worktrees with uncommitted changes
- Force operations that affect multiple worktrees
Secret Redaction
Automatically redacts sensitive values from logs:
# Command executed:
curl -H "Authorization: Bearer sk-1234..." https://api.example.com
# Logged as:
curl -H "Authorization: Bearer [REDACTED]" https://api.example.com
Patterns redacted:
- API keys (e.g.,
sk-,api_key=) - Tokens (e.g.,
Bearer,token=) - Passwords (e.g.,
password=,-p) - AWS credentials
- SSH keys
Audit Logging
Enable detailed command logging in ~/.claude/settings.json:
{
"safety-net": {
"audit": {
"enabled": true,
"logFile": "~/.config/cc-safety-net/audit.log"
}
}
}
Log format:
{
"timestamp": "2025-01-15T10:30:45.123Z",
"command": "git reset --hard HEAD~1",
"action": "blocked",
"reason": "Destructive git reset detected",
"mode": "default",
"cwd": "/home/user/project"
}
Commands Blocked
Git Operations
# Destructive resets
git reset --hard
git reset --hard HEAD~1
# Discard changes
git checkout -- .
git checkout -- file.txt
# Force push
git push --force
git push -f origin main
# Stash operations
git stash clear
git stash drop
# Strict mode only
git clean -fd
git branch -D feature
git remote remove origin
Filesystem Operations
# Recursive deletion of important directories
rm -rf /
rm -rf ~/
rm -rf .
rm -rf .git
# Allow safe cleanup
rm -rf /tmp/cache # ✅ Allowed
rm -rf node_modules # ✅ Allowed
Shell Wrappers (5 levels deep)
# Direct wrapper
bash -c "rm -rf /"
# Nested wrappers
sh -c "bash -c 'rm -rf /'"
eval "sh -c 'bash -c \"rm -rf /\"'"
Interpreter One-Liners
# Python
python -c 'import os; os.system("rm -rf /")'
python3 -c 'import shutil; shutil.rmtree("/")'
# Node.js
node -e 'require("child_process").execSync("rm -rf /")'
# Ruby
ruby -e 'system("rm -rf /")'
# Perl
perl -e 'system("rm -rf /")'
Commands Allowed
# Safe git operations
git checkout -b feature
git checkout main
git reset --soft HEAD~1
git push origin feature
git stash
git stash pop
# Safe filesystem operations
rm file.txt
rm -r /tmp/myapp-cache
rm -rf node_modules
mv old.txt new.txt
cp -r src/ backup/
# Safe git workflow
git add .
git commit -m "feat: add feature"
git push origin feature
git pull --rebase
git merge feature
Diagnostics
Check plugin status and configuration:
bunx cc-safety-net --diagnose
Output example:
🛡️ Safety Net Diagnostics
✓ Plugin installed and enabled
✓ PreToolUse hook registered
✓ Status line: Active
Configuration:
Mode: strict
Worktree: disabled
Paranoid: disabled
Audit log: enabled (~/.config/cc-safety-net/audit.log)
Custom Rules:
✓ block-npm-publish
✓ allow-temp-cleanup
✗ invalid-rule (Pattern compile error)
Recent Blocks (last 24h):
- git reset --hard (2025-01-15 10:30:45)
- rm -rf / (2025-01-15 09:15:22)
Debug Analysis
Explain why a command was blocked or allowed:
bunx cc-safety-net --explain "git reset --hard"
Output:
Command: git reset --hard
Action: 🚫 BLOCKED
Reason: Destructive git reset detected
Analysis:
- Command: git reset --hard
- Flags: --hard
- Pattern matched: Destructive reset (discards uncommitted changes)
- Mode: default
- Custom rules: none matched
Safe alternatives:
- git reset --soft HEAD~1 (keeps changes staged)
- git stash (temporarily saves changes)
- git commit (save changes permanently)
Testing the Hook
Verify the plugin is working:
# Should be blocked
git reset --hard
rm -rf /tmp/test-deleteme
# Should be allowed
git checkout -b test-branch
rm -rf /tmp/cache
Expected behavior when blocked:
🛡️ Safety Net: Command blocked
Command: git reset --hard
Reason: Destructive git reset detected
This command would discard all uncommitted changes.
Safe alternatives:
- git reset --soft HEAD~1
- git stash
- git commit
Troubleshooting
Plugin not blocking commands
- Verify installation:
bunx cc-safety-net --diagnose
- Check hook registration in Claude Code:
/plugins
# Verify safety-net shows as enabled
- Ensure PreToolUse hook is trusted (Codex only):
/hooks
# Select safety-net and press 't'
Custom rules not working
- Validate JSON syntax:
cat ~/.config/cc-safety-net/rules.json | jq .
- Check pattern syntax:
bunx cc-safety-net --explain "your command here"
- Review audit log:
tail -f ~/.config/cc-safety-net/audit.log
Status line not updating
- Verify command runs standalone:
bunx cc-safety-net --statusline
- Check settings.json syntax:
cat ~/.claude/settings.json | jq .statusLine
- Restart Claude Code if using native version
False positives
Use custom rules to allow specific patterns:
{
"rules": [
{
"name": "allow-my-script",
"pattern": "rm -rf /tmp/myapp-build-*",
"action": "allow",
"reason": "Safe cleanup pattern"
}
]
}
Shell wrapper not detected
Safety Net recursively analyzes 5 levels of shell wrappers. If a command still bypasses:
- Report with example:
bunx cc-safety-net --explain "your bypassed command"
- Add temporary custom rule while waiting for fix:
{
"rules": [
{
"name": "block-wrapper",
"pattern": "your-wrapper-pattern",
"action": "block",
"reason": "Temporary workaround"
}
]
}
Real-World Examples
Prevent accidental force push
# Blocked automatically
git push --force origin main
# Safe alternative shown
git push --force-with-lease origin main
Clean build artifacts safely
{
"rules": [
{
"name": "allow-build-cleanup",
"pattern": "rm -rf (dist|build|.next|out|target)/",
"action": "allow",
"reason": "Safe to clean build directories"
}
]
}
Block production deployments
{
"rules": [
{
"name": "block-prod-deploy",
"pattern": "(kubectl|terraform).*prod",
"action": "block",
"reason": "Use CI/CD for production"
}
]
}
Team workspace protection
{
"safety-net": {
"strict": true,
"worktree": true,
"audit": {
"enabled": true,
"logFile": "~/team-audit.log"
}
},
"rules": [
{
"name": "block-db-drops",
"pattern": "DROP (DATABASE|TABLE)",
"action": "block",
"reason": "Use migration system"
}
]
}
FAQ
What does the claude-code-safety-net skill do?
Safety net plugin that blocks destructive git and filesystem commands in Claude Code, OpenCode, Gemini CLI, Copilot CLI, and Codex
How do I install claude-code-safety-net?
Run npx skills add https://github.com/reason-machines/claude-code-skills --skill claude-code-safety-net in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/claude-code-safety-net/ (personal) or .claude/skills/claude-code-safety-net/ (project).
Which AI agents can use claude-code-safety-net?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is claude-code-safety-net safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains claude-code-safety-net?
It is published by reason-machines in reason-machines/claude-code-skills. It has 76 recorded installs.
More from reason-machines/claude-code-skills
claude-code-best-practice
reason-machines/claude-code-skills
Open the skill to read its SKILL.md instructions.
free-claude-code-proxy
reason-machines/claude-code-skills
Run Claude Code CLI, VS Code, or JetBrains ACP through a local proxy that routes to NVIDIA NIM, Kimi, OpenRouter, DeepSeek, or local LLMs
claude-code-best
reason-machines/claude-code-skills
Open the skill to read its SKILL.md instructions.
aris-autonomous-ml-research
reason-machines/claude-code-skills
Open the skill to read its SKILL.md instructions.
claude-code-game-studios
reason-machines/claude-code-skills
Open the skill to read its SKILL.md instructions.
oh-my-claudecode-multi-agent-orchestration
reason-machines/claude-code-skills
Open the skill to read its SKILL.md instructions.
Popular ai & agents skills
google-agents-cli-publish
google/agents-cli
This skill should be used when the user wants to "publish an agent", "publish my ADK agent", "register an agent with Gemini", "publish to Gemini" (formerly Gemini Enterprise), or needs guidance on the agents-cli publish gemini command. Also use when the user wants to "manage agents in Agent Registry", "list/update/delete registered agents", or "register an MCP server". Covers ADK vs A2A registration modes, programmatic and interactive usage, flag reference, auto-detection from deployment metadata, Agent Registry fleet management, and troubleshooting. Part of the agents-cli skills suite. Do NOT use for deployment (use google-agents-cli-deploy).
google-agents-cli-eval
google/agents-cli
This skill should be used when the user wants to "run an evaluation", "evaluate my agent", "evaluate my ADK agent", "write an eval dataset", "analyze eval failures", "compare eval results", "optimize agent", or needs guidance on the Gemini platform eval methodology and the Quality Flywheel. Covers eval metrics, dataset schema, LLM-as-judge scoring, and common failure causes. Applies to any agents-cli project, whatever framework the agent is written in. Do NOT use for agent API code patterns (ADK: use google-agents-cli-adk-code), deployment (use google-agents-cli-deploy), or project scaffolding (use google-agents-cli-scaffold).
skill-creator
anthropics/skills
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.
codex-pet
prime-skills/runcomfy-agent-skills
Codex Pet generator on RunComfy. Build a Codex-compatible Codex Pet spritesheet.webp + pet.json from a single reference image, drop it into ${CODEXHOME:-$HOME/.codex}/pets/ / and Codex picks it up as a custom Codex Pet next to the 8 built-ins. This skill produces the exact Codex Pet atlas Codex expects (1536x1872 PNG/WebP, 8 cols x 9 rows, 192x208 cells, 9 animation states — idle, running-right, running-left, waving, jumping, failed, waiting, running, review). Calls OpenAI GPT Image 2 edit ONCE via the local RunComfy CLI as runcomfy run openai/gpt-image-2/edit to produce a canonical Codex Pet pose, then assembles all 9 animation rows programmatically with ImageMagick micro-transforms — no Codex Pro, no $imagegen, no OPENAIAPIKEY required, only RUNCOMFYTOKEN. Triggers on "codex pet", "create codex pet", "make codex pet", "hatch codex pet", "/hatch image", "desktop pet codex", "codex pets", "spritesheet.webp", or any explicit ask to build a custom pet for OpenAI Codex.
full-output-enforcement
leonxlnx/taste-skill
Overrides default LLM truncation behavior. Enforces complete code generation, bans placeholder patterns, and handles token-limit splits cleanly. Apply to any task requiring exhaustive, unabridged output.
executing-plans
obra/superpowers
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available