A high-performance Rust-based safety layer that blocks dangerous shell commands before they execute.

Install

mkdir -p .claude/skills/dcg && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/6119" && unzip -o skill.zip -d .claude/skills/dcg && rm skill.zip

Installs to .claude/skills/dcg

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Destructive Command Guard - High-performance Rust hook for Claude Code that blocks dangerous commands before execution. SIMD-accelerated, modular pack system, whitelist-first architecture. Essential safety layer for agent workflows.
232 charsno explicit “when” trigger
Intermediate

Key capabilities

  • →Intercepts and blocks destructive shell commands
  • →Uses a whitelist-first architecture for safety
  • →Provides SIMD-accelerated filtering for performance
  • →Organizes patterns into modular packs by category
  • →Blocks dangerous git, filesystem, and database commands

How it works

The tool acts as a pre-tool hook that evaluates commands against a whitelist of safe patterns and a blacklist of destructive patterns before execution.

Inputs & outputs

You give it
Shell command execution attempt
You get back
Blocked command notification or allowed execution

When to use dcg

  • →Protect files from accidental deletion
  • →Prevent destructive git resets
  • →Guard against dangerous shell scripts
  • →Ensure safe environment cleanup

About this skill

DCG — 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 for sub-millisecond latency.

Why This Exists

AI coding agents are powerful but fallible. They can accidentally run destructive commands:

  • "Let me clean up the build artifacts" → rm -rf ./src (typo)
  • "I'll reset to the last commit" → git reset --hard (destroys uncommitted changes)
  • "Let me fix the merge conflict" → git checkout -- . (discards all modifications)
  • "I'll clean up untracked files" → git clean -fd (permanently deletes untracked files)

DCG intercepts dangerous commands before execution and blocks them with a clear explanation, giving you a chance to stash your changes first.

Critical Design Principles

1. Whitelist-First Architecture

Safe patterns are checked before destructive patterns. This ensures explicitly safe commands are never accidentally blocked:

git checkout -b feature    →  Matches SAFE "checkout-new-branch"  →  ALLOW
git checkout -- file.txt   →  No safe match, matches DESTRUCTIVE  →  DENY

2. Fail-Safe Defaults (Default-Allow)

Unrecognized commands are allowed by default. This ensures:

  • The hook never breaks legitimate workflows
  • Only known dangerous patterns are blocked
  • New git commands work until explicitly categorized

3. Zero False Negatives Philosophy

The pattern set prioritizes never allowing dangerous commands over avoiding false positives. A few extra prompts for manual confirmation are acceptable; lost work is not.

What It Blocks

Git Commands That Destroy Uncommitted Work

CommandReason
git reset --hardDestroys uncommitted changes
git reset --mergeDestroys uncommitted changes
git checkout -- <file>Discards file modifications
git restore <file> (without --staged)Discards uncommitted changes
git clean -fPermanently deletes untracked files

Git Commands That Destroy Remote History

CommandReason
git push --force / -fOverwrites remote commits
git branch -d, --delete, -D, -f, -M, -CDeletes or force-overwrites a user-owned branch ref

Git Commands That Destroy Stashed Work

CommandReason
git stash dropPermanently deletes a stash
git stash clearPermanently deletes all stashes

Filesystem Commands

CommandReason
rm -rf (outside /tmp, /var/tmp, $TMPDIR)Recursive deletion is dangerous

What It ALLOWS

Safe operations pass through silently:

Always Safe Git Operations

git status, git log, git diff, git add, git commit, git push, git pull, git fetch, read-only branch listings, git stash, git stash pop, git stash list

Explicitly Safe Patterns

