git-guardrails-claude-code

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill blocks dangerous git operations from executing during Claude Code sessions, reducing the risk of irreversible changes and credential exposure.

Core Features & Use Cases

  • PreToolUse Bash hook that blocks specified dangerous commands before Claude runs any tool.
  • Automatic enforcement of a safe command policy for common Git operations like push and reset --hard.
  • Easy setup for both project-scoped and global use, with a straightforward test procedure.

Quick Start

Copy the script to your project’s .claude/hooks directory or to your global ~/.claude/hooks directory, then configure a PreToolUse Bash hook to invoke it.

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 during Claude Code sessions?

Blocking dangerous git commands requires a PreToolUse Bash hook that intercepts actions like git push or reset --hard before execution. This Skill supplies the script and configuration workflow to enforce a safe command policy automatically.

Can I use git guardrails to prevent git push and reset --hard from running?

Yes, git guardrails can prevent git push and reset --hard from running by applying a PreToolUse Bash hook. The hook enforces an automatic safe command policy that denies blocked dangerous git operations before Claude runs any tool.

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

Yes, you need jq installed to use this Skill because jq is a required dependency for the hook script. You must also copy the script to your project's .claude/hooks directory or global ~/.claude/hooks directory and configure the PreToolUse Bash hook.

What is a PreToolUse Bash hook and how does it intercept git actions?

A PreToolUse Bash hook is a configuration mechanism that runs before Claude executes any tool, allowing scripts to intercept and deny specified commands. It enforces a safe command policy by blocking dangerous git operations like push and reset --hard before they run.

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

You can configure git blocking hooks either globally or per project in Claude Code. Copy the script to your project's .claude/hooks directory for project-scoped use, or to your global ~/.claude/hooks directory for system-wide enforcement across all sessions.