git-guardrails-claude-code
Skill4.6k starsChanged 4 months agoMITView on GitHub
设置 Claude Code hooks,在危险 git commands(push、reset --hard、clean、branch -D 等)执行前阻止它们。适用于用户想防止破坏性 git 操作、添加 git safety hooks,或在 Claude Code 中阻止 git push/reset 时。
- Deletes or force-pushes
- Commits and pushes
55 other projects use a version of this, 53 of them edited.
Trending
Quiet since October.thin dataabout the whole repository
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
Who's talking about vinvcn/mattpocock-skills-zh-CN
- sudosubin/agents.nix“agent-skills.github.vinvcn.mattpocock-skills-zh-cn: init at 1.2.3”GitHub · Oct 4, 2026
- Dysonnnn/MySoftwareList“mattpocock-skills-zh-CN”GitHub · Jun 20, 2026
- mattpocock/skills“Proposal: add a Community Translations section to the README”GitHub · May 12, 2026
The biggest 3 of 3 mentions linking to the repository that our crawl found. Each line is their own headline.
Used with
Projects with it also use batch-grill-me and obsidian-vault.
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.
47thtechcornerSkillbatch-grill-me
A relentless interview that asks every frontier question at once, round by round.
Also in 4 projects that use this
qhkmSkillobsidian-vault
Manage Obsidian vaults using built-in filesystem tools. Understands vault structure, frontmatter, wikilinks, tags, tasks, daily notes, and templates.
Also in 15 projects that use this
Other versions55 projects use a version of this.
Word for word · 0
None found.
Edited · 53
- mattpocock/skills★ 335k25% same
- devcxl/mattpocock-skills-zh★ 42632% same
- amazingloft999-droid/mattpocock-skills★ 42225% same
- loulanyue/skills★ 23125% same
- tt-a1i/matt-skills-with-to-goal★ 18225% same
- aurorasoft2/Matt_Pocock_Skills★ 13325% same
- VisualxIntelligence/mattpocok-skills★ 5525% same
- leandrocfe/skills★ 3825% same
- neuron-one/GODMODE★ 3324% same
- VoDaiLocz/kilo-kit-mcp★ 2725% same
43 more not listed
Wrote their own version · 2
- chrislacey89/skills★ 3same name
- wakqasahmed/skills★ 2same 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 repository39 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- ask-mattSkill
- codebase-designSkill
- code-reviewSkill
- diagnosing-bugsSkill
- domain-modelingSkill
- grill-with-docsSkill
- implementSkill
- improve-codebase-architectureSkill
- prototypeSkill
- researchSkill
- resolving-merge-conflictsSkill
- setup-matt-pocock-skillsSkill
- tddSkill
- to-specSkill
- to-ticketsSkill
- triageSkill
- wayfinderSkill
- wizardSkill
- claude-handoffSkill
- implement-specSkill
- loop-meSkill
- prSkill
- retroSkill
- setup-ts-deep-modulesSkill
- writing-beatsSkill
- writing-fragmentsSkill
- writing-shapeSkill
- migrate-to-shoehornSkill
- scaffold-exercisesSkill
- setup-pre-commitSkill
- grillingSkill
- grill-meSkill
- handoffSkill
- teachSkill
- to-questionnaireSkill
- wait-whatSkill
- writing-for-agentsSkill
The file
Files
Setup Git Guardrails
设置一个 PreToolUse hook,在 Claude 执行危险 git commands 前拦截并阻止它们。
What Gets Blocked
git push(包括--force在内的所有 variants)git reset --hardgit clean -f/git clean -fdgit branch -Dgit checkout ./git restore .
被阻止时,Claude 会看到一条 message,说明它无权访问这些 commands。
Steps
1. Ask scope
询问用户:只为当前 project 安装(.claude/settings.json),还是为所有 projects 安装(~/.claude/settings.json)?
2. Copy the hook script
bundled script 位于:scripts/block-dangerous-git.sh
根据 scope 复制到目标位置:
- Project:
.claude/hooks/block-dangerous-git.sh - Global:
~/.claude/hooks/block-dangerous-git.sh
用 chmod +x 让它可执行。
3. Add hook to settings
添加到对应 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"
}
]
}
]
}
}如果 settings file 已存在,把 hook merge 到现有 hooks.PreToolUse array 中,不要覆盖其他 settings。
4. Ask about customization
询问用户是否要在 blocked list 中添加或移除 patterns。相应编辑复制后的 script。
5. Verify
运行快速测试:
echo '{"tool_input":{"command":"git push origin main"}}' | <path-to-script>应以 code 2 退出,并向 stderr 打印 BLOCKED message。
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.

