Back
22/65
Lesson 22
8 min
DCG: Pre-Execution Safety
Block dangerous commands before they cause damage
Ready to level up?
Mark complete to track your learning progress.
Block dangerous commands before they cause damage
Mark complete to track your learning progress.
Use DCG to block destructive commands before they do damage.
DCG (Destructive Command Guard) is a pre-execution hook for Claude Code, Codex, Antigravity and other agent CLIs that blocks dangerous commands before they execute. It protects your repos from hard resets, recursive deletes, destructive database commands, and more.
Think of it as a safety interlock: if a command looks destructive, DCG stops it and suggests a safer alternative.
Stops damage before it happens
Git, filesystem, database, cloud, and more
Explicit bypass when you know it is safe
Unreadable input passes with a warning; unfinished analysis asks or blocks
DCG runs as a PreToolUse hook inside Claude Code (and the equivalent hook in Codex, Gemini, Cursor, agy and others). Every command is checked against a set of rules before it runs.
# Example: test a command before running it$ dcg test "git reset --hard" --explainDecision: DENYRule ID: core.git:reset-hardReason: git reset --hard destroys uncommitted changes. Use 'git stash' first.Safer: git reset --soft HEAD~1 (keeps your changes)
DCG Control Room
Command Guard v2.1 active
Select Command to Analyze
Select a command above to see DCG in action
Watch the full interception pipeline animate
If you need to remove DCG, you can uninstall the hook and optionally purge its config. You can always re-enable it later with dcg install.
# Remove hook only (keeps dcg installed)$ dcg uninstall# Remove the hook and dcg's config directory (binary stays)$ dcg uninstall --purge# Full removal: run uninstall.sh from a local dcg checkout you trust$ bash ./uninstall.sh# Verify removal$ dcg doctor$ claude /hooks
Packs let you enable or disable rules based on your workflow. Keep the ones you need to avoid false positives.
# ~/.config/dcg/config.toml[packs]enabled = ["database.postgresql", "containers.docker"] # core.git + core.filesystem are always on
A block is a warning, not a dead end. Use it as a checkpoint:
DCG blocks obvious destructive commands instantly. SLB handles contextual risk that needs human approval. Together, they form a layered safety system.