Destructive Command Guard (dcg): Protecting AI Agents from Dangerous Commands

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Destructive Command Guard (dcg): Protecting AI Agents from Dangerous Commands

Summary

The Destructive Command Guard (dcg) is a high-performance hook designed to prevent AI coding agents from executing dangerous git and shell commands. Built in Rust, dcg intercepts and blocks catastrophic operations like `git reset --hard` or `rm -rf`, offering clear explanations and safer alternatives. It provides a crucial safety layer for developers working with tools like Claude Code, Codex CLI, and GitHub Copilot.

Repository Information

Analyzed by OSRepos on July 11, 2026

Topics

Click on any tag to explore related repositories

Use at your own risk

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.

Introduction

AI coding agents, while incredibly powerful, can sometimes execute catastrophic commands, leading to accidental data loss or irreversible changes. The Destructive Command Guard (dcg) is a robust solution built in Rust to act as a protective shield, blocking dangerous git and shell commands before they can cause harm. It integrates seamlessly as a PreToolUse hook for various AI agents, ensuring your work remains safe from unintended destruction.

Destructive Command Guard - Protecting your code from accidental destruction

dcg is designed for high performance, offering sub-millisecond latency and intelligent context detection to differentiate between dangerous commands and safe data. It supports a wide array of agents including Claude Code, Codex CLI, Gemini CLI, GitHub Copilot CLI, Cursor IDE, Hermes Agent, and Grok (xAI).

Installation

The quickest way to get dcg up and running is by using the provided install script. This script automatically detects your platform, downloads the correct binary, and configures hooks for supported AI agents on Linux, macOS, and Windows (via WSL or native PowerShell).

Quick Install (Linux, macOS, WSL):

curl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/destructive_command_guard/main/install.sh?$(date +%s)" | bash -s -- --easy-mode

Windows (native, PowerShell):

& ([scriptblock]::Create((irm "https://raw.githubusercontent.com/Dicklesworthstone/destructive_command_guard/main/install.ps1"))) -EasyMode -Verify

After installation, it is recommended to run dcg setup to add a shell startup check that warns you if the dcg hook is ever silently removed from your agent's configuration.

To update dcg, simply run:

dcg update

For uninstallation, use the dedicated script:

curl -fsSL https://raw.githubusercontent.com/Dicklesworthstone/destructive_command_guard/main/uninstall.sh | bash

Examples

When an AI agent attempts to run a destructive command, dcg intercepts it and provides a clear explanation along with suggestions for safer alternatives. Here's a quick example:

# AI agent tries to run:
$ git reset --hard HEAD~5

# dcg intercepts and blocks:
????????????????????????????????????????????????????????????????
BLOCKED  dcg
????????????????????????????????????????????????????????????????
Reason:  git reset --hard destroys uncommitted changes

Command: git reset --hard HEAD~5

Tip: Consider using 'git stash' first to save your changes.
????????????????????????????????????????????????????????????????

You can also test commands manually without executing them using dcg test:

dcg test "rm -rf ./build"

Why Use dcg?

dcg offers a comprehensive set of features to safeguard your development workflow:

  • Zero-Config Protection: Blocks dangerous git and filesystem commands out of the box, requiring minimal setup.
  • 50+ Security Packs: Extends protection to databases, Kubernetes, Docker, AWS/GCP/Azure, Terraform, and more through modular packs that can be enabled or disabled.
  • Sub-Millisecond Latency: Utilizes SIMD-accelerated filtering and a dual regex engine for high performance, ensuring it won't slow down your workflow.
  • Smart Context Detection: Intelligently distinguishes between dangerous commands meant for execution and similar strings appearing as data, preventing false positives.
  • Rich Terminal Output: Provides human-readable denial panels with clear reasons, rule context, and actionable suggestions on stderr.
  • Agent-Safe Streams: Ensures machine-readable hook output stays on stdout for agents, while rich UI is directed to stderr for human readability.
  • Fail-Open Design: Prioritizes workflow continuity, allowing commands to proceed with a warning if dcg cannot safely analyze them due to timeouts or parse errors.
  • Explain Mode: Use dcg explain "command" to get a detailed trace of why a command was blocked or allowed, invaluable for debugging and understanding policy.

Links

For more detailed documentation, advanced configuration, and to contribute to the project, visit the official GitHub repository:

Related repositories

Similar repositories that may be relevant next.

awesome-claude-code: A Curated List of Resources for Anthropic's Claude Code

awesome-claude-code: A Curated List of Resources for Anthropic's Claude Code

August 24, 2026

The awesome-claude-code repository offers a comprehensive, curated list of tools, integrations, frameworks, and resources specifically designed for developers utilizing Anthropic's Claude Code. This valuable collection helps users discover everything from official SDKs and agent skills to IDE integrations and client GUIs. It serves as an essential guide for enhancing development workflows with AI-powered coding assistance.

awesome-listclaude-codeai-agents
claude-codex-settings: Enhance Your AI Coding Tools with Battle-Tested Configurations

claude-codex-settings: Enhance Your AI Coding Tools with Battle-Tested Configurations

August 23, 2026

The `claude-codex-settings` repository provides battle-tested configurations, plugins, hooks, and agents for Claude Code, OpenAI Codex, and Cursor. It aims to significantly improve AI coding tool behavior by offering structured guidelines and an extensive ecosystem of specialized skills. This versatile resource also supports Kimi, MiniMax, and GLM APIs, streamlining AI-powered development workflows.

ai-agentsai-toolsclaude-ai
ios-simulator-skill: Enhance Claude's iOS App Development with Simulator Skill

ios-simulator-skill: Enhance Claude's iOS App Development with Simulator Skill

August 22, 2026

The ios-simulator-skill is a production-ready skill for Claude Code, designed to build, test, and automate iOS applications efficiently. It optimizes Claude's interaction with the iOS Simulator and Xcode builds, significantly reducing token wastage from LLM output. This skill provides 27 scripts for robust semantic UI navigation, accessibility testing, and device lifecycle management.

iossimulatorclaude-code
awesome-agent-skills: A Curated Collection of 1000+ AI Agent Skills

awesome-agent-skills: A Curated Collection of 1000+ AI Agent Skills

August 22, 2026

VoltAgent's awesome-agent-skills is a comprehensive repository featuring over 1000 hand-picked AI agent skills from official development teams and the community. This valuable resource supports various AI coding assistants like Claude Code, Codex, Gemini CLI, and Cursor. It stands out for its focus on real-world, non-AI-generated skills, making it an essential toolkit for developers building intelligent agents.

agent-skillsai-agentsawesome-list

Source repository

Open the original repository on GitHub.

14 counted GitHub visits

View on GitHub
OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️