Git Guardrails Claude Code
Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute. Use when user wants to prevent destructive git operations, add git safety hooks, or block git push/reset in Claude Code.
Install
/plugin marketplace add mattpocock/skillsThe repo is a Claude Code plugin marketplace. Run /plugin afterwards to pick the plugin that includes this skill.
npx skills add mattpocock/skills --skill git-guardrails-claude-codegit clone --depth 1 https://github.com/mattpocock/skills.git /tmp/skills
mkdir -p ~/.claude/skills
cp -r /tmp/skills/skills/misc/git-guardrails-claude-code ~/.claude/skills/git-guardrails-claude-codePersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# Setup Git Guardrails
Sets up a PreToolUse hook that intercepts and blocks dangerous git commands before Claude executes them.
## 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 .`
When blocked, Claude sees a message telling it that it does not have authority to access these commands.
## Steps
### 1. Ask scope
Ask the user: install for **this project only** (`.claude/settings.json`) or **all projects** (`~/.claude/settings.json`)?
### 2. Copy the hook script
The bundled script is at: [scripts/block-dangerous-git.sh](scripts/block-dangerous-git.sh)
Copy it to the target location based on scope:
- **Project**: `.claude/hooks/block-dangerous-git.sh`
- **Global**: `~/.claude/hooks/block-dangerous-git.sh`
Make it executable with `chmod +x`.
### 3. Add hook to settings
Add to the appropriate settings file:
**Project** (`.claude/settings.json`):
```json
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/block-dangerous-git.sh"
}
]
}
]
}
}
```
**Global** (`~/.claude/settings.json`):Details
- Skill name
git-guardrails-claude-code- Repository
- mattpocock/skills
- Path
skills/misc/git-guardrails-claude-code/SKILL.md- License
- MIT
- Repo updated
- 30 October 2026
- Listed in
- VoltAgent/awesome-agent-skills
FAQ
What does the Git Guardrails Claude Code skill do?
Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute. Use when user wants to prevent destructive git operations, add git safety hooks, or block git push/reset in Claude Code.
How do I install the Git Guardrails Claude Code skill?
Claude Code plugin: /plugin marketplace add mattpocock/skills. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Git Guardrails Claude Code popular?
It lives in mattpocock/skills, which has 307,829 GitHub stars and 25,903 forks, and is included in 1 curated skill list.
Related skills
Ask Matt
308kmattpocock/skills
Ask which skill or flow fits your situation. A router over the skills in this repo.
Chief of Staff
308kmattpocock/skills
Pursue a long-running goal in a single session by co-ordinating subagents.
Claude Handoff
308kmattpocock/skills
Hand the current conversation off to a fresh background agent that picks up the work immediately.
Ship
138kgarrytan/gstack
Ship workflow: detect + merge base branch, run tests, review diff, bump VERSION, update CHANGELOG, commit, push, create PR. (gstack)
Code Review
308kmattpocock/skills
Review the changes since a fixed point (commit, branch, tag, or merge-base) along two axes: Standards (does the code follow this repo's documented coding standards?) and Spec (does the code match what the originating issue/spec asked for?). Runs both reviews in parallel sub-agents and reports them side by side. Use when the user wants to review a branch, a PR, work-in-progress changes, or asks to "review since X".
Benchmark
294kaffaan-m/ECC
このスキルを使用して、パフォーマンスベースラインを測定し、PR前後の回帰を検出し、スタック代替案を比較します。
Browse the most popular Claude skills, all git & code review skills, or write your own with the skills generator.