git-guardrails-claude-code

Block destructive git commands in Claude Code via PreToolUse hooks.

4|2|Updated Jun 20, 2026
One-click install
npx skills add https://github.com/saitarrun/devforge-ai --skill git-guardrails-claude-code-saitarrun
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-guardrails-claude-code
Source: https://github.com/saitarrun/devforge-ai/tree/main/skills/git-safety
Command: npx skills add https://github.com/saitarrun/devforge-ai --skill git-guardrails-claude-code-saitarrun

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

Accidental execution of destructive git commands like force push, hard reset, or branch deletion in Claude Code can cause irreversible data loss, broken repositories, and lost work, with no easy way to undo the damage.

Core Features & Use Cases

  • Pre-execution command blocking: Sets up a PreToolUse hook that intercepts dangerous git commands before Claude Code runs them, stopping accidental execution before any damage occurs.
  • Configurable blocked command list: Blocks the most common high-risk git operations by default, including all variants of git push, git reset --hard, git clean, git branch -D, and full-file checkout/restore commands.
  • Flexible scope installation: Supports installing the guardrails for a single project or globally across all Claude Code environments, with automatic merging into existing settings files to avoid overwriting other configurations.
  • Use Case: A developer using Claude Code to make quick changes can avoid accidentally force pushing unfinished work to the main branch or wiping their local changes with a stray reset --hard command.

Quick Start

Use the git-guardrails-claude-code skill to install configurable hooks that block destructive git commands in your Claude Code environment.

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 prevent Claude Code from running destructive git commands like force push?

You can prevent destructive git commands by installing configurable PreToolUse hooks that intercept bash commands like git push or git reset before Claude Code executes them, stopping irreversible data loss.

What high-risk git operations should be blocked during AI-assisted development?

High-risk git operations to block include force push, hard reset, branch deletion, and full file checkout or restore commands, which can cause broken repositories and lost work if executed accidentally.

How do I set up git safety hooks for a single project versus globally?

You can install git safety hooks for a single project or globally across all Claude Code environments, with automatic merging into existing settings files to avoid overwriting your current configurations.

Can I configure which git commands are blocked by the guardrails?

Yes, the guardrails use a configurable blocked command list that stops the most common high-risk operations by default, allowing you to tailor safety requirements for your specific AI-assisted development workflow.

Does installing git guardrails overwrite existing Claude Code settings?

No, installing these git guardrails automatically merges into your existing settings files, preventing the overwrite of other configurations while applying the safety hooks to your environment.

Why do I need pre-execution blocking for git commands in Claude Code?

Pre-execution blocking is needed because accidental execution of commands like git clean or reset --hard in Claude Code causes irreversible data loss, and intercepting them before runtime prevents the damage entirely.