git-guardrails-claude-code

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

40|9|Updated Jan 4, 2026
One-click install
npx skills add https://github.com/akillness/jeo-skills --skill git-guardrails-claude-code-akillness
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-guardrails-claude-code
Source: https://github.com/akillness/jeo-skills/tree/main/.agent-skills/git-guardrails-claude-code
Command: npx skills add https://github.com/akillness/jeo-skills --skill git-guardrails-claude-code-akillness

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Claude Code can perform git operations that may inadvertently damage repositories; this skill provides a safety net by implementing a PreToolUse hook to block destructive operations before they run.

Core Features & Use Cases

  • PreToolUse hook blocks destructive git commands in Claude Code, preventing accidental pushes, resets, and clean operations.
  • Supports project-level and global scope installation (.claude/hooks/ or ~/.claude/hooks/), with guidance to integrate into existing workflows.
  • Use Case: Protect critical repos in environments where Claude Code runs automated tasks and could trigger risky git operations.

Quick Start

Install the local or global hook and register it in Claude Code settings to block destructive git commands.

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?

To block destructive git commands in Claude Code, you can enforce a PreToolUse hook that halts risky operations like git push --force, reset --hard, clean -f, and branch -D before they run.

What is a PreToolUse hook for git safety?

A PreToolUse hook for git safety is a mechanism that intercepts and blocks destructive git operations before execution, preventing accidental repository damage during automated code execution.

Can I install git guardrails globally or per-project?

Yes, you can install git guardrails globally or per-project by placing the configurable hook script under ~/.claude/hooks or .claude/hooks respectively, then mapping it in your settings.

Which risky git operations should I prevent automated agents from running?

You should prevent automated agents from running destructive git operations such as git push --force, reset --hard, clean -f, and branch -D to protect critical repositories from accidental damage.

How do I register a hook script in Claude Code settings?

To register a hook script in Claude Code settings, you map the configured hook script to the PreToolUse event, ensuring the safety mechanism intercepts risky git commands before they execute.