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 Claude Code hook 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
Errors never block your workflow
DCG runs as a PreToolUse hook inside Claude Code. Every command is checked against a set of rules before it runs.
# Example: test a command before running it$ dcg test "git reset --hard" --explain> BLOCKED: git.reset.hard> Why: hard reset discards uncommitted work> Safer: git restore --staged .
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 the binary and config. You can always re-enable it later with dcg install.
# Remove hook only (keeps dcg installed)$ dcg uninstall# Full removal (hook + binary + config)$ dcg uninstall --purge# 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 = ["git", "filesystem", "database.postgresql", "containers.docker"]
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.