SkillsReviewed · Matt Pocock

Git Guardrails for Claude Code

Git Guardrails for Claude Code is a setup skill for developers who want to prevent risky Git commands from their coding assistant, but its text matching can miss equivalent commands and block harmless text. It configures a Bash hook for one project or all projects.

Researched 13 Nov 2026

In short.

Git Guardrails for Claude Code is a skill for developers seeking protection against accidental Git operations by their assistant, but its hook provides incomplete coverage through command text matching. The bundled script checks for push, destructive reset, clean, branch deletion and restore patterns before Bash tool use. Installation can apply to one project or all projects. Dependency failures and alternative command spellings can escape the checks. Nothing was installed or executed, so actual blocking and Claude Code compatibility remain unverified.

Researched and written by an AI model and checked by a second AI model. How it works

Coverage includes all three files in skills/misc/git-guardrails-claude-code at revision 5863806dd4e15c63174bee4e7515a4256792ecfa and the associated repository LICENSE. Linked pages and other repository folders are excluded. Findings describe the instructions and static script behavior; installation, command execution, actual Claude Code blocking, operating system compatibility and performance were not assessed through execution.

The overview

Identity

The resource is the git-guardrails-claude-code instruction skill in Matt Pocock's skills repository. It contains setup instructions, a Bash hook script and interface metadata naming it Git Guardrails for Claude Code. Its purpose is to intercept selected Git commands before Claude Code executes them through its Bash tool.

