git-guardrails-claude-code
यह क्या करती है
यह Claude Code में एक सुरक्षा जांच जोड़ती है जो कुछ git कमांड को चलने से रोकती है। यह उन लोगों के लिए है जो अपनी कोड रिपॉज़िटरी को गलती से होने वाले नुकसान से बचाना चाहते हैं।
कब इस्तेमाल करें
- ✓जब आप नहीं चाहते कि एजेंट गलती से कोड push करे।
- ✓जब आप git reset --hard जैसे विनाशकारी कमांड रोकना चाहते हों।
- ✓जब आप ये सुरक्षा नियम एक प्रोजेक्ट पर या अपने सभी प्रोजेक्ट्स पर लागू करना चाहते हों।
Skill का लिंक
https://github.com/mattpocock/skills/blob/main/skills/misc/git-guardrails-claude-code/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“सुरक्षा hooks सेट कीजिए ताकि Claude Code गलती से मेरी git रिपॉज़िटरी में push या reset न कर सके।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट एक hook स्क्रिप्ट आपके प्रोजेक्ट या home सेटिंग्स में कॉपी करता है और उसे सेटिंग्स फ़ाइल में जोड़ता है। जब कोई रोका गया कमांड चलाने की कोशिश होती है, तो hook उसे रोकता है और एजेंट को बताता है कि उसके पास उसे चलाने का अधिकार नहीं है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Setup Git Guardrails
Sets up a PreToolUse hook that intercepts and blocks dangerous git commands before Claude executes them.
What Gets Blocked
git push(all variants including--force)git reset --hardgit clean -f/git clean -fdgit branch -Dgit checkout ./git restore .
When blocked, Claude sees a message telling it that it does not have authority to access these commands.
Steps
1. Ask scope
Ask the user: install for this project only (.claude/settings.json) or all projects (~/.claude/settings.json)?
2. Copy the hook script
The bundled script is at: scripts/block-dangerous-git.sh
Copy it to the target location based on scope:
- Project:
.claude/hooks/block-dangerous-git.sh - Global:
~/.claude/hooks/block-dangerous-git.sh
Make it executable with chmod +x.
3. Add hook to settings
Add to the appropriate settings file:
Project (.claude/settings.json):
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/block-dangerous-git.sh"
}
]
}
]
}
}
Global (~/.claude/settings.json):
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/block-dangerous-git.sh"
}
]
}
]
}
}
If the settings file already exists, merge the hook into the existing hooks.PreToolUse array. Don't overwrite other settings.
4. Ask about customization
Ask if user wants to add or remove any patterns from the blocked list. Edit the copied script accordingly.
5. Verify
Run a quick test:
echo '{"tool_input":{"command":"git push origin main"}}' | <path-to-script>
Should exit with code 2 and print a BLOCKED message to stderr.
अक्सर पूछे जाने वाले सवाल
कौन-से git कमांड रोके जाते हैं?
हर तरह के push, git reset --hard, git clean -f, git branch -D, और सभी फ़ाइलों पर लागू checkout या restore।
क्या मैं चुन सकता हूं कि नियम कहां लागू हों?
हां। स्किल पूछती है कि इन्हें केवल इस प्रोजेक्ट के लिए इंस्टॉल करना है या सभी प्रोजेक्ट्स के लिए।
कोई कमांड रोके जाने पर क्या होता है?
Claude को एक संदेश दिखता है कि उसके पास उस कमांड तक पहुंचने का अधिकार नहीं है।
जानकारी
लेखक का मूल विवरण
Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute. Use when user wants to prevent destructive git operations, add git safety hooks, or block git push/reset in Claude Code.
repo: mattpocock/skills
लोकप्रियता
- GitHub स्टार
- 310k
- रैंकिंग में स्थान
- #120
- लाइसेंस
- MIT
- अपडेट की गई
- 1/11/2026
कमेंट
- …
इस repository की और skills
ask-matt
310kयह आपके एजेंट को कोडिंग स्किल के एक सेट का मार्गदर्शक बनाती है, जो आपकी स्थिति के लिए सही स्किल की ओर इशारा करता है, विचार से लेकर भेजे गए कोड तक।
code-review
310kयह आपके बदलावों को आपकी रिपॉज़िटरी के कोडिंग मानकों और मूल स्पेक के साथ जांचती है, merge से पहले दोनों समीक्षाएं साथ-साथ चलाकर।
domain-modeling
310kयह एक साझा प्रोजेक्ट शब्दावली बनाती है और मुख्य डिज़ाइन फ़ैसले दर्ज करती है, ताकि आपका कोड वही शब्द इस्तेमाल करे जो आपकी टीम करती है।
implement-spec
310kएक पूरे स्पेक और उसके टिकट्स को काम करने वाले कोड में बदलती है, टिकट्स को क्रम से संभालते हुए और उन्हें एक branch में जोड़ते हुए।
मिलती-जुलती skills
openclaw-update
394kयह आपके एजेंट को चल रहे OpenClaw Gateway को अपडेट करने में मदद करती है, इंस्टॉल के तरीके के अनुसार सही विधि चुनकर और सेशन बनाए रखकर।
diagnose-gateway
394kयह आपके एजेंट को सेटिंग्स, चैनल और पोर्ट जांचकर पता लगाने देती है कि OpenClaw Gateway क्यों फ़ेल हो रहा है, बिना कुछ बदले।
crabbox-apps
394kयह आपके एजेंट को किसी अस्थायी क्लाउड मशीन पर ऐप खोलने और चलाने देती है, फिर उसका व्यू आपके चैट के साइड पैनल में दिखाती है।