guard-git

guard-git is a cursor rule for Claude Code, Cursor from danielvm-git/bigpowers. It costs 96 tokens per session (1,870 once invoked), scanned B, original, MIT.

A Git safety hook that blocks several destructive commands and enforces rules for commits, protected branches, and common secret patterns. Git is the version-control system used to track code changes.

In plain words
What is it for?
Use it to guard Git operations, require Conventional Commit messages, block risky branch actions, and scan commits for recognizable secrets.
Why use it?
It helps prevent accidental data loss, unsafe commits, leaked credentials, and direct changes to protected branches.

Cursor rule for Claude CodeCursor

Written for Claude Code and Cursor: $CLAUDE_PROJECT_DIR variable, but also installed under .cursor/. Also seen: reads .claude/ paths; mentions Claude Code; mentions Gemini CLI.

Good fit Use it to guard Git operations, require Conventional Commit messages, block risky branch actions, and scan commits for recognizable secrets.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/danielvm-git/bigpowers/guard-git
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/danielvm-git/bigpowers

Made for: Claude Code, Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for guard-git

README.md
[![agentmods](https://agentmods.dev/badge/rules/danielvm-git/bigpowers/guard-git/github.svg)](https://agentmods.dev/rules/danielvm-git/bigpowers/guard-git)
Your own site
<a href="https://agentmods.dev/rules/danielvm-git/bigpowers/guard-git"><img src="https://agentmods.dev/badge/rules/danielvm-git/bigpowers/guard-git/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for guard-git

Your own site · 80×15
<a href="https://agentmods.dev/rules/danielvm-git/bigpowers/guard-git"><img src="https://agentmods.dev/badge/rules/danielvm-git/bigpowers/guard-git.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 96 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,870 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00096 $0.01870
Opus 5.5 $0.00038 $0.00748
Sonnet 5.5 $0.00019 $0.00374
Haiku 4.5 $0.00010 $0.00187

Measured 1mo ago against content hash 528d90a61ee6, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade B, and why

guard-git scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

| Claude Code | `PreToolUse` (Bash) | `.claude/settings.json` or `~/.claude/settings.json` |
.cursor/rules/guard-git.mdc · 231 lines

How it starts

The opening of the file, as written. The whole thing — 231 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Guard Git

HARD GATE — HARD GATE — Before committing, verify: branch is not main/master, author is correct, git user is configured. Bad commits are hard to fix.

Installs a shared hook that blocks destructive git operations and enforces workflow discipline. Requires jq on the agent's PATH when the hook runs.

What gets blocked/enforced

  • Safety: git push --force, git reset --hard, git clean -f, git branch -D, git checkout ., git restore ..
  • Discipline: Blocks direct commits or pushes to protected branches (main, master) unless GIT_BIGPOWERS_LAND=1 (set only by scripts/land-branch.sh).
  • Allows: git push origin <feature-branch> for backup/CI; solo land push to main only inside land-branch.sh.
  • Standardization: Enforces Conventional Commits for all git commit commands.
  • Secrets: Blocks commits containing common secret patterns (sk-, ghp_, AKIA, xoxb-, -----BEGIN private keys) — see REFERENCE.md.

Quick start

  1. Scope: ask project-only vs global (paths differ per product).
  2. Write the hook bundle from REFERENCE.md into the client's hooks directory.
  3. Run chmod +x on pre-tool-use.sh.
  4. Merge the hook snippet from REFERENCE.md into the right settings file — do not wipe unrelated keys.
  5. Verify with the 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.

Read the full file on GitHub · 231 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 231 lines · 96 tokens per session scan B 528d90a61ee6

Subscribe to this mod's changes

guard-git is a cursor rule published in the GitHub repository danielvm-git/bigpowers (267 stars, last pushed 27d ago), licensed MIT. It adds 96 tokens to every session and 1,870 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.