The original resource address is [https://github.com/mattpocock/skills/tree/main/skills/misc/git-guardrails-claude-code]. The supplied files are pinned to revision 5863806dd4e15c63174bee4e7515a4256792ecfa.

Assessment

This is a small, understandable precaution against common accidental commands. Its usefulness comes from checking tool input before execution instead of depending only on instructions that the assistant must remember.

Its practical limit is the difference between recognizing text and understanding a shell command. The script can reject familiar spellings, but it cannot establish that every equivalent Git operation is blocked. Installation success, runtime behavior and compatibility with a particular Claude Code version are unverified.

Users

It fits developers using Claude Code who want to reduce accidental publishing, deletion or loss of local changes. Beginners get a predefined list of commands to restrict; experienced developers can inspect and edit the matching patterns.

The default policy includes ordinary git push commands, so it also interrupts routine publishing through the assistant. Users who expect the assistant to push branches regularly will need to adjust the patterns or their workflow.

Capabilities

The script checks for text matching git push, git reset --hard, git clean -fd, git clean -f, git branch -D, git checkout . and git restore . patterns. It also includes broader push --force and reset --hard patterns that do not require a preceding git word.

A match produces a BLOCKED message on standard error identifying the command and matching pattern, followed by exit status 2. Without a match, the script exits with status 0. The setup instructions support project or global installation and customization of the blocked patterns.

Using it

Requirements

The documented integration requires Claude Code command hooks, a PreToolUse configuration matching the Bash tool and an executable copy of the hook. The script requires Bash and the cat, jq and grep commands to be available to its process.

Input is expected to be JSON containing the command at tool_input.command. Minimum dependency versions, supported operating systems and a minimum compatible Claude Code version are not specified.

Mechanism

The hook reads standard input, extracts tool_input.command with jq and passes the resulting text through grep -qE for each pattern. It stops at the first match. It does not execute the submitted command, inspect repository state or parse shell syntax.

The settings attach this script to the Bash tool's PreToolUse event. The instructions describe exit status 2 as the blocking signal; actual Claude Code handling has not been demonstrated in the supplied evidence.

Setup

For one project, the instructions place the script at .claude/hooks/block-dangerous-git.sh and the hook configuration in .claude/settings.json. For all projects, they use ~/.claude/hooks/block-dangerous-git.sh and ~/.claude/settings.json. The copied script must be executable.

The configuration adds a command hook under hooks.PreToolUse with matcher Bash. The project command uses CLAUDE_PROJECT_DIR to locate the script. Existing settings should be preserved by merging the hook into the existing array. The instructions then offer pattern customization and a sample input check.

Example

The documented example supplies JSON containing tool_input.command set to git push origin main directly to the script. From the source, the expected result is a BLOCKED message on standard error and exit status 2 because the command contains git push.

This example checks the hook's response to command text without performing a Git push. It is a proposed check, not a recorded result; neither it nor a real Claude Code interaction was executed.

Assessment & evidence

Limitations

The guide describes all git push variants as blocked, but the implementation does not establish that coverage. For example, git -C repo push does not contain the git push pattern. Reordered flags such as git clean -df also escape the listed clean patterns. These are deductions from the source, not executed results.

Matching is unanchored and examines all submitted text. A harmless echo command containing git push can match, and the checkout or restore dot patterns also match paths beginning with a dot. Commands invoked inside another script are not inspected unless matching text appears in the submitted command.

The script does not explicitly handle invalid JSON, a missing command field or jq failure. An extraction failure can reach the final success exit. The Bash matcher also provides no demonstrated coverage of other tools or direct terminal use.

Fit and tradeoffs

The resource fits a need for an inspectable precaution against common accidental Git commands. Its short script makes the rules visible and editable, while project scope allows different repositories to use different restrictions.

It is a poor fit as the sole control for a requirement that every prohibited Git operation must be prevented. That conclusion follows from the text matching, lack of shell parsing and absence of explicit input failure handling.

Alternatives

The documented choices are project installation, global installation and editing the blocked patterns. Project scope limits where the settings apply; global scope is intended to apply the same policy across projects.

No separate alternative resource or comparative results are supplied. Relative coverage, compatibility and maintenance effort therefore remain unknown.

Evidence

The source material contains the complete selected skill: SKILL.md, agents/openai.yaml and scripts/block-dangerous-git.sh, plus the repository LICENSE. The YAML provides a display name and short description; the behavior resides in the Bash script.

Original instructions: [https://raw.githubusercontent.com/mattpocock/skills/5863806dd4e15c63174bee4e7515a4256792ecfa/skills/misc/git-guardrails-claude-code/SKILL.md]. Hook implementation: [https://raw.githubusercontent.com/mattpocock/skills/5863806dd4e15c63174bee4e7515a4256792ecfa/skills/misc/git-guardrails-claude-code/scripts/block-dangerous-git.sh].

Interface metadata: [https://raw.githubusercontent.com/mattpocock/skills/5863806dd4e15c63174bee4e7515a4256792ecfa/skills/misc/git-guardrails-claude-code/agents/openai.yaml]. License: [https://raw.githubusercontent.com/mattpocock/skills/5863806dd4e15c63174bee4e7515a4256792ecfa/LICENSE]. No runtime results or compatibility measurements accompany these files.

Access & freshness

Costs

No price, subscription requirement or support fee is stated for this skill. Claude Code access costs and any environment costs are unknown from the supplied evidence.

The bundled hook contains no model API calls or network requests. Its execution time and any effect on assistant usage costs have not been measured.

Rights

The supplied repository license is MIT, with copyright attributed to Matt Pocock in 2026. It permits use, copying, modification, distribution, sublicensing and sale, provided the copyright and permission notices remain in copies or substantial portions.

The license supplies the software without warranty and disclaims liability. Redistribution of the skill and its companion files must retain the required notices.

Freshness

The supplied snapshot was captured on 13 November 2026 at 18:05:30.250 UTC and identifies revision 5863806dd4e15c63174bee4e7515a4256792ecfa. These findings apply to that revision.

The files do not establish a release version, last modification date or supported Claude Code versions. Subsequent repository changes and current hook compatibility are unknown.

Adoption steps

Before adopting the skill, choose project or global scope, inspect the blocked patterns and decide whether preventing ordinary pushes suits the work. Preserve existing Claude Code settings when adding the hook.

Verify dependencies and hook behavior in a disposable environment. Useful checks include the documented push input, a harmless command, alternate Git syntax, harmless text containing a blocked phrase and malformed input. Then confirm that the intended Claude Code version invokes the hook and handles its exit status as expected.

Treat the default script as a precaution against common mistakes. A requirement for comprehensive enforcement needs additional controls and evidence beyond the supplied implementation.

Evidence for this report

LICENSEnotice · checked 2026-11-13