git-guardrails-claude-code
/git-guardrails-claude-code
Konfiguruje w Claude Code hooki blokujące groźne polecenia git, np. reset --hard, clean i branch -D, zanim agent je wykona.
- Autor
- soultech-oh-ux ↗
- Repozytorium
- goodseed ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 07.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 07.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
Konfiguruje w Claude Code hooki blokujące groźne polecenia git, np. reset --hard, clean i branch -D, zanim agent je wykona.
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
- What Gets Blocked
- Steps
- Known limits (by design)
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.
---
# 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: `${GSD_PACK_DIR:-$HOME/.goodseed/pack}/skills/git-guardrails-claude-code/scripts/block-dangerous-git.sh`
**Requires `python3` on PATH** (the gate tokenizes the command instead of substring-matching; it fails closed — blocks — if python3 is missing). No jq needed.
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 existing `hooks.PreToolUse` array — don't overwrite other settings.
### 4. Ask about customization
Ask if user wants to add or remove rules from the blocked set. Edit the rule functions in the copied script accordingly (`check_git_invocation`), and add matching cases to the `--self-test` battery.
### 5. Verify
Run the built-in battery — it includes the bypass vectors (flag injection `git -C x push`, quoting `git "push"`, reordering `git reset HEAD~1 --hard`, wrappers `sudo`/`env`) and false-positive controls (`git commit -m "explain git push"`):
```bash
<path-to-script> --self-test
```
Must print `self-test OK`. Then spot-check the live contract:
```bash
echo '{"tool_input":{"command":"git push origin main"}}' | <path-to-script> # exit 2, BLOCKED on stderr
echo '{"tool_input":{"command":"git status"}}' | <path-to-script> # exit 0
```
## Known limits (by design)
The threat model is preventing *mistakes*, not stopping a determined adversary. Interpreter indirection (`bash -c "git push"`), git aliases (`git co`), and shell variables that expand outside the inspected string are not caught — the human reviewing the session remains the kill-switch.
Pliki w paczce (2)
- SKILL.md 3 KB
- scripts/block-dangerous-git.sh 9 KB
Wersje
| Repozytorium | Wynik | Licencja |
|---|---|---|
| Ta strona · soultech-oh-ux/goodseed | 100 | MIT |
| mattpocock/skills | 100 | MIT |
| sideshowroberto/vfx-agent-toolkit | 100 | MIT |
| stevesolun/ctx | 100 | MIT |
| akillness/jeo-skills | 95 | MIT |
Migawka bazy z 13.11.2026 · wersja paczki 0e525cee48c6 (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.