dcg (Destructive Command Guard) क्या है?
dcg (Destructive Command Guard) एक Rust pre-tool hook जो coding agent के चलाने से पहले destructive shell और git commands को ब्लॉक करता है. यह Evaluation & Production Ops टूल्स की Guardrails & Security श्रेणी में आता है; ओपन सोर्स है और Rust में लिखा गया है। शुरू करने के लिए: linux या macOS पर इंस्टॉल करें.
सारांश
Destructive Command Guard — `dcg` — एक hook है जो AI coding agent और आपके shell के बीच बैठता है। यह जिस समस्या को हल करता है वह सीमित और परिचित है: agents कभी-कभी `git reset --hard`, `rm -rf ./src` या `DROP TABLE users` जैसा कुछ चला देते हैं, और घंटों का uncommitted काम एक पल में गायब हो जाता है। dcg command के execute होने से पहले उसे intercept करता है, destructive commands को रोकता है और साथ में कारण तथा एक सुरक्षित विकल्प भी बताता है।
यह तेज़ी के लिए Rust में लिखा गया है, क्योंकि यह हर tool call के critical path पर चलता है — प्रोजेक्ट SIMD-accelerated filtering और lazily compiled regexes के ज़रिए sub-millisecond execution का दावा करता है। Patterns एक modular pack system में व्यवस्थित हैं, जिसमें categories में समूहित पचास से अधिक packs हैं: `database` जैसी एक bare category चालू करने पर उसके नीचे के हर sub-pack चालू हो जाते हैं, और अलग-अलग sub-packs को फिर से हटाया जा सकता है। बिना किसी configuration के यह डिफ़ॉल्ट रूप से खतरनाक git और filesystem commands को ब्लॉक करता है; Windows पर filesystem और system packs डिफ़ॉल्ट रूप से चालू होते हैं, इसलिए `del /s`, `rd /s`, `Remove-Item -Recurse`, `format` और `vssadmin delete shadows` भी कवर होते हैं। सिर्फ़ simple pattern matching से आगे, यह heredocs और inline scripts को स्कैन करता है, context को classify करता है और allowlists लागू करता है।
dcg पहचानता है कि कौन-सा agent उसे call कर रहा है, और per-agent profile लागू कर सकता है जो packs जोड़ता या हटाता है, allowlist को चौड़ा करता है, या अज्ञात callers के लिए allowlists को पूरी तरह अनदेखा कर देता है। समर्थित सूची लंबी है और जहाँ संभव हो hook-native है: Claude Code, Codex CLI 0.125.0+, Gemini CLI, GitHub Copilot CLI, VS Code Copilot Chat, Cursor, Hermes Agent, Grok, Antigravity CLI, OpenCode, Oh My Pi, Crush, Pi, Posit Assistant, साथ में Aider (सिर्फ़ git hooks) और Continue (सिर्फ़ detection)। Escape hatches जानबूझकर और स्तरीय हैं: एक command के लिए `DCG_BYPASS=1`, block message में छपा एक allow-once code, या कारण दर्ज के साथ एक स्थायी allowlist entry। यह project Jeffrey Emanuel का Python hook के रूप में शुरू हुआ, Darin Gordon ने इसे Rust में port किया, और उसके बाद इसका काफ़ी विस्तार हुआ।
Distribution सुरक्षा को ध्यान में रखकर बनाया गया है: PowerShell installer एक अनिवार्य SHA256 checksum verify करता है, minisign मौजूद होने पर release की minisign signature जाँचता है, और cosign तथा trusted bundle उपलब्ध होने पर Sigstore/cosign provenance verify करता है।
यह क्या करता है
- destructive git, filesystem, database, Kubernetes, cloud और container commands को execution से पहले ब्लॉक करता है, साथ में स्पष्टीकरण और सुरक्षित विकल्प के साथ
- categories में व्यवस्थित 50+ modular rule packs, जिन्हें `~/.config/dcg/config.toml` में हर category या हर sub-pack के लिए चालू या बंद किया जा सकता है
- Per-agent profiles: packs जोड़ें या हटाएँ, allowlist बढ़ाएँ, या अज्ञात callers के लिए allowlist bypass पूरी तरह बंद करें
- Claude Code, Codex CLI, Gemini CLI, GitHub Copilot CLI, VS Code Copilot Chat, Cursor, Hermes Agent, Grok, OpenCode, Crush, Oh My Pi और अन्य के साथ native hook integration
- Sub-millisecond Rust implementation, SIMD-accelerated filtering, heredoc और inline-script scanning, और context classification के साथ
- स्तरीय escape hatches — एक बार का `DCG_BYPASS=1`, block message का allow-once code, या कारण के साथ स्थायी allowlist entry
- Installers SHA256 checksum verify करते हैं, और tooling उपलब्ध होने पर minisign तथा Sigstore/cosign provenance भी
शुरू करें
Installer आपका platform अपने-आप पहचानता है, सही binary डाउनलोड करता है और जो भी समर्थित agents मिलते हैं उन्हें wire up कर देता है। यह Linux, macOS और Windows पर चलता है (PowerShell के ज़रिए native रूप से, या WSL के ज़रिए)।
Linux या macOS पर इंस्टॉल करें
Easy mode हर पहचाने गए agent के लिए hooks कॉन्फ़िगर करता है।
curl -fsSL "https://raw.githubusercontent.com/Dicklesworthstone/destructive_command_guard/main/install.sh?$(date +%s)" | bash -s -- --easy-modeWindows पर इंस्टॉल करें
PowerShell installer checksum verify करता है, dcg को आपके user PATH में जोड़ता है और एक self-test चलाता है।
& ([scriptblock]::Create((irm "https://raw.githubusercontent.com/Dicklesworthstone/destructive_command_guard/main/install.ps1"))) -EasyMode -Verifyकिसी खास agent को wire up करें
कई agents को Claude compatibility layer के बजाय native hook मिलता है। OpenCode के लिए, `dcg install --opencode` एक `tool.execute.before` plugin `~/.config/opencode/plugins/dcg-guard.js` में लिखता है (`<repo>/.opencode/plugins/dcg-guard.js` के लिए `--project` जोड़ें); इसके बाद OpenCode को restart करें, और `opencode_plugin` status जाँचने के लिए `dcg doctor` चलाएँ।
dcg install --grok # ~/.grok/hooks/dcg.json
dcg install --opencode # tool.execute.before plugin
dcg install --crush # hooks.PreToolUse in crush.json
dcg install --omp # Oh My Pi tool_call extensionअपने rule packs चुनें
असली pack और category IDs देखने के लिए `dcg packs` चलाएँ, फिर जो चाहिए उसे चालू करें। एक bare category अपने सभी sub-packs में फैल जाती है।
# ~/.config/dcg/config.toml
[packs]
enabled = [
"database.postgresql", # Blocks DROP TABLE, TRUNCATE
"kubernetes.kubectl", # Blocks kubectl delete namespace
"cloud.aws", # Blocks aws ec2 terminate-instances
"containers.docker", # Blocks docker system prune
]False positive से कैसे निपटें
बार-बार आने वाली किसी भी चीज़ के लिए allowlist entry को प्राथमिकता दें; DCG_BYPASS उस एक invocation के लिए सारी सुरक्षा बंद कर देता है।
DCG_BYPASS=1 <command> # single command
dcg allow-once <code> # code from the block message
dcg allowlist add core.git:reset-hard -r "reason" # permanentकमांड और कोड प्रोजेक्ट के अपने दस्तावेज़ों से लिए गए हैं — हमेशा जांचें आधिकारिक repo ताज़ा जानकारी के लिए।
कब इस्तेमाल करें
- `git reset --hard` या `rm -rf` से coding agent को uncommitted काम मिटाने से रोकना
- database, kubernetes और cloud packs के ज़रिए agents को production databases, Kubernetes namespaces और cloud resources से दूर रखना
- एक ही machine पर कई अलग-अलग coding agents को एक ही policy के तहत चलाना, हर agent के लिए अलग trust profiles के साथ
- कम भरोसेमंद या अपरिचित agent को सख्त rule set देना और allowlist bypass न देना
How dcg (Destructive Command Guard) compares
dcg (Destructive Command Guard) alongside other open-source guardrails & security tools AI/TLDR tracks, ranked by GitHub stars.
| टूल | स्टार | यह क्या करता है |
|---|---|---|
| SkillSpector | ★ 28.6k | इंस्टॉल करने से पहले कोई agent skill दुर्भावनापूर्ण पैटर्न के लिए स्कैन करें |
| Presidio | ★ 12.2k | टेक्स्ट, इमेज और स्ट्रक्चर्ड डेटा में PII की पहचान करें और उसे हटाएं |
| Failproof AI | ★ 10.5k | एक policy API, जो Claude Code, Codex, Cursor और नौ अन्य agent harnesses से जुड़कर हर event पर agent को block, warn या steer करता है |
| Guardrails AI | ★ 7.7k | Python में कंपोज़ेबल गार्ड्स से LLM के इनपुट और आउटपुट वैलिडेट करें |
| NeMo Guardrails | ★ 7.6k | LLM चैट ऐप्स में programmable rails जोड़ें, ताकि वे सुरक्षित रहें और विषय पर बनी रहें |
| BLA (Blind LLM Agents) | ★ 7.5k | आपके रिलीज़ किए गए build को इतना मज़बूत बनाएं कि AI reverse-engineering agents का बजट खत्म हो जाए और वे नकली चीज़ों के पीछे भागें |
| dcg (Destructive Command Guard) | ★ 6.4k | एक Rust pre-tool hook जो coding agent के चलाने से पहले destructive shell और git commands को ब्लॉक करता है |
| GLiNER | ★ 4.3k | किसी भी entity type के लिए zero-shot named-entity recognition, जो इतना छोटा है कि CPU पर चल जाए |
