git-guardrails-claude-code

Block dangerous Git commands via Claude Code PreToolUse hooks.

Updated Jun 15, 2026
One-click install
npx skills add https://github.com/giovi1998/SitoPreventivo --skill git-guardrails-claude-code-giovi1998
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-guardrails-claude-code
Source: https://github.com/giovi1998/SitoPreventivo/tree/main/.agents/skills/git-guardrails-claude-code
Command: npx skills add https://github.com/giovi1998/SitoPreventivo --skill git-guardrails-claude-code-giovi1998

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Prevents destructive Git actions from running inside Claude Code by intercepting risky commands before they execute, reducing the chance of accidental data loss or history rewrites.

Core Features & Use Cases

  • Dangerous command blocking: Stops git push, git reset --hard, git clean -f/-fd, git branch -D, git checkout ., and git restore ..
  • Claude Code hook setup: Installs as a PreToolUse Bash hook for either a single project or all projects.
  • Safety workflow: Useful when you want a guardrail for local development, team repositories, or agent-driven automation where a mistaken git command could be harmful.

Quick Start

Ask to install the guardrail for this project only or all projects, then copy the bundled script into the matching hooks folder and add the PreToolUse hook entry in your Claude Code settings.

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

You can block dangerous git commands in Claude Code by configuring a PreToolUse Bash hook and copying a block-dangerous-git.sh script into your settings. This intercepts risky operations like push, reset --hard, clean, and branch -D before they execute.

Can I install git safety hooks globally for all my Claude Code projects?

Yes, git safety hooks can be configured at either a project-level or global level in Claude Code. Choosing the global setup applies the command blocking guardrails across all your projects automatically.

What destructive git operations should I prevent AI agents from running?

Destructive git operations to prevent include git push, git reset --hard, git clean -f/-fd, git branch -D, git checkout ., and git restore .. Blocking these stops accidental data loss and history rewrites during automated workflows.

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

Yes, jq is required to set up these bash hooks for blocking git commands. The PreToolUse hook script relies on jq to parse the JSON input and evaluate whether a bash command should be blocked.

Why use PreToolUse hooks to intercept git clean and checkout operations?

PreToolUse hooks intercept git clean and checkout operations before execution, providing a safety guardrail for local development and agent-driven automation. This prevents accidental data loss by stopping the command before it runs.