Dicklesworthstone/destructive_command_guard
Rust pre-execution hooks that block destructive AI-agent shell commands
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
Destructive Command Guard (dcg) is a local Rust CLI that sits between an AI coding agent and the shell tool it is about to invoke. A client hook or plugin provides the tool-call context, dcg evaluates the command text against configured rule packs, and the client applies the returned decision. The evaluation pipeline combines SIMD-accelerated filtering, context classification, and a dual regex engine with lazily compiled patterns. The manifest uses Rust edition 2024 and sets a minimum Rust version of 1.95.
Integration is client-specific. Codex CLI 0.125.0+ uses a Bash PreToolUse hook; dcg identifies its payload by a nonempty turn_id and writes only the supported denial fields to stdout, reserving stderr for human-readable output. OpenCode instead uses a native tool.execute.before plugin. The integration surface is hooks, plugins, and a CLI; no MCP server interface is established.
Key Capabilities & Differentiators
With no configuration, dcg checks for destructive filesystem, Git, and disk operations. The filesystem and Git core packs always participate in evaluation, while system.disk can be disabled. windows.filesystem and windows.system also come on by default on native Windows and can activate on other hosts when the request is recognized as Cmd or PowerShell; a Windows-looking string by itself is not enough. More than 50 packs extend coverage to PostgreSQL and other databases, Kubernetes, Docker, cloud CLIs, Terraform, and more.
Context classification distinguishes command text used as data from operations that would actually run, and evaluation extends to heredocs and inline scripts. dcg explain exposes the matched policy and resolved mode, while scan mode brings command checks into pre-commit and CI. Agent profiles can add or remove eligible packs and change allowlist handling. trust_level is an audit label, not a control that changes evaluation.
Trade-offs & Limitations
Compared with Git hooks, dcg can inspect agent-issued shell calls before execution and apply the same policy to filesystem, infrastructure, and database commands. Compared with a sandbox or service-side authorization, its strength is early, explainable feedback, not containment. It depends on the client routing calls through a working hook and honoring the result. Aider is limited to Git hooks, while Continue is detection-only. Keep OS isolation and least-privilege credentials for operations that require a hard boundary.
Broader pack coverage gives teams more control but increases the policy they must tune and test. Pack-wide warn or log does not relax critical rules: they resolve back to deny unless overridden individually. Analysis timeouts can produce explicit review or block outcomes. Cargo.toml references a LICENSE file without identifying the license by SPDX identifier; inspect the actual terms before approving commercial use or redistribution.
Hardware & Deployment Guide
Install the local binary and register it with the client's hook or plugin mechanism. The Codex installer detects codex on PATH or an existing ~/.codex/ directory, merges into ~/.codex/hooks.json, preserves other hooks, and refuses to overwrite malformed JSON. OpenCode uses dcg install --opencode. Start with the default policy, add workload-specific packs in the dcg TOML configuration, and use dcg doctor --strict in the agent's launch environment. Validate both allow and deny behavior end to end before expanding rollout. Source builds require Rust 1.95; the guard itself does not need a model, GPU, or hosted inference service.
The release sequence shows why both test layers matter: v0.17.0 expanded PowerShell truncation coverage and fixed Antigravity hook registration; v0.17.1 introduced a tri-state distinction between action, inert input, and input that cannot be proven safe in the affected guardrail; v0.17.2 added the opt-in system.processes pack for shared agent hosts.
dcg explain diagnoses rule decisions, dcg doctor --strict surfaces configuration failures, and scan mode supports pre-commit and CI.Teams running hook-capable coding agents that want a consistent, explainable check against accidental damage to worktrees, disks, and infrastructure, with CI scanning as a second check.
You need a standalone MCP server or a hard boundary over all processes, filesystem access, or production credentials. Use isolation and service-side access controls for those requirements.
Quick Start & Installation
dcg allowlist add-command "mytool publish --to https://artifacts.corp.internal" \ -r "First-party internal publisher" --user
Comparison vs. Top Coding, Skills & MCP Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| destructive_command_guard ★ | 6.4k | +18 | Rust | — | Rust pre-execution hooks that block destructive AI-agent shell commands |
| rtk | 88.7k | +684 | Rust | Apache-2.0 | A local Rust CLI wrapper that trims command output before coding agents read it. |
| ECC | 316.1k | +4.2k | JavaScript | MIT | Plugins and CLI workflows for planning, reviewing, and verifying agent-written c |
| ponytail | 204.4k | +4.1k | JavaScript | MIT | A prompt-driven coding-agent plugin for smaller changes and focused tests. |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/Dicklesworthstone/destructive_command_guard.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about destructive_command_guard
How does dcg enforce a decision in Codex CLI?
~/.codex/hooks.json. On denial, dcg exits 0 and sends minimal hookSpecificOutput JSON on stdout; the human-readable explanation goes to stderr. An allowed command produces no output. After installation, verify that the client actually honors a denial in a disposable workspace.What hardware and runtime does dcg require?
Can we deploy dcg internally or bundle it commercially?
Cargo.toml points to a LICENSE file but does not give an SPDX license identifier, and the license text is not available here. Review the actual file before approving commercial use, redistribution, or bundling. Local execution avoids a hosted-service dependency for the guard itself, but does not establish licensing rights.How does dcg compare with Git hooks or a sandbox?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy