SkillAgentSearch skills...

git-guardrails-claude-code

Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute

Install / Use

npx skills add mattpocock/skills --skill git-guardrails-claude-code

Installs into whichever agent you are using.

About this skill
📄

SKILL.md

Installable skill definition

Quality Score

88/100

Supported Platforms

Claude Code

Our assessment of git-guardrails-claude-code

git-guardrails-claude-code scores 88/100 on our quality scale, 1822nd of 4,648 Development & Engineering skills we index (top 40%).

Its SKILL.md is 2.3 KB long, well organised into 8 sections with 3 code examples: moderately detailed.

With 268,790 GitHub stars, it is one of the more widely adopted skills in the catalogue.

Substance
20/30
Structure
18/20
Description
15/15
Adoption
20/20
Freshness
15/15

Maintenance, license and trust

  • The repository was last updated about 2 months ago, so git-guardrails-claude-code is actively maintained.
  • Our last check on 2026-10-31 found the source still online.
  • It is released under the MIT license, a permissive license that allows use, modification and commercial use with attribution.
  • Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.

Safety scan

No issues found

Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful.

AI review by kimi-k2.7-code on 2026-09-25. Automated pattern scan on 2026-09-24. It catches known dangerous patterns, not every risk — read a skill before letting an agent act on it.

git-guardrails-claude-code compared with similar skills

All 4 of these similar skills score higher than git-guardrails-claude-code; compare them before choosing.

SkillScoreStarsUpdatedFormat
git-guardrails-claude-code (this skill)by mattpocock88268.8k45d agoSKILL.md
taste-skillby Leonxlnx100112.0k1d agoCLAUDE.md
Agent-Reachby Panniantong100110.3k1d agoCLAUDE.md
ai-job-searchby ai-job-search-dev10070.5ktodayCLAUDE.md
claude-howtoby luongnv8910046.7k5d agoCLAUDE.md

Frequently asked questions

How do I install git-guardrails-claude-code?
Run npx skills add mattpocock/skills --skill git-guardrails-claude-code. The install tabs above show the steps for each supported agent.
Which AI agents does git-guardrails-claude-code work with?
It is written for Claude Code, as a SKILL.md file. Other agents that read the same format can often use it too.
Is git-guardrails-claude-code safe to use?
Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful. It is MIT-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
Is git-guardrails-claude-code still maintained?
The repository was last updated about 2 months ago, so git-guardrails-claude-code is actively maintained.

name: git-guardrails-claude-code description: 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.

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.

Related Skills

View on GitHub
GitHub Stars268.8k
CategoryDevelopment
Updated1mo ago
Forks22.7k

Languages

Shell

Trust signals

100/100

From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.

No cautions