git-guardrails-claude-code

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This guardrails skill prevents destructive git operations in Claude Code by installing a PreToolUse hook that blocks risky commands before execution.

Core Features & Use Cases

  • Intercepts and blocks dangerous git commands such as push, reset --hard, clean, branch -D, and checkout/restore.
  • Supports project-scoped or global scope configuration to suit different environments.
  • Allows customization of the blocked command patterns and provides clear guidance to verify the guardrails are active.

Quick Start

Install the skill to automatically configure Claude Code to block dangerous git commands using a PreToolUse 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 or reset --hard in Claude Code?

You can block dangerous git commands in Claude Code by installing a PreToolUse hook that intercepts and prevents risky operations like push, reset --hard, clean, and branch -D before execution.

Can I apply git command guardrails globally across all my Claude Code projects?

Yes, git guardrails can be configured for global scope to protect all environments or scoped to individual projects, suiting different deployment needs and team workflows.

How do I customize which git commands are blocked during automated agent workflows?

The guardrails provide a curated block list that you can customize by modifying the blocked command patterns, allowing you to intercept specific risky git operations during agent runs.

Do I need jq to configure PreToolUse hooks for blocking git operations?

Yes, jq is required as a dependency to parse and process the hook configurations that intercept and block dangerous git commands before they execute in Claude Code.

What is the best way to prevent destructive git operations during automated agent runs?

Using a PreToolUse hook to intercept risky commands before execution is an effective approach, blocking operations like checkout, restore, and clean during automated workflows or agent runs.

How can I verify that my git command guardrails are active in Claude Code?

The guardrails include clear guidance and steps to verify that the PreToolUse hook is active, ensuring dangerous git commands are intercepted and blocked before execution.