PatternWhy Safe
git checkout -b <branch>Creating new branches
git checkout --orphan <branch>Creating orphan branches
git restore --staged <file>Unstaging only, doesn't touch working tree
git restore -S <file>Short flag for staged
git clean -n / --dry-runPreview mode, no actual deletion
rm -rf /tmp/*Temp directories are ephemeral
rm -rf $TMPDIR/*Shell variable forms

Safe Alternative: --force-with-lease

git push --force-with-lease   # ALLOWED - refuses if remote has unseen commits
git push --force              # BLOCKED - can overwrite others' work

Modular Pack System

DCG uses a modular "pack" system to organize patterns by category:

Core Packs (Always Enabled)

PackDescription
core.gitDestructive git commands
core.filesystemDangerous rm -rf outside temp

Database Packs

PackDescription
database.postgresqlDROP/TRUNCATE in PostgreSQL
database.mysqlDROP/TRUNCATE in MySQL/MariaDB
database.mongodbdropDatabase, drop()
database.redisFLUSHALL/FLUSHDB
database.sqliteDROP in SQLite

Container Packs

PackDescription
containers.dockerdocker system prune, docker rm -f
containers.composedocker-compose down --volumes
containers.podmanpodman system prune

Kubernetes Packs

PackDescription
kubernetes.kubectlkubectl delete namespace
kubernetes.helmhelm uninstall
kubernetes.kustomizekustomize delete patterns

Cloud Provider Packs

PackDescription
cloud.awsDestructive AWS CLI commands
cloud.gcpDestructive gcloud commands
cloud.azureDestructive az commands

Infrastructure Packs

PackDescription
infrastructure.terraformterraform destroy
infrastructure.ansibleDangerous ansible patterns
infrastructure.pulumipulumi destroy

System Packs

PackDescription
system.diskdd, mkfs, fdisk operations
system.permissionsDangerous chmod/chown patterns
system.servicessystemctl stop/disable patterns

Other Packs

PackDescription
strict_gitExtra paranoid git protections
package_managersnpm unpublish, cargo yank

Configuring Packs

# ~/.config/dcg/config.toml
[packs]
enabled = [
    "database.postgresql",
    "containers.docker",
    "kubernetes",  # Enables all kubernetes sub-packs
]

Environment Variables

VariableDescription
DCG_PACKS="containers.docker,kubernetes"Enable packs (comma-separated)
DCG_DISABLE="kubernetes.helm"Disable packs/sub-packs
DCG_VERBOSE=1Verbose output
DCG_COLOR=auto|always|neverColor mode
DCG_BYPASS=1Bypass DCG entirely (escape hatch)

Installation

Quick Install (Verified Release)

Install minisign through your trusted OS package manager first (for example, apt install minisign or brew install minisign). Then paste this function into Bash. It authenticates the release installer with the project's pinned Minisign key and checks its fixed SHA-256 identity before executing any downloaded code. The key is the trust root; establish it from a trusted copy of this documentation or an independent maintainer channel, not from the same download as the installer. A downloaded checksum alone does not authenticate a publisher.

<!-- verified-release-install:begin -->
dcg_install() (
  # Explicit failure guards also work when called inside `if dcg_install ...`.
  set -eu
  umask 077
  if [ "$#" -gt 1 ]; then
    printf '%s\n' 'Usage: dcg_install [--easy-mode|--system]' >&2
    exit 1
  fi
  case "${1:-}" in
    ''|--easy-mode|--system) ;;
    *) printf '%s\n' 'Usage: dcg_install [--easy-mode|--system]' >&2; exit 1 ;;
  esac

  readonly dcg_tag='v0.16.0'
  readonly dcg_sha256='072462974ad790008e8a3aadb1a9eecf2d9b6bd0ef7b469f69f0fb0fa3b51c7c'
  readonly dcg_key='RWSoYi6NXJWzaRs1mJmOwwXrZfPWcq6MXnQlNMLBYKzlIQTLwuVQG6uO'
  dcg_minisign=$(type -P minisign) || {
    printf '%s\n' 'Install minisign with your trusted OS package manager first.' >&2
    exit 1
  }
  dcg_curl=$(type -P curl) || exit 1
  dcg_bash=$(type -P bash) || exit 1
  if dcg_hash=$(type -P sha256sum); then
    dcg_hash_kind=sha256sum
  elif dcg_hash=$(type -P shasum); then
    dcg_hash_kind=shasum
  else
    printf '%s\n' 'A SHA-256 verifier (sha256sum or shasum) is required.' >&2
    exit 1
  fi

  dcg_tmp=$(mktemp -d "${TMPDIR:-/tmp}/dcg-install.XXXXXXXXXX") || exit 1
  printf 'Installer verification files: %s\n' "$dcg_tmp"
  dcg_base="https://github.com/Dicklesworthstone/destructive_command_guard/releases/download/$dcg_tag"
  for dcg_asset in install.sh install.sh.minisig; do
    "$dcg_curl" --proto '=https' --proto-redir '=https' --tlsv1.2 -fsSL \
      --max-time 120 --user-agent 'destructive_command_guard-installer' \
      "$dcg_base/$dcg_asset" -o "$dcg_tmp/$dcg_asset" || exit 1
  done
  "$dcg_minisign" -Vm "$dcg_tmp/install.sh" \
    -x "$dcg_tmp/install.sh.minisig" -P "$dcg_key" || exit 1
  if [ "$dcg_hash_kind" = sha256sum ]; then
    dcg_actual=$("$dcg_hash" "$dcg_tmp/install.sh") || exit 1
  else
    dcg_actual=$("$dcg_hash" -a 256 "$dcg_tmp/install.sh") || exit 1
  fi
  if [ "${dcg_actual%% *}" != "$dcg_sha256" ]; then
    printf '%s\n' 'Installer does not match the pinned release; refusing execution.' >&2
    exit 1
  fi

  case "${1:-}" in
    --system)
      # The first elevated command runs only after BOTH checks succeed.
      sudo -- "$dcg_bash" "$dcg_tmp/install.sh" \
        --version "$dcg_tag" --require-minisign --system ;;
    --easy-mode)
      "$dcg_bash" "$dcg_tmp/install.sh" \
        --version "$dcg_tag" --require-minisign --easy-mode ;;
    *) "$dcg_bash" "$dcg_tmp/install.sh" \
        --version "$dcg_tag" --require-minisign ;;
  esac
)
<!-- verified-release-install:end -->

Choose one installation mode after defining the function:

dcg_install                 # Normal: install to ~/.local/bin
dcg_install --easy-mode     # Also configure PATH automatically
dcg_install --system        # Install to /usr/local/bin using sudo after verification

For system-wide installation, install minisign on the system PATH so the elevated installer can also verify the binary archive. Missing tools, missing assets, invalid signatures, or a different installer digest stop installation; there is no unsigned or source-build fallback. The private download directory is retained for inspection. The tag and digest are a pair: upgrading this recipe requires independently verifying and pinning the new release's installer bytes. Do not replace the tag with main or latest or remove either verification.

For native Windows, follow the


Content truncated.

When not to use it

  • →Against adversarial attacks or malicious actors
  • →To inspect contents of non-Bash scripts
  • →For protecting committed but unpushed work

Prerequisites

Claude Code environmentRust runtime for hook execution

Limitations

  • →Does not inspect contents of scripts like ./deploy.sh
  • →Assumes the AI agent is well-intentioned but fallible
  • →Does not protect against non-Bash commands

How it compares

Unlike manual review, this tool provides real-time, automated interception of specific dangerous commands using a high-performance Rust hook.

Compared to similar skills

dcg side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
dcg (this skill)14moReviewIntermediate
ecc-safety-guard05moNo flagsIntermediate
linux-production-shell-scripts710moReviewIntermediate
audit-prep-assistant15moReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

Search skills

Search the agent skills registry