git-guardrails-claude-code

Block dangerous git commands before execution in Claude Code.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill helps prevent destructive git operations like push, reset --hard, clean, branch -D, etc., by setting up Claude Code hooks that block these commands before they execute.

Core Features & Use Cases

  • Block Dangerous Commands: Prevents destructive git commands from executing.
  • Customizable: Allows users to add or remove patterns from the blocked list.
  • Scope Selection: Can be installed for a single project or all projects.
  • Use Case: Ideal for users who want to add git safety hooks or block git push/reset in Claude Code to prevent accidental destructive operations.

Quick Start

Set up Git Guardrails for your project by copying the script to the appropriate location and adding it to your settings file.

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 destructive git operations like push and reset --hard in Claude Code?

You can prevent destructive git operations in Claude Code by setting up hooks that block dangerous commands like push, reset --hard, clean, and branch -D before they execute. This script intercepts and stops those commands automatically.

What are Claude Code hooks and how do they block git commands?

Claude Code hooks are scripts configured in your settings file that intercept terminal commands. This hook specifically scans for dangerous git patterns and halts execution before any matching destructive command runs.

Can I customize which git commands are blocked by the safety hooks?

Yes, the git safety hooks are customizable. You can add or remove patterns from the blocked list to specify exactly which dangerous git commands you want to prevent from executing in your environment.

How do I install git guardrails for a single project versus all projects?

You install git guardrails by copying the script to the appropriate location and adding it to your settings file. The scope selection allows you to apply the hooks for a single project or across all projects.

Do I need Claude Code to set up git safety hooks?

Yes, this requires Claude Code to function. The script relies on Claude Code's hook mechanism to intercept and block destructive git commands before they are executed in the terminal.