git-guardrails-claude-code

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

1|Updated Jun 2, 2026
One-click install
npx skills add https://github.com/SevWren/Daily-Motivation-Brain-Helper --skill git-guardrails-claude-code-sevwren
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: git-guardrails-claude-code
Source: https://github.com/SevWren/Daily-Motivation-Brain-Helper/tree/main/CLAUDE/skills/misc/git-guardrails-claude-code
Command: npx skills add https://github.com/SevWren/Daily-Motivation-Brain-Helper --skill git-guardrails-claude-code-sevwren

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Claude Code can execute destructive git commands 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 developer letting Claude Code refactor a repository wants to guarantee the AI can never force-push to main or wipe uncommitted changes, so they install the hook globally. ## Quick Start Set up git guardrails in Claude Code to 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 commands against dangerous patterns like git push. When matched, the script exits with code 2 and Claude receives a blocked message.

How to set up Claude Code hooks for git safety?▼

Copy the block-dangerous-git.sh script to .claude/hooks/ or ~/.claude/hooks/, make it executable, then register it under hooks.PreToolUse in the corresponding settings.json with a Bash matcher.

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

Yes, install the hook script in ~/.claude/hooks/ and add the hook configuration to ~/.claude/settings.json instead of the project-level file. This blocks dangerous git commands across every project.

Which git commands does the guardrail block?▼

It 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 the git blocking hook not working in Claude Code?▼

Verify the script is executable with chmod +x, that jq is installed since the script parses JSON input with it, and that the hook path in settings.json matches the actual script location. Test by piping a sample JSON command into the script.