Skills-compatible agents / Git workflow
Git Guardrails for Claude Code Bash Calls
Configures a Claude Code PreToolUse hook that rejects selected dangerous Git command patterns before its Bash tool runs them.
318,785 repository stars · checked 2026-11-09. Count applies to mattpocock/skills, not this individual skill.
Guide by IDAKIM Digital. Source review: . Original explanation based on the linked publisher sources.
What it does
The source offers project or global scope, copies a bundled Bash hook and merges a Bash matcher into existing settings. The reviewed script reads JSON with jq and matches command text using regular expressions. Its listed patterns cover push, hard reset, forced clean, force-deleting a branch and broad checkout or restore operations. A matching command exits with status 2 and a blocked message. This is a practical guard against common command shapes, not a complete Git authorization or shell-parsing boundary.
When to use it
- Prevent accidental pushes from a project’s Claude Code sessions.
- Add an extra stop before common destructive working-tree commands.
- Apply reviewed Git restrictions across a developer’s Claude Code projects.
Step-by-step workflow
- Choose project-only or global scope with the repository owner.
- Read the bundled hook and check its Bash and jq requirements.
- Copy the reviewed hook into the chosen hooks directory without overwriting other controls.
- Merge its PreToolUse entry into the existing Bash hooks array.
- Test harmless synthetic hook input and review customized patterns before use.
Example request
Prepare a project-only git-guardrails-claude-code configuration. Inspect existing hooks and preserve them. Explain exactly which command strings the reviewed script matches and where a regex-based check can miss equivalent operations. Propose the settings merge and a synthetic blocked-push check. Do not push, reset, clean or install anything during this review.
Worked example
A synthetic JSON request containing git push origin main should be rejected by the hook before a real push occurs. That demonstrates the selected pattern, not every possible route to modifying a remote. Alternate tools, unusual shell syntax or an invocation that changes the command shape may fall outside the matcher. A useful handover names those limits, confirms existing hooks remain present and tells the maintainer how to inspect the selected scope.
What you get
A scoped hook configuration and a small verification plan for the command patterns it actually recognizes.
How to evaluate the result
- Verify a sample blocked request exits 2 without executing Git.
- Check existing hooks survive the settings merge.
- Document unsupported command forms and other tool paths.
What you need
Claude Code with supported PreToolUse hooks, Bash, jq, readable settings and a reviewed copy of the bundled script. Other agents need different integration.
Setup and activation
The publisher documents plugin setup for Claude Code, Codex and Copilot, and manual Agent Skills setup for Gemini CLI and other clients. Choose one distribution method per client to avoid duplicate skills. The engineering collection expects project-specific tracker, triage-label and document-location settings from setup-matt-pocock-skills. Keep referenced companion skills and files available. This catalogue review does not install or run them; scan the exact source before any later installation. Client tools, permissions and subagent support still need separate validation.
Limits and considerations
Regex matching is not comprehensive command analysis. It can miss alternate forms and block harmless text. The script includes the rejected command in stderr, so never place secrets in command strings. Existing permissions, backups and code review remain necessary.
Related workflows
- Pair with pr for reviewing authorized Git changes.
- Use handoff to explain repository restrictions to another session.
License and reuse
MIT at repository level (Copyright 2026 Matt Pocock). Preserve the copyright and permission notice when redistributing substantial source material; inspect any separately licensed dependencies or assets.
Further reading
Read the original source
Publisher: mattpocock/skills
Source reviewed: 2026-11-09
Source reviewed; not installed, executed or security-scanned for this directory. These example requests were written by IDAKIM Digital. Upstream content can change.