git-guardrails-claude-code

Block dangerous git commands before Claude Code executes them.

13|3|Updated May 12, 2026
One-click install
npx skills add https://github.com/kevinnft/ai-agent-skills --skill git-guardrails-claude-code-kevinnft
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-guardrails-claude-code
Source: https://github.com/kevinnft/ai-agent-skills/tree/main/skills/mattpocock/misc/git-guardrails-claude-code
Command: npx skills add https://github.com/kevinnft/ai-agent-skills --skill git-guardrails-claude-code-kevinnft

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This skill sets up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute, preventing destructive operations.

Core Features & Use Cases

  • PreToolUse hook injected into Claude Code to intercept and block defined git commands.
  • Per-project or global scope configuration to apply safety guards across environments.
  • Clear messaging to the user when a command is blocked, with guidance for safe alternatives.

Quick Start

Install the block-dangerous-git hook for your project or global setup and configure Claude Code to use the hook.

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

You can block dangerous git commands in Claude Code by installing a PreToolUse hook that intercepts destructive operations like push --force, reset --hard, and clean before execution. The hook stops the command and provides messaging with safe alternatives.

What destructive git operations does the Claude Code PreToolUse hook prevent?

The PreToolUse hook prevents destructive git operations including push --force, reset --hard, clean, and branch -D from executing within Claude Code. It intercepts these defined commands to protect your repository from unintended data loss.

Can I configure git safety hooks globally or per-project in Claude Code?

Yes, you can configure git safety hooks globally or per-project in Claude Code. This flexible scoping allows you to apply consistent guards against destructive git commands across your entire environment or isolate them to specific repositories.

Do I need jq installed to set up git guardrails for Claude Code?

Yes, jq is required to set up git guardrails for Claude Code. The configurable hook script relies on jq to parse tool input data and evaluate whether the invoked git command matches the defined blocklist of destructive operations.

How does Claude Code intercept git commands before they execute?

Claude Code intercepts git commands before execution using a PreToolUse hook. This mechanism injects a script that evaluates the proposed command against a blocklist, halting destructive operations like reset --hard and clean while providing safe alternative guidance.

What is the best way to prevent accidental data loss from automated git commands?

The best way to prevent accidental data loss from automated git commands is implementing a PreToolUse hook that blocks destructive operations like push --force, reset --hard, and clean. This ensures automated tools cannot execute irreversible repository changes without explicit approval.