Skip to content
Back to skills

Git Guardrails

ASecurity

Sets up a Claude Code hook that blocks destructive git commands (push, reset --hard, clean -f) before they run. Use when the user wants git safety hooks.

  • 7 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 18, 2026
ai-agentsbashrailsgit

Works with

  • claude code

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned November 18, 2026

npx -y skills add AgentAvow/AgentAvow --skill git-guardrails --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Git Guardrails?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Git Guardrails
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/agentavow-git-guardrails/badge)](https://www.skillsdirectory.com/skills/agentavow-git-guardrails)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: git-guardrails
description: Sets up a Claude Code hook that blocks destructive git commands (push, reset --hard, clean -f) before they run. Use when the user wants git safety hooks.
---

# Git guardrails

Sets up a PreToolUse hook that stops destructive git commands before the agent runs them.

## Steps

### 1. Pick the scope

Ask the user whether to install it for this project (`.claude/settings.json`) or for every
project (`~/.claude/settings.json`).

### 2. Copy the script

Copy [scripts/block-git.sh](scripts/block-git.sh) to `.claude/hooks/block-git.sh`
(project) or `~/.claude/hooks/block-git.sh` (global) and make it executable.

### 3. Add the hook

Add this to the settings file you picked:

```json
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "~/.claude/hooks/block-git.sh"
          }
        ]
      }
    ]
  }
}
```

If the file already has a `hooks.PreToolUse` array, merge the entry into it.

### 4. Check it

```bash
echo '{"tool_input":{"command":"git push origin main"}}' | ~/.claude/hooks/block-git.sh
```

It should exit 2 and print BLOCKED.

Files in this skill

  • SKILL.md1.2 KB
  • scripts/block-git.sh371 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.