git-guardrails-claude-code

Block destructive Git commands like push, reset --hard, and branch -D in Claude Code.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/mnadalc/dotfiles --skill git-guardrails-claude-code-mnadalc
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-guardrails-claude-code
Source: https://github.com/mnadalc/dotfiles/tree/main/.ai/project-specific-skills/git-guardrails-claude-code
Command: npx skills add https://github.com/mnadalc/dotfiles --skill git-guardrails-claude-code-mnadalc

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill prevents accidental data loss or unintended changes by blocking destructive Git commands before they are executed by Claude Code.

Core Features & Use Cases

  • Command Interception: Hooks into Git operations to prevent execution of dangerous commands.
  • Safety Assurance: Protects against accidental pushes, hard resets, or branch deletions.
  • Use Case: When working on a critical project, you can use this Skill to ensure that no destructive Git commands are run by the AI, safeguarding your codebase.

Quick Start

Install the git guardrails for this project by copying the hook script and adding it to your project's Claude settings.

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 in Claude Code?

To block dangerous git commands, you install a hook script into your project's Claude settings to intercept and prevent destructive operations like git push, git reset --hard, and git branch -D before execution.

What is pre-execution validation for git operations?

Pre-execution validation for git operations is a safety mechanism that intercepts commands before they run, specifically blocking destructive actions like hard resets and branch deletions to prevent accidental data loss and safeguard the codebase.

How do I set up git hooks to prevent accidental pushes and hard resets?

You set up git hooks to prevent accidental pushes by copying the provided guardrail hook script and adding it directly to your project's Claude settings, which enables command interception for version control safety.

Can I use Claude Code hooks to protect a critical project from branch deletions?

Yes, you can use Claude Code hooks to protect a critical project by applying guardrails that specifically block branch deletions, accidental pushes, and hard resets, safeguarding your codebase from unintended changes.

What are the limitations of using scripts for git guardrails?

The limitation of using scripts for git guardrails is that they specifically target command interception within Claude Code, meaning they prevent destructive operations like git push or hard resets locally but do not alter external repository states.