Set up Claude Code hooks to block dangerous git commands before they execute.
Automate repetitive workflows and reduce manual effort
Example: Generate reports, summarize documents, draft communications
Save 3-5 hours per week on routine tasks
Learn new skills, understand complex topics, get expert guidance
Example: Explain concepts, provide examples, suggest learning resources
Accelerate learning and skill development by 2x
Enhance output quality through reviews, suggestions, and refinements
Example: Review drafts, suggest improvements, catch errors
Improve work quality by 30-40% with less effort
Time estimate: 15-45 minutes depending on use case complexity
Prerequisites
Submit your Claude Code skill and start earning
epx add mattpocock/skills/blob/main/git-guardrails-claude-code/SKILL.md --skill git-guardrails-claude-codeCompatible with
Supported agents
| name | git-guardrails-claude-code |
| description | 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. |
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:
.claude/hooks/block-dangerous-git.sh~/.claude/hooks/block-dangerous-git.shMake 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):
{
"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.
Ask if user wants to add or remove any patterns from the blocked list. Edit the copied script accordingly.
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.
AI-first code editor with Composer
Before installing skills in Cursor, ensure your development environment meets these requirements:
node --versionmattpocock-git-guardrails-claude-codeExecute the skills CLI command in your project's root directory to begin installation:
epx add mattpocock/skills/blob/main/git-guardrails-claude-code/SKILL.md --skill git-guardrails-claude-codeFetches mattpocock-git-guardrails-claude-code from mattpocock/skills and configures it for Cursor.
The CLI shows a list of agents. Use arrow keys and space to select Cursor:
Confirm successful installation by checking the skill directory location:
.cursor/skills/mattpocock-git-guardrails-claude-code
Restart Cursor to activate mattpocock-git-guardrails-claude-code. Access via /mattpocock-git-guardrails-claude-code in your agent's command palette.
Learn more:View source on GitHubSkills CLI docsAbout CursorWhat are agent skills?
Steps
Common Pitfalls
✓ Do
✗ Don't
💡 Pro Tips
✓ Use when
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid when
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
write-a-prd
mattpocock/skills · Productivity · same repo
write-a-skill
mattpocock/skills · Productivity · same repo
prd-to-issues
mattpocock/skills · Productivity · same repo
wayfinder
mattpocock/skills · engineering · same repo
code-review
mattpocock/skills · engineering · same repo
prototype
mattpocock/skills · engineering · same repo
mattpocock-git-guardrails-claude-code reduced setup friction for our internal harness; good balance of opinion and flexibility.
Solid pick for teams standardizing on skills: mattpocock-git-guardrails-claude-code is focused, and the summary matches what you get after install.
mattpocock-git-guardrails-claude-code has been reliable in day-to-day use. Documentation quality is above average for community skills.
mattpocock-git-guardrails-claude-code has been reliable in day-to-day use. Documentation quality is above average for community skills.
mattpocock-git-guardrails-claude-code fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
mattpocock-git-guardrails-claude-code fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
mattpocock-git-guardrails-claude-code has been reliable in day-to-day use. Documentation quality is above average for community skills.
I recommend mattpocock-git-guardrails-claude-code for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
We added mattpocock-git-guardrails-claude-code from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
mattpocock-git-guardrails-claude-code fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
showing 1-10 of 75