git-guardrails-claude-code

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

16|Updated Jun 6, 2026
One-click install
npx skills add https://github.com/Insik-Han/han-monorepo-template --skill git-guardrails-claude-code-insik-han
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-guardrails-claude-code
Source: https://github.com/Insik-Han/han-monorepo-template/tree/main/.agents/skills/git-guardrails-claude-code
Command: npx skills add https://github.com/Insik-Han/han-monorepo-template --skill git-guardrails-claude-code-insik-han

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Claude Code environments risk destructive git operations; this Skill installs guardrails to intercept and block dangerous commands before they execute.

Core Features & Use Cases

  • PreToolUse hook that blocks commands like git push (including --force), git reset --hard, git clean -fd, git branch -D, and git checkout/restore.
  • Project-scoped or global scope installation through Claude Code settings, ensuring safety across projects or system-wide.
  • Simple script deployment: copy and enable the block-dangerous-git.sh hook to the target location and make it executable.

Quick Start

Install the provided block-dangerous-git.sh hook into the target environment and verify it blocks dangerous 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 prevent destructive git commands like git push --force from running in Claude Code?

You can prevent destructive git commands by installing a PreToolUse hook that intercepts tool inputs and blocks patterns like git push --force before execution. This guardrail script uses jq to read and evaluate the input payload.

Can I block git reset --hard and git branch -D globally across all my projects?

Yes, you can deploy the guardrail script globally to intercept git reset --hard and git branch -D commands across all projects. The hook integrates with Claude Code global settings to enforce safety system-wide.

What git commands does the PreToolUse hook intercept and block?

The PreToolUse hook intercepts and blocks dangerous git commands including git push, git reset --hard, git clean, git branch -D, and git checkout or restore operations before they execute.

Do I need jq installed to use git guardrails in Claude Code?

Yes, jq is required to use these git guardrails. The blocking script relies on jq to parse the tool_input JSON payload and match dangerous git command patterns during the PreToolUse hook execution.

How do I set up a bash script to block dangerous git operations in my project?

To set up the block-dangerous-git.sh hook, copy the script into your target project or global environment, make it executable, and enable it within Claude Code settings to intercept dangerous git operations.