git-guardrails-claude-code

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

Updated May 21, 2026
One-click install
npx skills add https://github.com/louderthanthunderx1/loki-skills --skill git-guardrails-claude-code-louderthanthunderx1
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-guardrails-claude-code
Source: https://github.com/louderthanthunderx1/loki-skills/tree/main/skills/misc/git-guardrails-claude-code
Command: npx skills add https://github.com/louderthanthunderx1/loki-skills --skill git-guardrails-claude-code-louderthanthunderx1

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Prevents destructive git operations by automatically blocking dangerous commands before Claude executes them.

Core Features & Use Cases

  • Intercepts commands via a PreToolUse hook to block dangerous git operations.
  • Supports project-scoped and global installation by providing project (.claude/settings.json) and global (~/.claude/settings.json) configuration.
  • Includes a bundled script scripts/block-dangerous-git.sh to copy into the target hooks path and a quick verification step.

Quick Start

Choose the scope (project or global), copy scripts/block-dangerous-git.sh to the corresponding Claude hooks path, and add the hook to your Claude 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 in Claude Code?

Block destructive git operations by installing a PreToolUse hook that intercepts commands before Claude executes them. Copy the bundled shell script into your hooks path and register it in settings.json to prevent pushes, resets, cleanups, and branch deletions.

What destructive git operations should I prevent in AI-assisted development?

Destructive git operations include force pushes, hard resets, branch deletions, and cleanups. Using a PreToolUse hook intercepts these commands before execution, protecting both local repositories and collaborative workflows from unintended data loss.

Can I configure git guardrails globally or per project?

Yes, you can configure git guardrails globally or per project. The Skill supports project-scoped configuration via .claude/settings.json and global configuration via ~/.claude/settings.json to apply hooks across your environment.

Do I need jq to use git guardrails with Claude Code?

Yes, jq is a required dependency for this git guardrail hook. The block-dangerous-git.sh script relies on jq to parse the JSON payload from the Claude Code PreToolUse hook and evaluate the intercepted git commands.

How does a PreToolUse hook stop git branch deletions?

A PreToolUse hook stops git branch deletions by evaluating the command payload before the tool executes. If the block-dangerous-git.sh script detects a dangerous git action, it blocks the operation and prevents Claude from running it.

What is the best way to prevent accidental git resets in collaborative workflows?

The best way to prevent accidental git resets in collaborative workflows is automating command interception. A PreToolUse hook script blocks destructive git operations automatically, removing reliance on manual checks during development.