Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsJul 22, 2026·2 min de lecture

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.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
DCG
Commande d'installation directe
npx -y tokrepo@latest install 46c76857-85aa-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

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

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires