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.

Stars
★ 6.4k
Last updated
1d ago v0.17.2
FARS reviewed
Nov 08, 2026 +3 new
License
NOASSERTION
Primary language
Rust

At a glance

How it runs
CLIAgent plugin / skill
Works with
Portable with changesCodex · Claude CodeChatGPT (Partial support)
Cost
Free, no paid service needed
Setup effort
Low · running in minutes
You'll need
Rust binary (prebuilt or built from source)Supported AI coding agent (e.g., Claude Code, Codex CLI)Shell / CLI
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.

  1. A developer using Claude Code who wants to prevent accidental git reset --hard or rm -rf from losing uncommitted work.
  2. A DevOps engineer who needs to enforce a security policy across team members' AI coding agents.
  3. A security auditor who wants to scan codebases for dangerous commands in CI pipelines.
  4. A Windows workstation user who needs native PowerShell and cmd protection against destructive operations.
  5. An organization that wants to create custom security packs for internal tools and proprietary systems.
  6. 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)

Local shell command execution

Can run terminal commands; pair with approval gates or container/OS sandboxing.

What are this agent's strengths and limitations?

Pros
  • 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.
Limitations
  • 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?

FollowAgents source review · FARS-2.1
Some gaps
66/ 100 5-point scale 3.3 / 5
This review covers the source as of Nov 08, 2026. The project has shipped 3 stable release(s) since, which have not been re-reviewed. The score and verdict describe the reviewed version only. Recent releases ↓
Trust 17/29
Reliability 6/14
Adaptability 15/18
Convention 11/18
Effectiveness 12/13
Verifiability 5/8
Why each dimension lost points
Trust17 / 29 · 2.9/5

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.

Reliability6 / 14 · 2.1/5

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.

Adaptability15 / 18 · 4.2/5

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.

Convention11 / 18 · 3.1/5

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.

Effectiveness12 / 13 · 4.6/5

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.

Verifiability5 / 8 · 3.1/5

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.

Risks and how to mitigate them
  • 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.
Evidence confidence: Low Reviewed Nov 08, 2026 Reviewed revision 5ae312a7ab6d New commits since this review; the score may not cover them
See the full review method →
Maintain this project? Add the FARS badge to your README

The badge shows the current review score and verdict and links back to this page. It refreshes about once an hour after a re-review.

FARS

[![FARS review](https://followagents.com/badge/destructive-command-guard.svg)](https://followagents.com/en/agents/destructive-command-guard)
<a href="https://followagents.com/en/agents/destructive-command-guard"><img src="https://followagents.com/badge/destructive-command-guard.svg" alt="FARS review"></a>

Recent releases

Latest entries from the project's GitHub Releases. Notes are quoted from upstream as written, not rewritten or tested by FollowAgents.

  1. v0.17.2
    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 ↗
  2. v0.17.1
    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 ↗
  3. v0.17.0
    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?
Yes, dcg is open-source under a custom license (NOASSERTION) and can be freely used and modified.
Which AI agents are supported?
Supported agents include Claude Code, Codex CLI 0.125.0+, Gemini CLI, GitHub Copilot CLI, VS Code Copilot Chat, Cursor IDE, Hermes Agent, Posit Assistant, and Grok (xAI). Please refer to the project docs for the full list and configuration details.
What if dcg blocks a command I need to run?
You can temporarily bypass with DCG_BYPASS=1, or add a permanent allowlist rule using dcg allowlist add, or use the allow-once code.
Can dcg be bypassed?
Technically, an AI model could write scripts to disk to bypass hook-based blocking, so dcg is a guardrail rather than a complete enforcement boundary. Combine with other security measures.
How can I enforce stricter policies?
Enable strict_git pack, or set DCG_FAIL_CLOSED=1 to block unparseable input.
Was this page helpful?
View on GitHub ↗ Install ↓

Compare agents like this one

The same FARS review applied across the shortlist this agent qualifies for.

Related concepts