git-guardrails-claude-code
Skill0 starsChanged 6 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
121 other projects use a version of this, 118 of them edited.
Adopted by
Most recently taken up by
- 5thlayer/skillworksedited, first seen Nov 8, 2026
- dfirmin/compassedited, first seen Nov 8, 2026
- op3616windows/skillsedited, first seen Nov 8, 2026
- kazemcodes/skill-treeedited, first seen Nov 8, 2026
- itsryanarmani/skillsedited, first seen Nov 8, 2026
- shkodnik1917/claude-brainlabedited, first seen Nov 8, 2026
Used with
Projects with it also use setup-ts-deep-modules, loop-me and 6 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.
liufeng1976Skillsetup-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 40 projects that use this
RoentekSkillloop-me
Grill me about specs for the workflows I want to build, within this workspace.
Also in 51 projects that use this
ryotaroh180105Skillclaude-handoff
Hand the current conversation off to a fresh background agent that picks up the work immediately.
Also in 39 projects that use this
boyingliu01Skillbatch-grill-me
A relentless interview that asks every frontier question at once, round by round. Thin alias of `grilling` (#540) — upstream mattpocock/skills absorbed this protocol into grilling; XP-Gate keeps this name as the sprint-flow Phase 2 entry point so orchestration docs stay stable.
Also in 6 projects that use this
GoogleSkillask-matt
Ask which skill or flow fits your situation. A router over the skills in this repo.
Also in 39 projects that use this
FabienDehopreSkilldecision-mapping
Turn a loose idea into a sequenced map of investigation tickets, then drive them to resolution one at a time.
Also in 4 projects that use this
Other versions121 projects use a version of this.
Word for word · 0
None found.
Edited · 118
- mattpocock/skills★ 309k24% same
- vinvcn/mattpocock-skills-zh-CN★ 5.5k54% same
- devcxl/mattpocock-skills-zh★ 52238% same
- amazingloft999-droid/mattpocock-skills★ 42224% same
- InditexTech/weavejs★ 26624% same
- loulanyue/skills★ 23124% same
- tt-a1i/matt-skills-with-to-goal★ 19224% same
- aurorasoft2/Matt_Pocock_Skills★ 13324% same
- Tresnanda/kybern★ 8324% same
- VisualxIntelligence/mattpocok-skills★ 5524% same
108 more not listed
Wrote their own version · 3
- chrislacey89/skills★ 4same name
- wakqasahmed/ai-engineering-workflow-skills★ 2same 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 repository29 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- design-an-interfaceSkill
- qaSkill
- request-refactor-planSkill
- ubiquitous-languageSkill
- diagnoseSkill
- grill-with-docsSkill
- improve-codebase-architectureSkill
- prototypeSkill
- setup-matt-pocock-skillsSkill
- tddSkill
- to-issuesSkill
- to-prdSkill
- triageSkill
- zoom-outSkill
- reviewSkill
- writing-beatsSkill
- writing-fragmentsSkill
- writing-shapeSkill
- migrate-to-shoehornSkill
- scaffold-exercisesSkill
- setup-pre-commitSkill
- edit-articleSkill
- obsidian-vaultSkill
- cavemanSkill
- grill-meSkill
- handoffSkill
- write-a-skillSkill
The file
Files
Setup Git Guardrails
设置一个 PreToolUse hook,在 Claude 执行危险 git commands 前拦截并阻止它们。
What Gets Blocked
git push(包括--force在内的所有变体)git reset --hardgit clean -f/git clean -fdgit branch -Dgit checkout ./git restore .
被阻止时,Claude 会看到一条消息,说明它没有权限访问这些 commands。
Steps
1. Ask scope
询问用户:只为当前项目(.claude/settings.json)安装,还是为所有项目(~/.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 合并到现有 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.
Reviews can't be read right now.
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.

