git-guardrails-claude-code

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

195|16|Updated Feb 18, 2025
One-click install
npx skills add https://github.com/InditexTech/weavejs --skill git-guardrails-claude-code-inditextech
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-guardrails-claude-code
Source: https://github.com/InditexTech/weavejs/tree/main/code/.agents/skills/git-guardrails-claude-code
Command: npx skills add https://github.com/InditexTech/weavejs --skill git-guardrails-claude-code-inditextech

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This skill blocks dangerous git commands from executing in Claude Code to prevent destructive operations and accidental repository damage.

Core Features & Use Cases

  • PreToolUse hook integration to intercept and block dangerous commands such as git push, git reset --hard, git clean, and git branch -D.
  • Clear scope configuration for project-level or global usage, with a bundled script and step-by-step guidance for setup.
  • Safety-first design with predictable behavior and easy customization of blocked patterns.

Quick Start

Copy the bundled script to the appropriate Claude Code hooks location for project scope or global scope, then update Claude settings to enable the PreToolUse hook.

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

You can block dangerous git commands in Claude Code by installing a PreToolUse hook script that intercepts and prevents destructive operations like git push or git reset --hard before they execute. This skill provides the bundled script and setup guidance to enable this interception.

What destructive git operations should be blocked during AI assisted coding?

Destructive git operations that should be blocked include git push, git reset --hard, git clean, and git branch -D. The provided hook script evaluates a guarded command mask list at runtime to intercept these specific dangerous patterns.

Can I configure git guardrails globally for all my projects?

Yes, you can configure git guardrails globally for all projects or limit the scope to a single repository. The skill provides step-by-step guidance to copy the bundled hook script to the appropriate Claude Code hooks location for your chosen scope.

Do I need jq to run the git command blocking hook?

Yes, you need jq installed to run the git command blocking hook. The PreToolUse hook script relies on jq as a dependency to evaluate the guarded command mask list and process runtime interception logic.

How do I customize which git commands are blocked by the PreToolUse hook?

You can customize which git commands are blocked by modifying the guarded command mask list within the bundled hook script. This safety-first design allows predictable behavior and easy adjustment of blocked patterns to suit your specific repository requirements.