git-guardrails-claude-code

Configure a PreToolUse hook to block dangerous git commands in Claude Code.

Updated Apr 4, 2026
One-click install
npx skills add https://github.com/ClyptAI/Clypt-Frontend --skill git-guardrails-claude-code-clyptai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-guardrails-claude-code
Source: https://github.com/ClyptAI/Clypt-Frontend/tree/main/.agents/skills/mattpocock-skills/git-guardrails-claude-code
Command: npx skills add https://github.com/ClyptAI/Clypt-Frontend --skill git-guardrails-claude-code-clyptai

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Set up Claude Code hooks to block dangerous git commands before they execute. Use when a user wants to prevent destructive git operations, add git safety hooks, or block git push or reset in Claude Code.

Core Features & Use Cases

  • Prevent dangerous commands such as git push (including --force), git reset --hard, git clean -f and git clean -fd, git branch -D, and git checkout . or git restore .
  • Provides guidance to configure a PreToolUse hook that intercepts and blocks these commands before Claude runs them.
  • Use case: In team projects or demonstrations, apply the guardrails at the project level or globally to reduce risk of destructive changes.

Quick Start

Install the guardrails by choosing the scope, copy the hook script to the target location, add it to Claude's settings, and verify by attempting a dangerous git command to ensure it is blocked.

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 force push and reset in Claude Code?

You can block dangerous git commands in Claude Code by configuring a PreToolUse hook with an accompanying script. This intercepts and blocks destructive operations like git push --force, git reset --hard, and git clean -f before execution.

What specific git operations does this safety hook prevent from running?

The safety hook prevents destructive git operations including git push --force, git reset --hard, git clean -f and git clean -fd, git branch -D, and git checkout . or git restore . from executing in Claude Code.

Can I apply git guardrails globally across all my team projects and environments?

Yes, you can apply git guardrails globally or at the project level. Configuring the PreToolUse hook globally ensures destructive git operations are blocked across all team projects and environments.

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

Yes, jq is required as a dependency to set up these Claude Code hooks. The accompanying script uses jq to parse and enforce the blocked git commands policy before execution.

How does a PreToolUse hook intercept git commands before Claude executes them?

A PreToolUse hook intercepts git commands by running a script before Claude Code executes any tool. The script checks the command against a blocked list and stops execution if a dangerous git operation is detected.

What is the best way to verify that dangerous git commands are actually blocked?

The best way to verify dangerous git commands are blocked is to attempt a blocked operation like git reset --hard after setup. If the PreToolUse hook is configured correctly, Claude Code will prevent the command from executing.