मुख्य सामग्री पर जाएँ
Skillpedia
डिप्लॉय और क्लाउड (DevOps)310k · #120

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 पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/mattpocock/skills/blob/main/skills/misc/git-guardrails-claude-code/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

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 --hard
  • git clean -f / git clean -fd
  • git branch -D
  • git 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

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

ask-matt

310k

यह आपके एजेंट को कोडिंग स्किल के एक सेट का मार्गदर्शक बनाती है, जो आपकी स्थिति के लिए सही स्किल की ओर इशारा करता है, विचार से लेकर भेजे गए कोड तक।

AI और एजेंटएजेंट

code-review

310k

यह आपके बदलावों को आपकी रिपॉज़िटरी के कोडिंग मानकों और मूल स्पेक के साथ जांचती है, merge से पहले दोनों समीक्षाएं साथ-साथ चलाकर।

कोडिंगसामान्य कोडिंग

domain-modeling

310k

यह एक साझा प्रोजेक्ट शब्दावली बनाती है और मुख्य डिज़ाइन फ़ैसले दर्ज करती है, ताकि आपका कोड वही शब्द इस्तेमाल करे जो आपकी टीम करती है।

कोडिंगसामान्य कोडिंग

implement-spec

310k

एक पूरे स्पेक और उसके टिकट्स को काम करने वाले कोड में बदलती है, टिकट्स को क्रम से संभालते हुए और उन्हें एक branch में जोड़ते हुए।

कोडिंगसामान्य कोडिंग

मिलती-जुलती skills