git-guardrails-claude-code
Skill2 starsChanged 7 months agoMITView on GitHub
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. Use when the user says "/git-guardrails-claude-code", "git guardrails claude code", or asks about git guardrails claude code.
- Deletes or force-pushes
- Commits and pushes
55 other projects use a version of this, 54 of them edited.
Adopted by
Most recently taken up by
- mattpocock/skillsedited, first seen Oct 8, 2026
- hmjBill/skillsedited, first seen Oct 5, 2026
- KroxiDev/engineering-skillsedited, first seen Oct 5, 2026
- nomdedev/agent-manager-templateedited, first seen Sep 30, 2026
- snowfluke/engineering-skillsedited, first seen Sep 30, 2026
- chinkan/RustFoxedited, first seen Sep 22, 2026
Used with
Projects with it also use setup-ts-deep-modules, writing-beats and 8 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
loulanyueSkillsetup-ts-deep-modules
Wire dependency-cruiser into a TypeScript repo so each package is a deep module — implementation hidden in subfolders, reachable only through its entry-point files. User-invoked.
Also in 16 projects that use this
RoentekSkillwriting-beats
Writing, exploit — assemble raw material into a journey of beats, grounding each term before a beat leans on it.
Also in 22 projects that use this
RoentekSkillwriting-fragments
Writing, explore — mine raw fragments, no structure yet.
Also in 22 projects that use this
qwlabsSkillclaude-handoff
Hand the current conversation off to a fresh background agent that picks up the work immediately.
Also in 16 projects that use this
47thtechcornerSkillbatch-grill-me
A relentless interview that asks every frontier question at once, round by round.
Also in 4 projects that use this
AWSSkillwizard
Generate an interactive bash wizard that walks a human through steps only they can perform. Use when provisioning infrastructure, setting up credentials or CI secrets, walking an unfamiliar third-party dashboard, or running a one-off migration or cutover. Don't invoke this for steps the agent can perform itself.
Also in 26 projects that use this
- +2 more from Roentek
Other versions55 projects use a version of this.
Word for word · 0
None found.
Edited · 54
- mattpocock/skills★ 335k98% same
- vinvcn/mattpocock-skills-zh-CN★ 4.6k33% same
- devcxl/mattpocock-skills-zh★ 42628% same
- amazingloft999-droid/mattpocock-skills★ 42299% same
- loulanyue/skills★ 23199% same
- tt-a1i/matt-skills-with-to-goal★ 18298% same
- aurorasoft2/Matt_Pocock_Skills★ 13399% same
- VisualxIntelligence/mattpocok-skills★ 5599% same
- leandrocfe/skills★ 3899% same
- neuron-one/GODMODE★ 3386% same
44 more not listed
Wrote their own version · 1
- chrislacey89/skills★ 3same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository85 other files it gives its agents.
- accessibility-auditingSkill
- adding-analyticsSkill
- adding-api-docsSkill
- adding-authSkill
- adding-dockerSkill
- adding-e2e-testsSkill
- adding-error-trackingSkill
- adding-feature-flagsSkill
- adding-stripeSkill
- api-smoke-testingSkill
- architecture-decision-recordsSkill
- auditing-performanceSkill
- auditing-securitySkill
- auto-type-checkingSkill
- babysitting-prSkill
- best-of-n-solvingSkill
- building-skills-from-patternsSkill
- cavemanSkill
- codebase-onboardingSkill
- comparing-branches-visuallySkill
- converting-css-modules-to-tailwindSkill
- converting-css-to-tailwindSkill
- creating-prSkill
- dark-mode-testingSkill
- database-designSkill
- design-an-interfaceSkill
- detecting-port-conflictsSkill
- domain-modelSkill
- edit-articleSkill
- exporting-to-pngSkill
- finding-dev-server-urlSkill
- fixing-broken-linksSkill
- form-testingSkill
- generating-imagesSkill
- github-triageSkill
- grill-meSkill
- grinding-until-passSkill
- improve-codebase-architectureSkill
- incident-responseSkill
- kubernetes-deployingSkill
- migrate-to-shoehornSkill
- monitoring-terminal-errorsSkill
- network-request-auditingSkill
- obsidian-vaultSkill
- parallel-ci-triageSkill
- parallel-code-reviewSkill
- parallel-exploringSkill
- parallel-test-fixingSkill
- profiling-performanceSkill
- prompt-engineeringSkill
- python-tdd-with-uvSkill
- qaSkill
- react-native-patternsSkill
- recording-browser-flow-as-testSkill
- request-refactor-planSkill
- responsive-testingSkill
- reviewing-codeSkill
- saving-workspace-contextSkill
- scaffold-exercisesSkill
- screenshotting-changelogSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
7 rules. 5 are common, 0 are distinctive, and 2 are very specific to this project.
5
Common
Most of the 49 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Common: line 18
When blocked, Claude sees a message telling it that it does not have authority to access these commands.
- Very specific: line 24
Ask the user: install for this project only (.claude/settings.json) or all projects (~/.claude/settings.json)?
- Common: line 39
Add to the appropriate settings file:
- Very specific: line 81
If the settings file already exists, merge the hook into existing hooks.PreToolUse array — don't overwrite other settings.
- Common: line 85
Ask if user wants to add or remove any patterns from the blocked list.
- Common: line 89
Run a quick test:
- Common: line 95
Should exit with code 2 and print a BLOCKED message to stderr.
“Common” is measured: kept by at least 6 in 10 of the 49 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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 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.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

