Configs2026年7月22日·1 分钟阅读

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 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
DCG
直接安装命令
npx -y tokrepo@latest install 46c76857-85aa-11f1-9bc6-00163e2b0d79 --target codex

先 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

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产