opensourceprojects.dev

A broadsheet for software that doesn't ask for your email

A hook that blocks destructive commands before your AI agent runs them
GitHub RepoImpressions3

Project Description

View on GitHub

A Safety Net for Your AI Agent's Worst Impulses

You've probably done it. Maybe you typed rm -rf into the wrong directory, or ran a cleanup script that was a little too enthusiastic. Now imagine handing those same commands to an AI coding agent that's moving fast and thinking in tool calls. The Destructive Command Guard (dcg) is a hook that sits between your agent and your shell, blocking destructive commands before they ever execute.

What It Does

dcg is a high-performance hook for AI coding agents. It intercepts commands before execution and blocks the ones that could destroy your work—things like recursive deletes, destructive git operations, and other commands you'd regret running. The point is simple: your agent gets a safety net, and you don't lose a day's work to a single bad tool call.

The project supports a wide range of agents: Claude Code, Codex CLI, Gemini CLI, GitHub Copilot CLI, VS Code Copilot Chat, Cursor IDE, Hermes Agent, Posit Assistant, Grok (xAI), Antigravity CLI, OpenCode, Oh My Pi, Crush, and Pi. There's also limited support for Aider (git hooks only) and detection-only support for Continue. Installation auto-detects your platform, downloads the right binary, and wires up the hooks for the agents it finds. It runs on Linux, macOS, and Windows (both via WSL and natively through a PowerShell installer).

Why It's Cool

  • It meets your agents where they already live. Rather than asking you to change how you work, dcg plugs into the hook systems these tools already expose. Some integrations are native (OpenCode's tool.execute.before, Oh My Pi's tool_call, Crush's hooks.PreToolUse), while others go through compatibility layers—like VS Code Copilot Chat picking up Claude-style hooks, or Grok accepting a native ~/.grok/hooks/dcg.json plus a Claude compatibility path. That kind of coverage isn't trivial to pull off, and it means you don't have to pick your agent based on whether it's protected.

  • The installer actually takes verification seriously. The Windows PowerShell installer verifies a mandatory SHA256 checksum, checks the release's long-lived minisign signature when minisign is available, and verifies Sigstore/cosign provenance when both cosign and a trusted bundle are present. For a tool whose whole job is preventing bad things from happening, it's reassuring that the installer doesn't ask you to trust it blindly.

  • It's opinionated about scope. dcg doesn't try to be a general-purpose sandbox or a full permission system. It's a guard against destructive commands specifically. That focus is a feature—narrow tools tend to be faster, easier to reason about, and less likely to get in your way during normal work.

  • Coverage is broad without being bloated. The list of supported agents is long, but the install process stays a single command. You don't have to configure each integration by hand unless you want to; the installer handles the common cases, and per-agent flags exist for the ones that need explicit opt-in (dcg install --grok, --agy, --opencode, --omp, --crush).

  • It works on the platforms people actually use. Linux, macOS, Windows via WSL, and native Windows. The native Windows path even configures Copilot at the user level (%COPILOT_HOME%\hooks or %USERPROFILE%\.copilot\hooks) so every workspace is protected, not just the one you're in.

How to Try It

The fastest path on Linux or macOS:

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

The --easy-mode flag auto-detects your platform, downloads the appropriate binary, and configures hooks for the supported agents it finds. If you're on native Windows, use the PowerShell installer instead:

& ([scriptblock]::Create((irm "https://raw.githubusercontent.com/Dicklesworthstone/destructive_command_guard/main/install.ps1"))) -EasyMode -Verify

That one installs dcg.exe, verifies the SHA256 checksum, checks the minisign signature when available, verifies Sigstore/cosign provenance when possible, adds dcg to your User PATH, runs a self-test, and configures detected agent hooks.

If you want to wire up a specific agent manually—say OpenCode, Crush, Oh My Pi, or Antigravity CLI—there are dedicated install flags (dcg install --opencode, --crush, --omp, --agy), and the repo includes integration docs for OpenCode, Crush, and Pi.

Grab it at github.com/dicklesworthstone/destructive_command_guard.

Final Thoughts

If you're running AI coding agents on real projects—especially ones with uncommitted work or anything you can't easily recreate—dcg is worth the five minutes it takes to install. It's not a replacement for backups or version control, and it won't save you from every possible mistake. But it closes a specific, very real gap: the moment between your agent deciding to run something destructive and that command actually running. For anyone who's watched an agent confidently propose rm -rf on the wrong path, that gap is exactly where you want a guard.

Back to Projects
Project ID: 6c06ef02-e10b-46c4-a2f7-1491fcbf43f4Last updated: September 22, 2026 at 02:47 AM