Your AI agent ran git reset --hard HEAD~5. You didn't tell it to. Your last three hours of work are gone.

This is not a hypothetical.

What It Is

dcg (Destructive Command Guard) is a pre-execution hook that sits between your AI coding agent and your shell. When the agent tries to run something destructive — rm -rf, git reset --hard, DROP TABLE, kubectl delete namespace — dcg intercepts it, blocks it, and tells the agent why. All in sub-millisecond time.

Written in Rust. Supports Claude Code, Codex CLI, Gemini CLI, GitHub Copilot CLI, Cursor, and a handful of others. One installer, zero config required to get started.

Why It's Worth Your Time

The problem isn't that AI agents are careless. The problem is that they operate at a level of confidence that doesn't map to real consequences. An agent will cheerfully git reset --hard to "clean up a merge conflict" without pausing to think that you haven't committed in four hours.

What makes dcg different is what it doesn't do: it doesn't require you to sandbox your AI agent or wrap every command in a confirmation prompt. That kills the flow. Instead, it runs as a hook — transparent when commands are safe, instant when they're not.

The smart part is context detection. It knows that grep "rm -rf" Makefile is searching for a string and rm -rf ./src is ending your afternoon. It won't cry wolf.

Hands On

Install takes one command:

curl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/destructive_command_guard/main/install.sh?$(date +%s)" | bash -s -- --easy-mode

The installer auto-detects which agents you have configured, downloads the right binary for your platform, and merges its hook into your agent config without clobbering anything you already have. That last part matters — too many tools that "install a hook" nuke whatever was there before.

Out of the box, two rule packs are always on and cannot be disabled: core.filesystem (dangerous rm -rf outside temp directories) and core.git (destructive git commands that lose uncommitted work, rewrite history, or destroy stashes). Everything else is opt-in.

Want broader coverage — Kubernetes, cloud providers, databases? One config file:

# ~/.config/dcg/config.toml
[packs]
enabled = [
    "database.postgresql",
    "kubernetes.kubectl",
    "cloud.aws",
    "containers.docker",
]

There's also dcg explain "some command" which tells you exactly why a command would be blocked. Useful when tuning rules, or just understanding what the guard is thinking.

When something gets blocked, the output is human-readable:

════════════════════════════════════════════════════════════════
BLOCKED  dcg
────────────────────────────────────────────────────────────────
Reason:  git reset --hard destroys uncommitted changes

Command: git reset --hard HEAD~5

Tip: Consider using 'git stash' first to save your changes.
════════════════════════════════════════════════════════════════

There's a real limitation worth knowing: the README itself is honest about it. An agent can still write a shell script to disk and execute that, bypassing hook-based blocking entirely. The hook operates at the shell command invocation layer, not deeper in the process tree. It catches the obvious moves, not the creative ones. On Windows there's also a specific Codex code path (unified_exec) that hook coverage doesn't reach yet.

Honest Verdict

dcg is solving a real problem and solving it the right way — at the invocation layer, with zero workflow friction, and with a fail-open design that never breaks your workflow if something goes wrong with the guard itself. The 50+ rule packs are genuinely useful if you work with Kubernetes or cloud infra; a single misunderstood kubectl delete namespace is the kind of thing that ruins a production on-call shift.

The script-bypass limitation is real. But it covers the obvious catastrophes: the accidental rm -rf, the enthusiastic git reset --hard, the confident DROP TABLE. That's 90% of actual incidents. On any machine where an AI agent has shell access, I'd run this.

Go Try It

Run the one-liner above. Then ask your AI agent to do something it shouldn't. See what happens.

GitHub: Dicklesworthstone/destructive_command_guard