A hook that blocks destructive shell, git and filesystem commands before AI coding agents run them
source availableMIT License (with OpenAI/Anthropic Rider)free
dcg (Destructive Command Guard) is a Rust hook that AI coding agents call before running a shell command, and that blocks destructive ones such as git reset --hard, rm -rf ./src or DROP TABLE with an explanation and a safer alternative. It works out of the box for git and filesystem commands, and has more than 50 optional rule packs for databases, Kubernetes, Docker, cloud CLIs and Terraform. It scans heredocs and inline scripts, tells a command apart from the same words used as data, explains why a command was blocked (dcg explain) and has a scan mode for pre-commit hooks and CI. Its installer sets it up for Claude Code, Codex, Gemini CLI, GitHub Copilot CLI, Cursor, OpenCode, Amp and other agents, on Linux, macOS and Windows. Its licence is MIT with a rider that grants no rights to OpenAI, Anthropic or anyone acting for them.
Problems it solves
- my AI coding agent ran git reset --hard and wiped my uncommitted work
- stop coding agents running rm -rf, force pushes and other destructive commands
- block an AI agent from dropping database tables or deleting Kubernetes namespaces
- an AI agent ran a destructive command I didn't expect and broke my working copy
- explain why a command my coding agent tried was blocked
- scan scripts in pull requests for dangerous commands in CI
Features
- pre-execution hook for Claude Code, Codex CLI, Gemini CLI, Copilot CLI, Cursor and more
- blocks destructive git and filesystem commands with no configuration
- 50+ optional packs: databases, Kubernetes, Docker, AWS, GCP, Azure, Terraform
- heredoc and inline script scanning
- dcg explain shows why a command is blocked
- scan mode for pre-commit hooks and CI
- per-agent profiles with extra packs and allowlists
Capabilities
| Has a command line tool | plan not known |
|---|
