git-guardrails-claude-code

Block destructive git commands before Claude Code executes them.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents Claude Code from running destructive git commands that could overwrite work, remove files, or rewrite repository history.

Core Features & Use Cases

  • Command Blocking: Stops risky git actions such as push, force push, hard reset, clean, and destructive branch deletion before they execute.
  • Flexible Scope: Supports installation for a single project or across all projects through Claude Code settings.
  • Safe Customization: Lets you adjust the blocked patterns and verify the hook after setup.
  • Use Case: Use it when you want a guardrail that protects active branches, local changes, and shared repositories from accidental damage.

Quick Start

Ask me to install the git guardrails for this project or for all projects, and I will copy the hook, update the Claude Code settings, and verify that dangerous git commands are blocked.

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

You can block destructive git commands by setting up a PreToolUse Bash hook combined with an executable shell script and a merged settings.json entry. This intercepts risky actions like push, hard reset, clean, and branch deletion before execution.

Can I apply git guardrails globally across all projects or just locally?

You can apply git guardrails globally across all projects or locally to a single project. The setup configures the Claude Code settings.json to enforce the PreToolUse Bash hook at your chosen scope.

How does a PreToolUse hook stop git force push and hard reset operations?

A PreToolUse hook stops git force push and hard reset operations by running an executable shell script before the Bash tool executes. If the command matches destructive patterns in settings.json, the hook blocks it to prevent overwriting work or rewriting history.

Is it possible to customize which git commands are blocked by the safety hook?

Yes, you can safely customize which git commands are blocked by the safety hook. The setup allows you to adjust the blocked patterns and verify the hook configuration after installation to ensure your guardrails match your project requirements.

What do I need to set up git safety guardrails for my repository?

To set up git safety guardrails, you need a PreToolUse Bash hook, an executable shell script, and a merged settings.json entry. The Skill copies the hook, updates your Claude Code settings, and verifies that dangerous commands are blocked.