Overview
The Destructive Command Guard (dcg) is a high-performance security hook designed to protect AI coding agents from executing dangerous and destructive commands. It acts as a proactive shield, intercepting commands related to Git, file system operations, databases, cloud infrastructure, and more, before they can cause accidental data loss or system damage. dcg supports a wide range of popular AI coding tools and platforms, ensuring your development workflow remains safe and productive.
Key Features
- Proactive Threat Interception: Blocks high-risk commands like
rm -rf,git reset --hard,DROP TABLE, and cloud resource deletion before execution. - Extensive Command Coverage: Guards against destructive actions across Git, filesystems, databases (PostgreSQL, MySQL, MongoDB, etc.), Kubernetes, Docker, major cloud providers (AWS, Azure, GCP), and numerous other categories via a modular "pack" system.
- High Performance: Engineered for sub-millisecond latency using SIMD-accelerated filtering, ensuring no noticeable impact on your workflow.
- Intelligent Context Awareness: Differentiates between commands intended for execution and those meant for analysis (e.g.,
grep "rm -rf"vs.rm -rf /). - Rich User Feedback: Provides clear, human-readable denial panels on stderr with explanations, suggested safer alternatives, and rule context. Machine-readable output is available on stdout for agent integration.
- Agent-Specific Configuration: Supports custom trust levels and profiles for different AI agents, allowing fine-tuned security policies.
- Easy Installation & Configuration: Offers simple one-liner installers for Linux, macOS, and Windows (WSL/native PowerShell). Configuration is managed via TOML files, with sensible defaults provided out-of-the-box.
- Comprehensive Pack System: Over 50 specialized security packs cover a vast array of potential threats, with the ability to enable/disable packs as needed.
- Bypass Mechanisms: Provides controlled escape hatches, including environment variable bypass, single-command allow-once codes, and permanent allowlist configurations for legitimate exceptions.
- Scan Mode: Enables pre-commit hooks and CI integration to identify potentially dangerous commands during code review.
Typical Use Cases
- Safeguarding Uncommitted Work: Prevents AI agents from executing commands that could permanently delete uncommitted changes (e.g.,
git reset --hard). - Preventing Accidental Data Loss: Blocks irreversible database operations such as
DROP TABLE,TRUNCATE, orFLUSHALL. - Protecting Cloud Infrastructure: Stops AI from unintentionally terminating critical cloud resources (e.g.,
aws ec2 terminate-instances,kubectl delete namespace). - Securing Container Environments: Guards against destructive Docker/Podman commands like
docker system pruneorpodman volume rm --all. - Enhancing CI/CD Security: Integrates into CI pipelines to catch dangerous commands before they are executed in a production-like environment.
- Controlled AI Agent Adoption: Provides a safety net for teams experimenting with new AI coding agents, ensuring that accidental misconfigurations or harmful suggestions do not lead to disaster.
- Auditing and Visibility: Offers detailed logging and scan modes to understand and prevent potentially risky command patterns in your development workflow.
