ConfigsJul 22, 2026·2 min read

Destructive Command Guard — Block Dangerous Shell Commands from AI Agents

A Rust CLI tool that intercepts and blocks dangerous git and shell commands before AI coding agents can execute them. Prevents accidental force pushes, hard resets, and destructive operations.

Agent ready

Ready-to-run agent install

This asset can be installed after the agent chooses its runtime, checks the plan, and runs the matching command.

Native · 98/100Policy: allow
Agent surface
Any MCP/CLI agent
Kind
Skill
Install
Single
Trust
Trust: Established
Entrypoint
DCG
Direct install command
npx -y tokrepo@latest install 46c76857-85aa-11f1-9bc6-00163e2b0d79 --target codex

Run after dry-run confirms the install plan.

Introduction

Destructive Command Guard (DCG) is a lightweight Rust tool that acts as a safety layer between AI coding agents and your shell. It intercepts commands before execution, checks them against a configurable blocklist of destructive patterns, and prevents accidental data loss from force pushes, hard resets, and file deletions.

What DCG Does

  • Intercepts shell commands before execution and checks for destructive patterns
  • Blocks dangerous git operations like force push, reset --hard, and clean -fd
  • Prevents accidental rm -rf and other file system destructive commands
  • Provides configurable allow/deny lists for fine-grained control
  • Logs blocked commands for audit and review

Architecture Overview

DCG is a single static Rust binary with zero dependencies. It operates as a command wrapper or shell hook, parsing the command line before passing it to the underlying shell. Pattern matching uses a compiled rule set that evaluates in microseconds, adding negligible latency to command execution.

Self-Hosting & Configuration

  • Install via cargo: cargo install destructive-command-guard
  • Or download prebuilt binaries from GitHub releases
  • Configure rules in ~/.config/dcg/rules.toml
  • Integrate as a git hook or shell alias
  • Set environment-specific overrides for CI/CD pipelines

Key Features

  • Zero-dependency single binary written in Rust
  • Sub-millisecond command evaluation overhead
  • Configurable rules with allow and deny patterns
  • Works with any AI coding agent that executes shell commands
  • Audit logging of all blocked commands

Comparison with Similar Tools

  • Git hooks — Per-repo only; DCG protects globally across all repos
  • Shell aliases — Easy to bypass; DCG wraps the actual binary
  • Husky — JS-specific git hooks; DCG is language-agnostic
  • pre-commit — Runs checks on staged files; DCG blocks dangerous commands themselves

FAQ

Q: Does DCG add latency to commands? A: Negligible. Rule evaluation takes microseconds since patterns are compiled at startup.

Q: Can I allow specific destructive commands? A: Yes, configure allow rules in rules.toml to permit specific patterns when needed.

Q: Does it work with Claude Code, Codex, etc.? A: Yes, DCG works with any tool that executes shell commands, including all major AI coding agents.

Q: What happens when a command is blocked? A: DCG prints a warning explaining why the command was blocked and exits with a non-zero status code.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets