Claude Code hook

destructive_command_guard

Fast Rust PreToolUse hook that stops destructive shell, git and filesystem commands before they run.

6,242 stars 264 forksHooks Source

Install

Install
brew install dicklesworthstone/tap/dcg
From source
git clone https://github.com/Dicklesworthstone/destructive_command_guard.git

From the README

dcg (Destructive Command Guard)

A high-performance hook for AI coding agents that blocks destructive commands before they execute, protecting your work from accidental deletion across Claude Code, Codex CLI, Gemini CLI, Copilot CLI, VS Code Copilot Chat, Cursor, Hermes Agent, Grok (xAI), Posit Assistant, Oh My Pi, Factory Droid's Execute tool, and related tools.

Supported: Claude Code, Codex CLI 0.125.0+, Gemini CLI, GitHub Copilot CLI, VS Code Copilot Chat, Cursor IDE, Hermes Agent, Posit Assistant (Positron/RStudio extension, standalone server, and pa terminal client), Grok (xAI) (native ~/.grok/hooks/ plus Claude compatibility layer), Antigravity CLI (agy) (native ~/.gemini/config/hooks.json via dcg install --agy), OpenCode (native tool.execute.before plugin via dcg install --opencode — see docs/opencode-integration.md), Oh My Pi (omp) (native tool_call extension via dcg install --omp), Crush (native hooks.PreToolUse entry in crush.json via dcg install --crush — see docs/crush-integration.md), Reasonix (native hooks.PreToolUse entry in settings.json via dcg install --reasonix — see docs/reasonix-integration.md), Muse Code (native hooks.PreToolUse matcher group in ~/.config/muse/settings.json via dcg install --muse — see docs/muse-integration.md), Amp (native tool.call plugin via dcg install --amp — see docs/amp-integration.md), Pi (via extension recipe), Aider (limited—git hooks only), Continue (detection only)

Quick Install

Factory Droid's Execute tool is supported through dcg install --droid;
see coverage and Script-mode limitations.

Install a verified release on Linux, macOS, or WSL.
The copyable recipe authenticates the pinned installer before running it and
supports normal, easy-mode, and system-wide installation.

Works on Linux, macOS, and Windows via…
Read the full README on GitHub

How hooks work

  • Hooks are shell commands Claude Code runs at fixed points: before or after a tool call, when you submit a prompt, when Claude stops, on notifications and at session start.
  • They are set in the hooks section of ~/.claude/settings.json (or .claude/settings.json for a project), or come bundled in a plugin.
  • A hook can block a tool call, add context, or run a formatter or test. Read the scripts before you install them: they run on your machine with your permissions.
Claude Code docs

Details

Type
Hooks
Language
Rust
Last updated
3 November 2026
Topics
ai-agentsclideveloper-toolsgitrustsafety

FAQ

What is destructive_command_guard?

Fast Rust PreToolUse hook that stops destructive shell, git and filesystem commands before they run. It is a hook for Claude Code, from Dicklesworthstone/destructive_command_guard on GitHub.

How do I install destructive_command_guard?

Run brew install dicklesworthstone/tap/dcg, then follow the setup in the README.

Is destructive_command_guard popular?

Dicklesworthstone/destructive_command_guard has 6,242 GitHub stars and 264 forks. It was last updated on 3 November 2026.

More hooks

Browse the most popular Claude Code mods, all hooks, or the skills and MCP server directories.