Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
oakoss avatar

Destructive Command Guard

  • 63 installs
  • 14 repo stars
  • Updated March 2, 2026
  • oakoss/agent-skills

Helps with ai & agent building tasks during AI-assisted development.

About

destructive-command-guard is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted coding.

  • destructive-command-guard
  • AI & Agent Building
  • AI-coding skill

Destructive Command Guard by the numbers

  • 63 all-time installs (skills.sh)
  • +2 installs in the week ending Aug 4, 2026 (Skillselion tracking)
  • Ranked #6,190 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/oakoss/agent-skills --skill destructive-command-guard

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs63
repo stars14
Last updatedMarch 2, 2026
Repositoryoakoss/agent-skills

What it does

Helps with ai & agent building tasks during AI-assisted development.

Files

SKILL.mdMarkdownGitHub ↗

Destructive Command Guard

A high-performance Claude Code hook that intercepts and blocks destructive commands before they execute. Written in Rust with SIMD-accelerated filtering via the memchr crate and Aho-Corasick multi-pattern matching for sub-millisecond latency. Assumes agents are well-intentioned but fallible.

Overview

DCG uses a whitelist-first architecture: safe patterns are checked before destructive patterns, and unrecognized commands are allowed by default (fail-safe). This ensures legitimate workflows are never broken while known dangerous patterns are always blocked. DCG runs as a PreToolUse hook in Claude Code, receiving JSON on stdin for each Bash tool invocation and returning exit code 0 (allow) or 2 (block). It only inspects direct Bash tool invocations, not contents of shell scripts.

The processing pipeline has four stages: JSON parsing, command normalization (strips absolute paths like /usr/bin/git), SIMD quick-reject filter (skips regex for commands without git or rm), and pattern matching. The memchr crate provides hardware-accelerated substring search (SSE2/AVX2 on x86_64, NEON on ARM), while Aho-Corasick handles multi-pattern matching in O(n) time regardless of pattern count.

DCG supports 49+ modular security packs organized by category (git, filesystem, databases, containers, Kubernetes, cloud providers, infrastructure tools). Core packs (core.git, core.filesystem) are always enabled; additional packs are configured via ~/.config/dcg/config.toml or the DCG_PACKS environment variable. The dcg scan subcommand can also audit files for destructive command contexts, suitable for CI integration.

DCG is not published on crates.io; it is installed from GitHub via cargo +nightly install or prebuilt binaries for Linux, macOS, and Windows WSL. The threat model assumes agents are well-intentioned but fallible; DCG catches honest mistakes, not adversarial attacks.

Quick Reference

CategoryBlocked Commands
Uncommitted workgit reset --hard, git checkout -- <file>, git restore <file>, git clean -f
Remote historygit push --force / -f, git branch -D
Stashed workgit stash drop, git stash clear
Filesystemrm -rf (outside /tmp, /var/tmp, $TMPDIR)
CategoryAllowed Commands
Safe gitgit status, git log, git diff, git add, git commit, git push, git pull, git fetch, git branch -d, git stash, git stash pop
Safe patternsgit checkout -b, git restore --staged, git clean -n, git push --force-with-lease
Temp dirsrm -rf /tmp/*, rm -rf $TMPDIR/*
SettingValue
Exit code (safe)0
Exit code (blocked)2
Default behaviorAllow (fail-safe)
Pattern prioritySafe checked first, then destructive
Safe patterns34
Destructive patterns16
Pack CategoryExamples
Core (default)core.git, core.filesystem
Databasedatabase.postgresql, database.mysql, database.mongodb
Containerscontainers.docker, containers.compose, containers.podman
Kuberneteskubernetes.kubectl, kubernetes.helm, kubernetes.kustomize
Cloudcloud.aws, cloud.gcp, cloud.azure
Infrastructureinfrastructure.terraform, infrastructure.ansible
Systemsystem.disk, system.permissions, system.services
Otherstrict_git, package_managers
Environment VariablePurpose
DCG_PACKSEnable packs (comma-separated)
DCG_DISABLEDisable specific packs
DCG_VERBOSEVerbose output
DCG_BYPASSBypass DCG entirely (escape hatch)
DCG_COLORColor mode (auto, always, never)
Installation MethodCommand
Quick install`curl -fsSL ".../install.sh" \
From sourcecargo +nightly install --git https://github.com/Dicklesworthstone/destructive_command_guard destructive_command_guard
Prebuilt binariesLinux x86_64, Linux ARM64, macOS Intel, macOS Apple Silicon, Windows WSL
Processing StageDescription
JSON parsingReads PreToolUse hook input, allows non-Bash tools
NormalizationStrips absolute paths (/usr/bin/git becomes git)
SIMD quick-rejectmemchr substring search skips regex for irrelevant commands
Pattern matchingSafe patterns first, then destructive, default allow

Common Mistakes

MistakeCorrect Pattern
Forgetting to restart Claude Code after adding the hookAlways restart Claude Code after modifying ~/.claude/settings.json
Using DCG_BYPASS=1 permanently in shell profileOnly set bypass temporarily for a single command, then remove it
Assuming DCG inspects commands inside scriptsDCG only inspects direct Bash tool invocations, not contents of ./deploy.sh
Blocking git branch -d (lowercase) thinking it is destructiveLowercase -d is safe (merge-checked); only uppercase -D force-deletes
Not enabling database or cloud packs for production environmentsConfigure relevant packs in ~/.config/dcg/config.toml for your stack
Expecting DCG to stop malicious actorsDCG catches honest mistakes; determined users can always bypass the hook
Running cargo install without nightly toolchainDCG requires Rust nightly (edition 2024); use cargo +nightly install

Delegation

  • Audit which destructive commands an agent session has attempted: Use Explore agent
  • Set up DCG with custom packs for a new project environment: Use Task agent
  • Plan a layered safety architecture combining DCG with other guardrails: Use Plan agent

References

  • Command detection and processing pipeline
  • Pack configuration and environment variables
  • Installation and Claude Code setup
  • Safety patterns and edge cases
  • Troubleshooting and FAQ

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.