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.
- Source repo
- Dicklesworthstone/destructive_command_guard
- Stars
- ★ 6.4k
- Last updated
- 1d ago v0.17.2
- FARS reviewed
- Nov 08, 2026 +3 new
- License
- NOASSERTION
- Primary language
- Rust
- FA score
- 66/100 · Some gaps
At a glance
- How it runs
- Works with
- Portable with changesCodex · Claude CodeChatGPT (Partial support)
- Cost
- Free, no paid service needed
- Setup effort
- Low · running in minutes
- You'll need
- Typical use
- A developer using Claude Code who wants to prevent accidental git reset --hard or rm -rf from losing uncommitted work.
- Not a fit if
- Environments where installing agent hooks is not possible
- Users of limited integrations like Aider (git hooks only)
- Teams expecting zero false positives without allowlist tuning
- Maintenance
- Commits in the last 30 dayslast commit 2026-12-02latest release v0.17.2 (2026-11-26)+1.6 ★/day over 7 days
- Source review
- 66/100 · Some gaps
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.
Key setup facts
Pulled from the install and usage notes below. The project README has the current values.
- Config files
~/.config/dcg/config.toml- Install notes cover
- Windows · macOS · Linux · WSL
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.
Safety boundaries, hardening & integrations
Operational blast radius, source-verified safety controls, and first-run hardening steps before connecting this agent to real workspaces.
Declared capability surface (blast radius)
Can run terminal commands; pair with approval gates or container/OS sandboxing.
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 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.
Key facts side by side with the most closely related agents.
| Agent | Source review | Form / cost | Stars | Updated | Language | Full support on |
|---|---|---|---|---|---|---|
| Destructive Command Guard (dcg) This agent | 66 · Some gaps | CLIFree | ★ 6.4k | 1d ago | Rust | Codex · Claude Code |
| RTK Command Output Optimizer | 72 · Some gaps | CLIFree | ★ 89k | 2d ago | Rust | Codex · Claude Code |
| Cortex TMS | 61 · Some gaps | CLIFree | ★ 180 | 10d ago | MDX | Claude Code |
| mirrord: Run Local Processes Inside Your Kubernetes Cluster | 59 · Major gaps | CLIFree | ★ 5.4k | today | Rust | Codex · Claude Code |
How does FollowAgents rate this agent?
Why each dimension lost points
The source forbids unsafe code and limits automatically discovered repository config to monotonic enforcement additions. Allow-once grants have documented scope, expiry, revocation, and audit behavior, with an explicit warning that command redaction is not guaranteed. Scores are reduced because DCG_BYPASS, allowlists, and warn/log policies can bypass blocking, and enabled packs depend on user configuration; the dependency list is detailed but provides no vulnerability audit or dependency-lock evidence, and installation/update involve external downloads.
The docs describe handling for timeouts, parse failures, malformed input, and protocol differences, with troubleshooting guidance. The score is reduced because SKILL.md juxtaposes default-allow behavior with a zero-false-negative philosophy, while README descriptions of default packs and optional protections require careful distinction; static material cannot verify dependency availability or runtime behavior.
The product documents support for multiple agents, shells, operating systems, and database, cloud, container, and CI scenarios, with configuration and integration guidance. The score is reduced because ask/block behavior differs by protocol and scanning is explicitly limited by supported languages, modes, and dynamic-command analysis.
README, configuration, integration, security, and troubleshooting material is extensive, with concrete installation steps, examples, and limitations. The score is reduced because the documentation is large with many entry points and SKILL.md remains Claude Code-centered; a version is shown but no changelog is included in the packet; license metadata is NOASSERTION and Cargo points to a LICENSE whose terms are not established here; authors and issue reporting are identified, but current maintenance responsibility is not fully clear.
Pre-execution command blocking, readable explanations, rule tracing, machine-readable protocols, CI scanning, and exception management provide clear practical value. The score is reduced because performance and coverage claims are primarily repository assertions that static review cannot substantiate for actual false positives, false negatives, or latency, and many security packs are opt-in.
The README, docs, Cargo manifest, and entry-point source corroborate architecture, configuration, and protocol details, and the docs state several boundaries. The score is reduced because core matching implementation, complete rule packs, test results, and version-change material are outside the supplied sample; performance and breadth claims cannot be independently confirmed from it.
- Many database, cloud, and infrastructure packs are disabled by default; verify enabled packs, agent configuration, and effective policy after installation.
- The docs state that unknown commands are allowed by default and that dynamic scripts, obfuscated content, and unsupported languages may fall outside scanning coverage.
- Avoid weakening protection through DCG_BYPASS or broad allowlist/warn/log settings; allow-once command records may contain credentials, and --show-raw reveals unredacted text.
- The LICENSE contents were not supplied and license metadata is NOASSERTION; confirm the terms before use.
Recent releases
Latest entries from the project's GitHub Releases. Notes are quoted from upstream as written, not rewritten or tested by FollowAgents.
-
Release notes excerpt
What's Changed in v0.17.2 New opt-in pack - system.processes: enable it with enabled = ["system.processes"] on machines shared by several agents. It denies kills that pick their targets by pattern, parent-tree walk or broadcast (pkill, killall, kill -1, kills fed by pgrep/pidof/lsof -t/ps, xargs kill, find -exec kill, remote pattern kills over ssh, interpreter broadcasts, and launchctl bootout of a whole GUI domain). Kills of recorded PIDs stay allowed: literal PIDs, $!, job specs, recorded process groups, kill -0 probes, and a pidfile read back with ` …View on GitHub ↗ -
Release notes excerpt
What's Changed in v0.17.1 Security & Guardrail Fixes - Tri-state guardrail proof (bd-guardrails-global-options): careful_company_running_windows.guardrails now returns a tri-state DcgSegmentAction / DcgControlActionProof (Action / Inert / Unprovable). Static inert dcg argument data (for example dcg --agent="dcg --robot allow-once abc --yes" allowlist list or escaped-quote values) skips only the dcg-command regex fallback inside proven-inert segments while keeping all self-weakening dcg commands, leading env-var overrides (DCG_BYPASS, DCG_DISABLE), dynamic …View on GitHub ↗ -
Release notes excerpt
Highlights This release closes commands that previously ran unguarded (PowerShell Tee-Object/Out-File truncation, commands behind builtin, zsh precommand modifiers and macOS launchers, shell variables past neutral commands, command -p eval), fixes Antigravity hook registration so dcg actually fires for run_command, gives the Codex hook a display label, stops the hook from blocking its own recommended dcg test --stdin heredoc form, stabilizes the test suite and strict Clippy gate, and switches release builds from opt-level = "z" to opt-level = 3. …View on GitHub ↗
FAQ
Is dcg free to use?
Which AI agents are supported?
What if dcg blocks a command I need to run?
Can dcg be bypassed?
How can I enforce stricter policies?
Thanks — we use this to improve the page.
Subscribe to the FollowAgents RSS feed, or save this agent to your browser shortlist to compare on your next visit.