git-guardrails-claude-code

Block destructive git commands via a PreToolUse bash hook.

Updated Apr 13, 2026
One-click install
npx skills add https://github.com/henrycashe26/my_skills --skill git-guardrails-claude-code-henrycashe26
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-guardrails-claude-code
Source: https://github.com/henrycashe26/my_skills/tree/main/misc/git-guardrails-claude-code
Command: npx skills add https://github.com/henrycashe26/my_skills --skill git-guardrails-claude-code-henrycashe26

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill prevents accidental execution of destructive git operations like force pushes or hard resets, protecting your repository from irreversible data loss during AI-assisted coding sessions.

Core Features & Use Cases

  • Pre-emptive Blocking: Intercepts dangerous commands before they reach the shell.
  • Flexible Scope: Supports both project-specific and global installation configurations.
  • Use Case: Use this to ensure that an AI agent cannot accidentally run git reset --hard or git push --force while working on a critical production branch.

Quick Start

Ask the assistant to install the git guardrails hook for the current project to block dangerous git operations.

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 prevent Claude Code from running destructive git commands like force push?

To prevent destructive git commands in Claude Code, you can use a PreToolUse bash hook that intercepts and validates command strings against a blacklist of high-risk operations before they reach the shell.

How does a bash hook intercept dangerous git operations in an AI coding environment?

A bash hook intercepts dangerous git operations by validating command strings against a predefined blacklist before execution. It parses JSON command data using jq to check for high-risk actions like hard resets or force pushes.

Do I need jq installed to block git force pushes in my repository?

Yes, you need jq installed to block git force pushes using this approach. The validation logic relies on jq for parsing JSON command data within the standard bash shell environment to execute the intercepting hook.

Can I configure git safety guardrails globally or only for a specific project?

You can configure git safety guardrails for both global and project-specific installations. This flexible scope allows you to protect individual repositories or apply the destructive command blocking across your entire local environment.

What high-risk git operations should be blocked during AI-assisted coding sessions?

High-risk git operations that should be blocked during AI-assisted coding include force pushes and hard resets. Blocking these destructive operations protects your repository from irreversible data loss caused by accidental execution.