git-guardrails-claude-code
/git-guardrails-claude-code
Dodaje do Claude Code hooki, które blokują niebezpieczne polecenia git, np. push, reset --hard lub clean, zanim się wykonają.
- Autor
- akillness ↗
- Repozytorium
- jeo-skills ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 13.11.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 2
- Skrypty
- 1
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 13.11.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
- 1 skrypt w paczce. Przejrzyj je przed instalacją, bo Claude może je uruchomić.
Skrypty: scripts/block-dangerous-git.sh
Co robi i kiedy
Dodaje do Claude Code hooki, które blokują niebezpieczne polecenia git, np. push, reset --hard lub clean, zanim się wykonają.
Oryginalny opis (EN)
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.
Jak działa
- When to use this skill
- Instructions
- Setup Git Guardrails
- Examples
- Best practices
- References
Podgląd SKILL.md
---
name: git-guardrails-claude-code
description: >
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.
allowed-tools: Read Grep Glob Bash Write Edit
compatibility: >
Claude Code hook setup only. Route general Git workflow guidance to git-workflow.
metadata:
tags: git-safety, claude-code-hooks, pretooluse, destructive-commands, guardrails
platforms: Claude, ChatGPT, Gemini, Codex
version: "1.0"
source: mattpocock/skills
upstream_commit: 3cca18b368ae95cdbdebbff572ccafa662551015
invocation: model-invoked
---
# Git Guardrails for 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.
This skill is imported from `mattpocock/skills` (MIT) and is **model-invoked** upstream.
## When to use this skill
- 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.
## Instructions
## 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`):
```json
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/block-dangerous-git.sh"
}
]
}
]
}
}
```
If the settings file already exists, merge the hook into the existing `hooks.PreToolUse` array. Don't overwrite other settings.
#### 4. Ask about customization
Ask if user wants to add or remove any patterns from the blocked list. Edit the copied script accordingly.
#### 5. Verify
Run a quick test:
```bash
echo '{"tool_input":{"command":"git push origin main"}}' | <path-to-script>
```
Should exit with code 2 and print a BLOCKED message to stderr.
## Examples
- Apply this skill to one narrow scope first, confirm the output matches the shape described above, then widen to the full task.
- When a step needs a fact from the repository or the environment, look it up instead of asking the user for it.
## Best practices
- Keep the upstream procedure intact; record deviations explicitly instead of silently improvising.
- Stop and hand control back to the user at every decision point this skill marks as theirs.
- Prefer small reversible changes, and state assumptions rather than burying them.
## References
- Upstream skill: `mattpocock/skills` `skills/misc/git-guardrails-claude-code/SKILL.md` (commit `3cca18b`, MIT)
- Script: `scripts/block-dangerous-git.sh`
- Project standards: `.agent-skills/skill-standardization/SKILL.md`
- Validator script: `.agent-skills/skill-standardization/scripts/validate_skill.sh`
Pliki w paczce (2)
- SKILL.md 4 KB
- scripts/block-dangerous-git.sh 1 KB
Wersje
| Repozytorium | Wynik | Licencja |
|---|---|---|
| Ta strona · akillness/jeo-skills | 95 | MIT |
| mattpocock/skills | 100 | MIT |
| soultech-oh-ux/goodseed | 100 | MIT |
| sideshowroberto/vfx-agent-toolkit | 100 | MIT |
| stevesolun/ctx | 100 | MIT |
Migawka bazy z 13.11.2026 · wersja paczki 66ea5dd57621 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100git-guardrails
Instaluje hook dla jednego projektu lub wszystkich, który blokuje destrukcyjne polecenia git, np. push, reset --hard i branch -D. - 100git-guardrails
Instaluje hook, który blokuje destrukcyjne polecenia git, zanim agent AI je uruchomi, np. force push lub reset --hard. - 90git-safety
Pilnuje, by nie wykonywać niebezpiecznych operacji Git, takich jak force push, reset czy czyszczenie w trybie destrukcyjnym. - 100git-guardrails
Wymusza mechanicznie zasady bezpieczeństwa git hookiem PreToolUse, który blokuje force-push, reset --hard i inne ryzykowne polecenia. - 100git-guardrails
Instaluje hook PreToolUse, który blokuje destrukcyjne operacje git, np. --no-verify, branch -D i force-push, poza hubem. - 100git-guard
Pyta przed destrukcyjnym zapisem w Git, np. force push, reset --hard lub dodaniem plików .env, i najpierw streszcza diff.