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…
What it does
Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute.
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.
Sets up a PreToolUse hook that intercepts and blocks dangerous git commands before Claude executes them.
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.
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):
{
"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
- 1Add git-guardrails-claude-code to your AI
- 2Ask for something like this
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
- Raw reports
- full report skillspector honeybadger agentscan
- Secret scanNoticed
SkillSpector: AS1 HIGH SKILL.md:24 Agent Config Directory AccessReads your AI tool's settings folder. (LLM02 Sensitive Information Disclosure)SkillSpector: AS1 HIGH SKILL.md:61 Agent Config Directory AccessReads your AI tool's settings folder. (LLM02 Sensitive Information Disclosure) - Dangerous commandsNoticed
agentscan: 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
- PermissionsNoticed
HoneyBadger: 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
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
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:
- Download the skill. Keep the .zip as it is.
- On Claude's skills page, click +, then Create skill, then Upload a skill.
- 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.