Dicklesworthstone/destructive_command_guard
The Destructive Command Guard (dcg) is for blocking dangerous git and shell commands from being executed by agents.
What it solves
AI coding agents (such as Claude Code, Cursor, and GitHub Copilot) can occasionally execute catastrophic commands—like rm -rf ./src or DROP TABLE users—that destroy uncommitted work or production data in seconds. dcg provides a safety layer that intercepts these commands before they are executed.
How it works
It acts as a high-performance hook that intercepts commands from AI agents. It uses SIMD-accelerated filtering and a dual regex engine to scan for destructive patterns with sub-millisecond latency. The tool includes over 50 "security packs" (modular rule sets) covering databases, cloud providers, Kubernetes, and system disks. It can also detect destructive commands embedded in heredocs or inline scripts (e.g., python -c "os.remove(...)"). When a dangerous command is detected, it blocks execution and provides a human-readable explanation and safer alternatives on stderr.
Who it’s for
Developers using AI coding agents or CLI-based AI tools who want to prevent accidental data loss or system destruction caused by autonomous agent actions.
Highlights
- Broad Agent Support: Compatible with Claude Code, Codex CLI, Gemini CLI, Copilot CLI, Cursor, Grok (xAI), and more.
- Modular Security Packs: Over 50 specialized packs for different environments (AWS, GCP, Azure, PostgreSQL, Docker, Kubernetes, etc.).
- High Performance: Sub-millisecond latency ensures the safety check doesn't slow down the agent's workflow.
- Smart Context Detection: Distinguishes between data (e.g.,
grep "rm -rf") and actual execution (e.g.,rm -rf /). - Flexible Bypass: Offers multiple ways to allow commands, including environment variables, one-time codes, or permanent allowlists.
- CI Integration: Includes a "Scan Mode" for use in pre-commit hooks and CI pipelines to catch dangerous commands during code review.