← 所有精選

GitHub Trending 精選

每日一個爆紅開源專案

日榜 #12026-07-13

Dicklesworthstone/destructive_command_guard

The Destructive Command Guard (dcg) is for blocking dangerous git and shell commands from being executed by agents.

★ 2.8k stars · ▲ +444 今日 · 🔶 Rust · 📜 NOASSERTION在 GitHub 開啟 ↗
ai-agentsclideveloper-toolsgitrustsafety

這是什麼

dcg(Destructive Command Guard)是一個用 Rust 寫的 AI coding agent 安全 hook:在 Claude Code、Codex CLI、Gemini CLI、Copilot、Cursor、Hermes Agent 等工具真正執行 shell 或 git 指令前,先攔下高風險操作。README 的問題意識很清楚:agent 偶爾會跑出 git reset --hardrm -rf ./src 這類會毀掉未提交工作的命令。dcg 會在執行前判斷、阻擋,並用清楚訊息說明原因與較安全替代做法。它不是單一黑名單,而是 modular pack system,可把 Git、檔案系統、磁碟、資料庫、Docker、Kubernetes、雲端等規則分組啟用。

為什麼上榜

這個專案今天拿到 444 stars_period、總星數 2,847,反映的是 agentic coding 普及後的新痛點:不是 AI 不會寫程式,而是它開始有能力「真的改壞環境」。dcg 的吸引力在於支援面廣,README 明列 Claude Code、Codex CLI 0.125.0+、Gemini CLI、GitHub Copilot CLI、VS Code Copilot Chat、Cursor、Hermes Agent、Grok、Antigravity、OpenCode 等工具;也特別強調對 Codex 的原生 hook 輸出,避免 blocked command 被誤判成 hook failed。

適合誰,可以拿來做什麼

它適合所有讓 AI agent 在本機 repo 裡下命令的人:個人開發者、開源維護者、團隊工具工程師,或正在導入 Claude/Codex/Gemini 類 CLI 的團隊。最直接用途是保護 未 commit 的工作樹;進一步則可依環境開啟 PostgreSQL、Docker、Kubernetes、AWS/GCP/Azure 等 pack。README 也提供 bypass、allow-once、永久 allowlist,代表它不是要把流程鎖死,而是讓高風險操作有可追蹤的例外出口。

上手

README 提供一行式安裝,Linux、macOS 與 WSL 可用:

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

Windows 原生 PowerShell:

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

安裝器會偵測平台、下載 binary,並設定偵測到的 agent hooks。若要理解某條命令為何被擋,可用 dcg explain "command"

README 重點摘要