git-guardrails-claude-code

Block dangerous git commands on Claude Code repositories via a PreToolUse hook.

356|59|Updated Apr 29, 2026
One-click install
npx skills add https://github.com/amazingloft999-droid/mattpocock-skills --skill git-guardrails-claude-code-amazingloft999-droid
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-guardrails-claude-code
Source: https://github.com/amazingloft999-droid/mattpocock-skills/tree/main/skills/misc/git-guardrails-claude-code
Command: npx skills add https://github.com/amazingloft999-droid/mattpocock-skills --skill git-guardrails-claude-code-amazingloft999-droid

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires jq, and includes scripts (resource) components.

What problem does it solve?

Claude Code can perform dangerous git operations without guardrails, risking destructive changes. This Skill sets up a PreToolUse hook to intercept and block dangerous git commands before Claude executes them.

Core Features & Use Cases

  • PreToolUse hook that blocks dangerous git commands (git push, git reset --hard, git clean, git branch -D, etc.) before Claude runs them.
  • Works for project-scoped or global scope; guides user through copying the hook and updating settings.
  • Real-world use: prevent accidental pushes or resets during code generation sessions.

Quick Start

Install the guardrails and apply the hook to your project or global settings to block dangerous git commands.

Frequently Asked Questions about git-guardrails-claude-code

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I block dangerous git commands like force push in Claude Code?

To block dangerous git commands in Claude Code, you can install a PreToolUse hook that intercepts and prevents operations like git push --force, git reset --hard, and git clean before execution. This guardrail protects repositories from destructive actions during code generation.

Can I set up git hooks globally or per-project for Claude Code?

Yes, you can configure git hooks for Claude Code at either a per-project or global scope. The setup involves copying the hook script and updating your Claude settings to integrate the guardrails with your chosen configuration scope.

Do I need jq to install git guardrails for Claude Code?

Yes, jq is required to install and run these git guardrails. The hook script depends on jq to parse tool use requests and accurately block dangerous git commands within your Claude Code environment.

What specific git operations does a PreToolUse hook intercept?

A PreToolUse hook intercepts destructive git operations such as git push, git reset --hard, git clean, and git branch -D. It blocks these dangerous commands before Claude executes them to prevent accidental repository damage.

How do git prehooks prevent accidental resets during code generation?

Git prehooks prevent accidental resets during code generation by acting as a guardrail that automatically blocks destructive commands. The hook evaluates requested git operations and stops execution of dangerous actions before they can impact the repository state.