git-guardrails-claude-code

Blocks dangerous git commands in Claude Code using a PreToolUse hook script.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Claude Code can execute destructive git operations like git push --force or git reset --hard that permanently destroy work. This Skill installs a safety hook that intercepts and blocks these commands before they run. ## Core Features & Use Cases - Command Blocking: Intercepts git push, git reset --hard, git clean -f, git branch -D, git checkout ., and git restore . before execution. - Flexible Scope: Install the guardrail for a single project (.claude/settings.json) or globally across all projects (~/.claude/settings.json). - Customizable Patterns: Edit the bundled bash script to add or remove blocked command patterns. - Use Case: A team lead wants Claude Code to assist with development but never push to remote or discard local changes, so they install the hook project-wide to enforce that boundary. ## Quick Start Ask Claude to set up git guardrails that block dangerous git commands like push and reset --hard for this project.

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

Install a PreToolUse hook that matches the Bash tool and runs a script checking each command against dangerous patterns like git push. When matched, the script exits with code 2 and Claude receives a blocked message instead of executing.

How to set up a PreToolUse hook in Claude Code?▼

Add a hooks.PreToolUse entry to .claude/settings.json with matcher set to Bash and a command pointing to your hook script. The script receives JSON on stdin containing tool_input.command and can approve or block execution.

Can I apply git guardrails to all projects at once?▼

Yes, install the hook script to ~/.claude/hooks/ and register it in ~/.claude/settings.json instead of the project-level settings file. This blocks dangerous git commands across every project where Claude Code runs.

What git commands does the guardrail script block?▼

The script blocks git push (including --force), git reset --hard, git clean -f and -fd, git branch -D, git checkout ., and git restore .. You can edit the DANGEROUS_PATTERNS array in the script to customize the list.

Why is my Claude Code hook not blocking commands?▼

Common causes include the script lacking execute permission (run chmod +x), an incorrect path in settings.json, or missing jq dependency used to parse the JSON input. Test by piping a sample JSON command directly into the script and checking for exit code 2.