Skip to content
Back to skills

Git Guardrails Claude Code

ASecurity

Use when adding git safety hooks to prevent destructive operations in Claude Code

  • 2 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 10, 2026
ai-agentsrailstestinggit

Works with

  • claude code

Security analysis

A100/100

Scanned September 10, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Git Guardrails Claude Code?

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

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

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-claude-code
description: Use when adding git safety hooks to prevent destructive operations in Claude Code
tags: [git, safety, hooks, Claude-Code, guardrails]
related_skills: [setup-pre-commit, git-hooks-workflow, git-config-essentials]
---

# Git Guardrails Claude Code

Set up Claude Code hooks that block dangerous git commands (push, reset --hard, clean, branch -D) before they execute.

## What gets blocked
- `git push` (all variants including --force)
- `git reset --hard`
- `git clean -f` / `git clean -fd`
- `git branch -D`
- `git checkout .` / `git restore .`

## Setup steps
1. Ask scope: project-only (.claude/settings.json) or all projects (~/.claude/settings.json)
2. Copy the hook script to the appropriate location
3. Make it executable (chmod +x)
4. Add PreToolUse hook to settings.json
5. Verify by triggering a blocked command

> **Note**: This skill is designed for Claude Code's hook system. For Hermes Agent, adapt to use git config aliases or pre-commit hooks instead.

## Common Pitfalls

- **Missing execute permission on the hook script**: The block-dangerous-git.sh script must be chmod +x or it silently won't run.
- **Installing globally when project-only is appropriate**: Global hooks affect all Claude Code sessions. Only install globally if the user explicitly wants that.
- **Not testing the guardrails after installation**: Verify by triggering one of the blocked commands and confirming it is intercepted.

## Verification Checklist

- [ ] Scope confirmed (project or global)
- [ ] Hook script copied to correct location
- [ ] chmod +x applied to hook script
- [ ] Hook added to settings.json (PreToolUse)
- [ ] Guardrails verified with a test command

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.

Comments

Loading comments…

Newsletter

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