Skill Issue
← Browse

git-guardrails-claude-code

Stop the AI wiping work

  • For people who code
  • Needs: Claude Code and the small jq tool; it adds an always-on check to Claude Code's settings…
by mattpocock
Add to your AI

What it does

Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute.
mattpocock, in the skill's own instructions
Instructions the AI follows

This is the skill's own instruction file. It's written for the AI, so it can read like a list of orders. You don't need to read it to use the skill.

Instruction file1 min read

Sets up a PreToolUse hook that intercepts and blocks dangerous git commands before Claude executes them.

  • 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.

Ask the user: install for this project only (.claude/settings.json) or all projects (~/.claude/settings.json)?

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.

Add to the appropriate settings file:

Project (.claude/settings.json):

json
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/block-dangerous-git.sh"
          }
        ]
      }
    ]
  }
}

Global (~/.claude/settings.json):

From skills/misc/git-guardrails-claude-code/SKILL.md in mattpocock/skills · read from GitHub at commit 5863806

Try it

  1. 1Add git-guardrails-claude-code to your AI
  2. 2Ask for something like this
Your AI
  • Set up git guardrails for this project only.

  • Block git push and reset --hard in all my projects, not just this one.

  • Also block git stash drop, and show me the test that proves it works.

Example prompts written from the skill's instructions.

Safety

SafeDetails

All three scanners ran and found nothing that could steal your data or hijack your AI.

What it can do
  • Runs commands on your computer
  • Reads keys or settings
  • Asks for wide access to your files
Scanners
SkillSpector 2.12.0 · HoneyBadger 0.8.1 · agentscan 1.2.2
Scanned on
Nov 19, 2026
  • Secret scanNoticedSkillSpector: AS1 HIGH SKILL.md:24 Agent Config Directory Access Reads your AI tool's settings folder. (LLM02 Sensitive Information Disclosure)SkillSpector: AS1 HIGH SKILL.md:61 Agent Config Directory Access Reads your AI tool's settings folder. (LLM02 Sensitive Information Disclosure)
  • Dangerous commandsNoticedagentscan: filesystem high SKILL.md:13 git reset --hard (discards work) Can delete or overwrite your files. (LLM06 Excessive Agency)agentscan: filesystem high SKILL.md:14 git clean -f (deletes untracked) Can delete or overwrite your files. (LLM06 Excessive Agency)agentscan: filesystem medium scripts/block-dangerous-git.sh:10 git clean -f (deletes untracked) Can delete or overwrite your files. (LLM06 Excessive Agency)
  • Network callsPassed
  • PermissionsNoticedHoneyBadger: cap-env-drift MEDIUM scripts/block-dangerous-git.sh:19 undeclared env vars: COMMAND, INPUT (3 total evidence lines) Uses keys or settings without saying so. (LLM02 Sensitive Information Disclosure)
  • Prompt injectionPassed
  • LicensePassed
  • MaintenancePassed
Human review

No person has signed this one off yet.

Three open-source scanners (SkillSpector, HoneyBadger, agentscan) check this exact version. Heads up means it could steal your data or hijack your AI. What it can do is listed, not warned about. Scanners miss things.

How we check: only harm earns a Heads up, meaning prompt injection (OWASP LLM01) or data leaks (LLM02), in files the skill ships. Abilities like running commands (LLM06) are listed, not warned about. No AI is used for this step. OWASP

Details

Stars
332kwhole repo
Installs
582kon skills.sh
Last updated
Nov 24, 2026on GitHub

GitHub and skills.sh numbers are a snapshot from Nov 24, 2026, not live.

Community

Comments

See all Build skills

How to add git-guardrails-claude-code to Claude

Press Add to your AI at the top of this page and pick Claude, or do it yourself:

  1. Download the skill. Keep the .zip as it is.
  2. On Claude's skills page, click +, then Create skill, then Upload a skill.
  3. Pick the file you downloaded and switch the skill on.

Works on every Claude plan, Free included. Code execution and file creation need to be on in Claude's settings. How to add a skill to Claude, step by step.

In ChatGPT

Skills are on ChatGPT Business, Enterprise, Healthcare and Edu plans. Download the skill. Keep the .zip as it is. In ChatGPT, open Plugins in the sidebar, then the Skills tab, then Create, then Upload from your computer. Pick the file you downloaded. ChatGPT checks it, then it's ready. More on ChatGPT.

For AI apps and agents: the skill's instructions as plain text, at the version we scanned.

On these lists