git-guardrails
Git guardrails
Installs a shared hook that blocks destructive git operations. Requires jq on the agent’s PATH when the hook runs.
What gets blocked
git push(including--force)git reset --hard,git clean -f/git clean -fdgit branch -Dgit checkout ./git restore .
Quick start
- Scope: ask project-only vs global (paths differ per product).
- Copy the hook bundle from this skill’s scripts/ to the client’s hooks directory, keeping
block-dangerous-git.shandlib/git-guardrails-core.shtogether (the main script sources the core file). - Run
chmod +xonblock-dangerous-git.sh. - Merge the hook snippet from REFERENCE.md into the right settings file—do not wipe unrelated keys.
- Verify with the echo tests in REFERENCE.md.
| Client | Mechanism | Config |
|---|---|---|
| Claude Code | PreToolUse (Bash) |
.claude/settings.json or ~/.claude/settings.json |
| Cursor / Cursor CLI | beforeShellExecution |
.cursor/hooks.json or ~/.cursor/hooks.json |
| Gemini CLI | BeforeTool + run_shell_command |
.gemini/settings.json or ~/.gemini/settings.json |
| Google Antigravity | Built-in Terminal Deny list | Settings UI (no shell hook) |
Modes (env on the hook command): GIT_GUARDRAILS_MODE is claude (default) or cursor → stderr + exit 2 on block. Set gemini for Gemini CLI → JSON decision on stdout (see REFERENCE.md).
Customization
To add or remove patterns, edit lib/git-guardrails-core.sh in the copied bundle (array GIT_GUARDRAILS_PATTERNS).
Advanced
Full JSON examples, merge rules, Antigravity deny-list entries, and test commands: REFERENCE.md.
More from danielvm-git/skills
triage-issue
Triage a bug or issue by exploring the codebase to find root cause, then create a GitHub issue with a TDD-based fix plan. Use when user reports a bug, wants to file an issue, mentions "triage", or wants to investigate and plan a fix for a problem.
11ubiquitous-language
Extract a DDD-style ubiquitous language glossary from the current conversation, flagging ambiguities and proposing canonical terms. Saves to UBIQUITOUS_LANGUAGE.md. Use when user wants to define domain terms, build a glossary, harden terminology, create a ubiquitous language, or mentions "domain model" or "DDD".
11write-a-skill
Create new agent skills with proper structure, progressive disclosure, and bundled resources. Use when user wants to create, write, or build a new skill.
11setup-pre-commit
Set up Husky pre-commit hooks with lint-staged (Prettier), type checking, and tests in the current repo. Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typechecking/testing.
11tdd
Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.
10to-prd
Turn the current conversation context into a PRD and submit it as a GitHub issue. Use when user wants to create a PRD from the current context.
10