git-guardrails-claude-code

Block dangerous git commands in Claude Code via PreToolUse hooks.

2|Updated Apr 25, 2026
One-click install
npx skills add https://github.com/caezium/skills --skill git-guardrails-claude-code-caezium
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-guardrails-claude-code
Source: https://github.com/caezium/skills/tree/main/git-guardrails-claude-code
Command: npx skills add https://github.com/caezium/skills --skill git-guardrails-claude-code-caezium

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Prevent destructive git operations by enforcing a guardrail in Claude Code workflows, blocking risky commands before execution to protect repositories.

Core Features & Use Cases

  • PreToolUse hook setup to intercept and block dangerous commands such as push, reset --hard, clean, branch -D, and checkout/restore.
  • Guided installation for project-scoped (.claude/settings.json) or global settings (~/.claude/settings.json).
  • Customizable patterns and straightforward verification to ensure safe operation across different repos and teams.

Quick Start

Copy the bundled script to the target location and enable the PreToolUse hook for the desired scope.

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

To block dangerous git commands in Claude Code, configure a PreToolUse hook to intercept risky operations like push, reset --hard, clean, branch -D, and checkout before execution. This guardrail protects repositories from unintended destructive actions.

What git operations should be blocked to protect repositories?

Destructive git operations that should be blocked include git push, reset --hard, clean, branch -D, and checkout or restore. Intercepting these commands prevents irreversible data loss and maintains repository integrity during automated workflows.

How do I set up a PreToolUse hook to intercept git commands?

Set up a PreToolUse hook by copying the bundled block script to your target location and enabling it within project-scoped or global Claude Code settings. This intercepts and evaluates git commands before they execute.

Can I apply git safety guardrails globally across all my projects?

Yes, you can apply git safety guardrails globally by configuring the PreToolUse hook in the global settings file, covering all Claude Code environments. Project-scoped settings are also available for individual repository protection.

Do I need jq to run the git guardrail block script?

Yes, jq is required as a dependency to run the git guardrail block script. It processes the JSON input intercepted by the PreToolUse hook to evaluate and block destructive git commands effectively.