git-guardrails

Install Claude Code PreToolUse guards that block destructive git commands.

181|29|Updated Apr 21, 2026
One-click install
npx skills add https://github.com/iusztinpaul/squid --skill git-guardrails-iusztinpaul
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-guardrails
Source: https://github.com/iusztinpaul/squid/tree/main/skills/git-guardrails
Command: npx skills add https://github.com/iusztinpaul/squid --skill git-guardrails-iusztinpaul

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Install Claude Code PreToolUse hooks that block destructive git commands before they execute — force-push to protected branches, git reset --hard of unstaged work, git push --no-verify, and rm -rf paths that escape the worktree. Smart-merges into the project's .claude/settings.json and writes one guardian script. Trigger when the user says /git-guardrails, asks to harden Claude Code against destructive git commands, or is about to run /night unattended for the first time.

Core Features & Use Cases

  • Guards against force-pushes to protected branches (configurable via the protected list, default main, master, prod).
  • Prevents destructive commands such as git reset --hard when there is unstaged or uncommitted work.
  • Blocks git push --no-verify and commit bypass to preserve hooks and policies.
  • Writes a guardian script at .claude/scripts/git-guardrails.sh and merges a settings entry into .claude/settings.json to enforce safety.
  • Integrates with Claude Code workflows to protect unattended runs and initial project setups.

Quick Start

Run the /git-guardrails activation to install the guardian script and merge the hook into your project settings.

Frequently Asked Questions about git-guardrails

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I block destructive git commands like force-push in Claude Code?

To block destructive git commands in Claude Code, install PreToolUse hooks that exit non-zero to prevent risky actions. This guards against force-pushes to protected branches, hard resets of unstaged work, and path removals escaping the worktree.

What is a PreToolUse hook for preventing git reset --hard and push --no-verify?

A PreToolUse hook is a guardian script integrated into project settings that intercepts and blocks risky git commands before execution. It specifically prevents git reset --hard on uncommitted work and git push --no-verify to preserve repository policies.

Can I configure protected branches to prevent force-push in unattended Claude Code runs?

Yes, you can configure protected branches via a protected list with defaults like main, master, and prod. This configuration blocks force-pushes during unattended runs and collaborative repository workflows.

How do I install git guardrails to harden Claude Code against destructive actions?

Run the activation command to smart-merge a settings entry into .claude/settings.json and write a guardian script at .claude/scripts/git-guardrails.sh. This enforces safety by blocking force-pushes, hard resets, and worktree escapes.

Does the git guardrails script work with existing settings.json configurations?

Yes, the guardrails script smart-merges its required configuration into the project's existing .claude/settings.json. This integration ensures the PreToolUse hook enforces safety without overwriting your current Claude Code workflow settings.

When should I use git guardrails to prevent destructive git commands?

Use git guardrails when preparing for unattended runs or hardening initial project setups in collaborative repositories. It prevents destructive commands like force-pushes, hard resets, and rm -rf paths escaping the worktree before they execute.