# Git Guardrails Claude Code

> Install Claude hooks blocking dangerous git commands before execution.

- Skill: `redpanda-data/git-guardrails-claude-code` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add redpanda-data/git-guardrails-claude-code`
- Raw SKILL.md: https://api.skillmd.com/api/skills/redpanda-data/git-guardrails-claude-code/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: redpanda-data (https://skillmd.com/u/redpanda-data)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/redpanda-data/git-guardrails-claude-code

---


# Git Guardrails

Install PreToolUse Bash hook blocking dangerous git before Claude runs it.

Blocks: `git push`, `git reset --hard`, `git clean -f/-fd`, `git branch -D`, `git checkout .`, `git restore .`.

## Steps

1. Ask scope: project `.claude/settings.json` or global `~/.claude/settings.json`.
2. Copy bundled `scripts/block-dangerous-git.sh` to:
   - project: `.claude/hooks/block-dangerous-git.sh`
   - global: `~/.claude/hooks/block-dangerous-git.sh`
3. `chmod +x` hook.
4. Add PreToolUse Bash command in chosen settings:

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

5. Test with blocked command. Confirm hook denies.

