git-guardrails-claude-code

Block destructive git commands in Claude Code via a PreToolUse hook.

88|9|Updated Jul 16, 2020
One-click install
npx skills add https://github.com/docs-plus/docs.plus --skill git-guardrails-claude-code-docs-plus
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-guardrails-claude-code
Source: https://github.com/docs-plus/docs.plus/tree/main/.agents/skills/git-guardrails-claude-code
Command: npx skills add https://github.com/docs-plus/docs.plus --skill git-guardrails-claude-code-docs-plus

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Accidental execution of destructive git commands in Claude Code can cause irreversible data loss, disrupt team workflows, and waste hours of development work. This skill eliminates that risk by adding pre-execution guardrails that intercept dangerous git operations before Claude runs them.

Core Features & Use Cases

  • Pre-Execution Command Blocking: Intercepts and blocks high-risk git commands including all push variants, git reset --hard, git clean, git branch -D, and destructive checkout/restore operations before Claude executes them.
  • Flexible Installation Scope: Supports both project-specific setup stored in the project's .claude directory and global setup applied to all Claude Code projects on your system.
  • Customizable Block List: Lets you add or remove command patterns to match your team's specific workflow requirements.
  • Use Case: Development teams using Claude Code for git operations can use this skill to prevent accidental force pushes to production branches or irreversible resets that could wipe weeks of collaborative work.

Quick Start

Ask the AI to install git guardrails for your current Claude Code project to block dangerous git commands like force push and hard reset before they run.

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 or hard reset?

To prevent destructive git commands in Claude Code, you can use a PreToolUse hook that intercepts Bash tool inputs and blocks execution of dangerous patterns like force push and hard reset before they run.

Can I block git push and git reset --hard globally across all Claude Code projects?

Yes, you can apply git command blocking globally to all Claude Code projects on your system, or you can install it locally within a specific project's .claude directory for isolated development workflows.

How do I customize the list of dangerous git commands blocked in Claude Code?

You can customize the blocked command list by adding or removing specific git command patterns to match your team's specific workflow requirements and safety policies.

Do I need jq installed to set up git hooks for blocking dangerous git commands?

Yes, jq is required as a dependency to run the git guardrails hook, which intercepts predefined dangerous git command patterns and blocks execution with a clear error message.

What specific git operations does a PreToolUse hook intercept in Claude Code?

A PreToolUse hook intercepts high-risk git operations including all push variants, git reset --hard, git clean, git branch -D, and destructive checkout or restore operations before execution.