Git guardrails claude code
A curated library of 124 AI agent skills organized into 10 categories, with model-specific versions for Claude, GPT-5.5, GPT-5.4 and earlier, GLM, and DeepSeek.
npx -y skills add mhrsdev/AI-Agent-Skills-Library --skill git-guardrails-claude-codeAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
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.
SKILL.md
2.3 KB, 513 tokens by cl100k_base, as published. Nobody here has run it
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.
What ships with it: 2 files
3.1 KB alongside SKILL.md, 1 of them executable
scripts/
- block-dangerous-git.shruns507 B
- README.md2.6 KB
Gives 4 of the 12 instructions most context ai engineering skills give in 513 tokens
Counted across 1,193 of the 1,976 authors here whose files we hold, read 2026-08-07
- dispatch a fresh implementer subagent per taskin 48 of 1193, across 19 files
- dispatch a final code reviewer after all tasksin 33 of 1193, across 8 files
- provide full task text to the subagentin 30 of 1193, across 9 files
- review spec compliance before code qualityin 27 of 1193, across 10 files
- make the hook script executablehere, and in 26 of 1193, across 8 files
- re-snapshot after navigation or DOM changesin 25 of 1193, across 19 files
- read files before editing themin 22 of 1193, across 11 files
- answer subagent questions before proceedingin 22 of 1193, across 7 files
- mark task complete in TodoWrite after approvalin 22 of 1193, across 6 files
- merge hook into existing settingshere, and in 21 of 1193, across 3 files
- ask if installation is global or projecthere, and in 20 of 1193, across 2 files
- copy the hook script to target locationhere, and in 20 of 1193, across 2 files
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.