git-guardrails-claude-code

Intercept and block destructive git commands via a PreToolUse hook.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill prevents accidental execution of high-risk git commands that could lead to data loss or unwanted repository states, providing a safety layer for AI-assisted development.

Core Features & Use Cases

  • Command Interception: Automatically blocks dangerous operations like force pushes, hard resets, and branch deletions before they reach the git binary.
  • Flexible Scoping: Supports both project-specific and global safety configurations to suit different development environments.
  • Use Case: Use this to ensure that an AI agent cannot accidentally wipe local changes or force-push to a protected production branch during an automated refactoring session.

Quick Start

Run the setup script by following the prompts to install the git guardrail hook in your current project directory.

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 accidental destructive git operations during automated refactoring?

To prevent accidental destructive git operations, you can intercept dangerous commands before execution. This Skill operates as a PreToolUse hook to validate shell commands against a blacklist, blocking high-risk actions like force pushes and hard resets to ensure repository safety.

Can I use Claude Code to block force pushes and hard resets in my repository?

Yes, you can use Claude Code to block force pushes and hard resets. This Skill validates shell commands against a blacklist of destructive git patterns, automatically intercepting and stopping dangerous operations before they reach the git binary.

Do I need jq installed to set up git guardrails in my project?

Yes, you need jq installed to set up git guardrails. This Skill requires the jq utility to parse tool input and validate command strings before execution, ensuring dangerous shell commands are properly intercepted by the PreToolUse hook.

How do I configure git safety rules for a specific project versus globally?

You can configure git safety rules for a specific project or globally. This Skill supports flexible scoping, allowing you to define project-specific or global safety configurations to suit different development environments and prevent unwanted repository states.

What's the best way to stop an AI agent from wiping local git changes?

The best way to stop an AI agent from wiping local git changes is implementing a PreToolUse hook. This Skill intercepts dangerous shell commands like branch deletions and hard resets, providing a safety layer that prevents accidental data loss during automated sessions.