Destructive Command Guardrails

VerifiedCaution

Warns before destructive commands like rm -rf, force-push, DROP TABLE, and more. User can override each warning.

Sby Skills Guide Bot
SecurityIntermediate
8/29/2026
Claude Code
#destructive-commands#safety-guardrails#bash-hooks#git-safety#pre-commit-guard

Recommended for

Automated summary

Activates a safety mode through a PreToolUse hook that inspects every Bash command and warns or blocks before destructive operations (rm -rf, DROP TABLE, force-push, kubectl delete, etc.) run.

Strengths

  • Catches a specific family of dangerous patterns (recursive deletes, DROP/TRUNCATE, git reset --hard, docker prune, kubectl delete) before execution.
  • Two catastrophic shapes are hard-denied rather than merely flagged: recursive removal of /, ~ or $HOME, and force-push to the default branch.
  • Ships safe exceptions for throwaway directories (node_modules, dist, .next, __pycache__, coverage) so routine cleanups stay quiet.
  • Lets you append your own regex warn rules globally or per project, and config can only add rules, never silence the built-in ones.

Limitations

  • Relies on Claude Code hooks, so protection is session-scoped and ends with the conversation.
  • The pattern list is finite: compound commands using ; , && , | or newlines fall through the hard-deny tier and only get a MEDIUM ask.
  • A MEDIUM warning can always be overridden, so it is an advisory guardrail, not a policy boundary.
When to use it

Turn it on when touching production, debugging live systems, or working in a shared environment where a mistyped command would be costly.

When not to use it

Skip it if you need an unbypassable policy enforcement in CI or coverage for agents other than Claude Code, since this guard is opt-in and session-local.

Security analysis

Caution
Quality score86/100

The skill is a command guardrail that hooks into Bash execution to warn about destructive operations. It does not instruct destructive or exfiltrating actions itself, but it executes an external script on every command and logs local telemetry, so it warrants caution rather than safe.

Findings
  • •Runs a bash script ($HOME/.claude/skills/gstack/careful/bin/check-careful.sh) on every Bash PreToolUse; script source not included in SKILL.md, so its behavior cannot be fully audited.
  • •Writes local analytics to ~/.gstack/analytics/skill-usage.jsonl including repository name and timestamp, which may be a privacy concern if not disclosed to users.
  • •Uses Bash and Read allowed tools, and hook can intercept/deny commands, which is powerful but for legitimate safety purposes.
How this analysis is made

Examples

Enable safety mode before prod work
Careful mode on — I'm about to clean up old data on the production box, warn me before anything destructive.
Guard a force-push
Be careful for the rest of this session, I'm rewriting history on a shared branch and don't want a force-push to main to slip through.
Add a project-specific warning
Add a careful pattern so any command touching the billing schema warns me before running.

name: careful version: 0.1.0 description: Safety guardrails for destructive commands. (gstack) triggers:

  • be careful
  • warn before destructive
  • safety mode allowed-tools:
  • Bash
  • Read hooks: PreToolUse:
    • matcher: "Bash" hooks:
      • type: command command: "bash $HOME/.claude/skills/gstack/careful/bin/check-careful.sh" statusMessage: "Checking for destructive commands..."

<!-- AUTO-GENERATED from SKILL.md.tmpl — do not edit directly --> <!-- Regenerate: bun run gen:skill-docs -->

When to invoke this skill

Warns before rm -rf, DROP TABLE, force-push, git reset --hard, kubectl delete, and similar destructive operations. User can override each warning. Use when touching prod, debugging live systems, or working in a shared environment. Use when asked to "be careful", "safety mode", "prod mode", or "careful mode".

/careful — Destructive Command Guardrails

Safety mode is now active. Every bash command will be checked for destructive patterns before running. If a destructive command is detected, you'll be warned and can choose to proceed or cancel.

mkdir -p ~/.gstack/analytics
echo '{"skill":"careful","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}'  >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true

What's protected

| Pattern | Example | Risk | |---------|---------|------| | rm -rf / rm -r / rm --recursive | rm -rf /var/data | Recursive delete | | DROP TABLE / DROP DATABASE | DROP TABLE users; | Data loss | | TRUNCATE | TRUNCATE orders; | Data loss | | git push --force / -f | git push -f origin main | History rewrite | | git reset --hard | git reset --hard HEAD~3 | Uncommitted work loss | | git checkout . / git restore . | git checkout . | Uncommitted work loss | | kubectl delete | kubectl delete pod | Production impact | | docker rm -f / docker system prune | docker system prune -a | Container/image loss |

Safe exceptions

These patterns are allowed without warning:

  • rm -rf node_modules / .next / dist / __pycache__ / .cache / build / .turbo / coverage

How it works

The hook reads the command from the tool input JSON, checks it against the patterns above, and returns a hookSpecificOutput payload with permissionDecision: "ask" and a warning reason if a match is found (the decision must be nested under hookSpecificOutput — Claude Code ignores a top-level permissionDecision). You can always override a MEDIUM warning and proceed.

HIGH tier (hard deny)

Two catastrophic shapes are denied, not asked: rm -r/-R of exactly /, ~, or $HOME, and force-push to the repo's default branch. SIMPLE commands only (no ;, &&, ||, |, newline) — compound shapes fall through to the MEDIUM ask; --force-with-lease is never HIGH. A best-effort advisory hard-stop, not a policy boundary: the escape hatch is ending the opt-in, session-scoped /careful session.

Project patterns (additive only)

Add warn rules — one POSIX ERE per line, # comments OK — in ~/.gstack/careful-patterns.txt (global) or ~/.gstack/projects/<slug>/careful-patterns.txt (per-project). Consulted after the built-in families, so config can only ADD rules, never suppress a baseline warning. Invalid regex lines are skipped.

To deactivate, end the conversation or start a new one. Hooks are session-scoped.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/destructive-command-guardrails-mte1lh6o/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/destructive-command-guardrails-mte1lh6o' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/destructive-command-guardrails-mte1lh6o/download' --output '.skill-downloads/destructive-command-guardrails-mte1lh6o/SKILL.md.part' && mv '.skill-downloads/destructive-command-guardrails-mte1lh6o/SKILL.md.part' '.skill-downloads/destructive-command-guardrails-mte1lh6o/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/destructive-command-guardrails-mte1lh6o/SKILL.md' && test -s '.skill-downloads/destructive-command-guardrails-mte1lh6o/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/careful' && cp -R '.skill-downloads/destructive-command-guardrails-mte1lh6o' '.claude/skills/careful'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/destructive-command-guardrails-mte1lh6o'

openskills read 'destructive-command-guardrails-mte1lh6o'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/destructive-command-guardrails-mte1lh6o/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills