Destructive Command Guard (dcg)
A high-performance hook for AI coding agents that blocks destructive commands before they execute, protecting your work from accidental deletion.
Evidence shows: minimal protection by default (core git/filesystem/disk), other packs opt-in; user confirmation mechanisms (allow-once, allowlist, DCG_BYPASS); data flow transparency (stdout/stderr separation, JSON output); sensitive data handling limited (history stored locally in SQLite, but no explicit encryption); dependency security not fully verified (dependency versions not pinned, self-update feature); external effects clear (blocks commands, but provides bypass); rollback limited (no automatic rollback, only suggests stash); source attribution clear (authors and contributors listed). Deductions: dependency security not fully verified, sensitive data handling lacks explicit encryption, rollback limited.
Evidence shows: self-consistency good (README and test scripts align, robot mode output stable); dependency availability not fully verified (dependency versions not pinned, self-update may introduce risk); failure messages clear (provides reasons and suggestions). Deductions: dependency availability not fully verified.
Evidence shows: audience clear (AI coding agent users), scenarios broad (multiple agents and platforms); capability boundaries clear (core packs default, others optional); trigger precision high (context-aware, distinguishes data vs execution); environment fit good (Linux/macOS/Windows/WSL). Deductions: none significant.
Evidence shows: information architecture clear (README, docs directory); install notes detailed (curl, PowerShell); naming stable (dcg); examples and FAQ present (README examples); known limitations not explicitly listed; license custom MIT (with OpenAI/Anthropic restriction), may affect usage; versioning and changelog not explicit; maintenance responsibility clear (authors and contributors). Deductions: known limitations not explicit, license non-standard, versioning and changelog missing.
Evidence shows: output usability high (JSON and human-readable); marginal value high (solves real problem); cost-benefit reasonable (performance optimized, low latency). Deductions: none significant.
Evidence shows: claims traceable (README and test scripts correspond); cross-source corroboration limited (only in-repo evidence); fact/inference separation good (README distinguishes features from suggestions). Deductions: cross-source corroboration limited.
- License includes restrictions on OpenAI and Anthropic, which may affect some users.
- Dependency versions are not pinned, and self-update may introduce supply chain risks.
- History storage is not explicitly encrypted and may contain sensitive commands.
- DCG_BYPASS environment variable can completely disable protection; use with caution.
What does this agent do, and when should you use it?
dcg (Destructive Command Guard) is a high-performance hook that intercepts destructive commands before they execute, blocking them with clear explanations and safer alternatives. It supports multiple AI coding agents, including Claude Code, Codex CLI, Gemini CLI, Copilot CLI, VS Code Copilot Chat, Cursor, Hermes Agent, Grok (xAI), Posit Assistant, and related tools. Written in Rust, it features a modular pack system with 50+ security packs covering databases, Kubernetes, cloud providers, and more. It operates with sub-millisecond latency, uses SIMD-accelerated filtering, and includes heredoc/inline-script scanning, smart context detection, and rich terminal output. Installation is straightforward via scripts or Homebrew, and it automatically configures supported agent hooks.
dcg acts as a pre-execution hook for AI agents. It reads the command from the agent's hook input, parses it, and evaluates it against layered rules: trigger detection, content extraction, and AST-based pattern matching. If a destructive pattern is matched, it blocks the command and outputs a human-readable denial panel on stderr, with machine-readable JSON on stdout for agent compatibility. It supports environment variables, config files, agent-specific profiles, allowlists, and bypass mechanisms. It also provides scan mode for CI, explain mode, and commands like dcg allowlist, dcg packs, and dcg simulate.
- A developer using Claude Code who wants to prevent accidental git reset --hard or rm -rf from losing uncommitted work.
- A DevOps engineer who needs to enforce a security policy across team members' AI coding agents.
- A security auditor who wants to scan codebases for dangerous commands in CI pipelines.
- A Windows workstation user who needs native PowerShell and cmd protection against destructive operations.
- An organization that wants to create custom security packs for internal tools and proprietary systems.
- A Codex CLI user who needs first-class hook support to ensure blocked commands are correctly reported.
What are this agent's strengths and limitations?
- Sub-millisecond latency with SIMD-accelerated filtering.
- Extensive default protection for core filesystem and git operations, plus 50+ configurable security packs.
- Broad agent support including native Codex CLI integration, VS Code, Cursor, and more.
- Smart context detection distinguishes data from execution, reducing false positives.
- Requires installation and hook configuration, which may be complex for new users.
- Potential for false positives requiring allowlist adjustments.
- Dependent on specific agent hook mechanisms; some agents (e.g., Aider) have limited integration.
- Cannot prevent an AI model from writing scripts to bypass hooks; should be used as a guardrail, not a complete enforcement boundary.
How do you install or deploy this agent?
For Linux/macOS/WSL, use the one-liner installer: curl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/destructive_command_guard/main/install.sh?$(date +%s)" | bash -s -- --easy-mode. For native Windows (PowerShell): & ([scriptblock]::Create((irm "https://raw.githubusercontent.com/Dicklesworthstone/destructive_command_guard/main/install.ps1"))) -EasyMode -Verify. Alternative via Homebrew (macOS/Linux): brew install dicklesworthstone/tap/dcg && dcg install.
How do you use this agent?
After installation, dcg automatically configures hooks for supported agents. For example, when an agent attempts git reset --hard HEAD~5, dcg intercepts and blocks it. To enable more protection, edit ~/.config/dcg/config.toml and add packs like database.postgresql. To allow a command permanently, use dcg allowlist add core.git:reset-hard. To bypass for a single command, set DCG_BYPASS=1. Use dcg explain "<command>" to understand why it's blocked.
How does this agent compare with similar options?
The main alternative is the original Python script by Jeffrey Emanuel, which dcg improves upon with a Rust rewrite, offering better performance and more features. Another comparison is standard git hooks, but dcg provides broader coverage and agent-specific integration.