Cursor rule
.cursor/rules/guard-git.mdcBlock dangerous git commands (push, force push, reset --hard, clean, branch -D, checkout/restore .) and enforce Conventional Commits & Branch Protection before an AI agent runs them. Installs hook scripts for Claude Code, Cursor, Cursor CLI, and Gemini CLI; documents Google Antigravity Terminal deny lists. Use when the user wants git safety hooks, to block git push or destructive git in agents, or to mirror the same policy across AI coding tools.
Cursor rules
Quality
89/100
Scores the file, not the repository.Length
788 words
21 headings · 11 code blocksRepository
114
— · pushed 0 days agoLast changed
3 days ago
First indexed 3 days ago.123456# Guard Git7> **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.8910Installs a shared hook that blocks destructive git operations and enforces workflow discipline. **Requires `jq` on the agent's PATH** when the hook runs.1112## What gets blocked/enforced1314- **Safety**: `git push --force`, `git reset --hard`, `git clean -f`, `git branch -D`, `git checkout .`, `git restore .`.15- **Discipline**: Blocks direct commits or pushes to protected branches (`main`, `master`) unless `GIT_BIGPOWERS_LAND=1` (set only by `scripts/land-branch.sh`).16- **Allows**: `git push origin <feature-branch>` for backup/CI; solo land push to `main` only inside `land-branch.sh`.17- **Standardization**: Enforces [Conventional Commits](https://www.conventionalcommits.org/) for all `git commit` commands.18- **Secrets**: Blocks commits containing common secret patterns (`sk-`, `ghp_`, `AKIA`, `xoxb-`, `-----BEGIN` private keys) — see [REFERENCE.md](REFERENCE.md).1920## Quick start21221. **Scope**: ask project-only vs global (paths differ per product).232. **Write the hook bundle** from [REFERENCE.md](REFERENCE.md) into the client's hooks directory.243. **Run `chmod +x`** on `pre-tool-use.sh`.254. **Merge** the hook snippet from [REFERENCE.md](REFERENCE.md) into the right settings file — do not wipe unrelated keys.265. **Verify** with the tests in [REFERENCE.md](REFERENCE.md).2728| Client | Mechanism | Config |29|--------|-----------|--------|30| Claude Code | `PreToolUse` (Bash) | `.claude/settings.json` or `~/.claude/settings.json` |31| Cursor / Cursor CLI | `beforeShellExecution` | `.cursor/hooks.json` or `~/.cursor/hooks.json` |32| Gemini CLI | `BeforeTool` + `run_shell_command` | `.gemini/settings.json` or `~/.gemini/settings.json` |33| Google Antigravity | Built-in Terminal **Deny list** | Settings UI (no shell hook) |3435**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.3637## Customization3839To add or remove patterns or protected branches, edit `pre-tool-use.sh`.4041## Advanced4243Full JSON examples, merge rules, Antigravity deny-list entries, and test commands: [REFERENCE.md](REFERENCE.md).44454647<!-- story: e01s03 -->4849---5051# Git guardrails — reference5253## Navigation5455| Lines | Section |56|-------|---------|57| 1 | Title |58| 3–16 | Navigation |59| 17–28 | Secret patterns (audit + pre-commit) |60| 29–46 | Copy layout |61| 47–72 | Claude Code |62| 73–94 | Cursor and Cursor CLI |63| 95–122 | Gemini CLI |64| 123–137 | Google Antigravity |65| 138–180 | Verify (local tests) |6667## Secret patterns (audit + pre-commit)6869Agents must not commit files containing:7071- `sk-` (OpenAI API keys)72- `ghp_` / `gho_` (GitHub tokens)73- `AKIA` (AWS access key id)74- `xoxb-` (Slack bot tokens)75- `-----BEGIN` private keys7677Use `audit-code` supply-chain checklist before commit. Consider `git-secrets` or custom pre-commit hook in target projects.7879## Copy layout8081The main script is `pre-tool-use.sh`.8283```text84<hooks-dir>/pre-tool-use.sh85```8687Example project locations:8889- Claude: `.claude/hooks/`90- Cursor: `.cursor/hooks/`91- Gemini: `.gemini/hooks/`9293Use the same layout for user-level hooks (`~/.claude/hooks`, `~/.cursor/hooks`, `~/.gemini/hooks`).9495---9697## Claude Code9899Hook command does **not** need `GIT_GUARDRAILS_MODE` (defaults to `claude`).100101**Project** (`.claude/settings.json`):102103```json104{105 "hooks": {106 "PreToolUse": [107 {108 "matcher": "Bash",109 "hooks": [110 {111 "type": "command",112 "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/pre-tool-use.sh"113 }114 ]115 }116 ]117 }118}119```120121---122123## Cursor and Cursor CLI124125Use `beforeShellExecution`. Set `GIT_GUARDRAILS_MODE=cursor`.126127**Project** (`.cursor/hooks.json`):128129```json130{131 "version": 1,132 "hooks": {133 "beforeShellExecution": [134 {135 "command": "GIT_GUARDRAILS_MODE=cursor .cursor/hooks/pre-tool-use.sh",136 "matcher": "git"137 }138 ]139 }140}141```142143---144145## Gemini CLI146147Use `BeforeTool` with matcher `run_shell_command`. Set **`GIT_GUARDRAILS_MODE=gemini`**.148149**Project** (`.gemini/settings.json`):150151```json152{153 "hooks": {154 "BeforeTool": [155 {156 "matcher": "run_shell_command",157 "hooks": [158 {159 "name": "git-guardrails",160 "type": "command",161 "command": "GIT_GUARDRAILS_MODE=gemini \"$GEMINI_PROJECT_DIR\"/.gemini/hooks/pre-tool-use.sh",162 "timeout": 5000163 }164 ]165 }166 ]167 }168}169```170171---172173## Google Antigravity174175Add **Deny list** entries in **Antigravity → Settings → Terminal**:176177- `git push --force`178- `git push origin main`179- `git push origin master`180- `git reset --hard`181- `git clean`182- `git branch -D`183- `git checkout .`184- `git restore .`185186---187188## Verify (local tests)189190**1. Block push to main without land mode (Claude mode):**191```bash192echo '{"tool_input":{"command":"git push origin main"}}' | ./pre-tool-use.sh193# Expected: exit 2, protected branch message194```195196**2. Allow push to main with GIT_BIGPOWERS_LAND=1:**197```bash198GIT_BIGPOWERS_LAND=1 echo '{"tool_input":{"command":"git push origin main"}}' | ./pre-tool-use.sh199# Expected: exit 0 (when on main)200```201202**3. Allow push to feature branch:**203```bash204echo '{"tool_input":{"command":"git push -u origin feat/my-task"}}' | ./pre-tool-use.sh205# Expected: exit 0206```207208**4. Conventional Commits (Gemini mode):**209```bash210echo '{"tool_input":{"command":"git commit -m \"bad message\""}}' | GIT_GUARDRAILS_MODE=gemini ./pre-tool-use.sh211# Expected: exit 0, {"decision":"deny", "reason":"..."}212```213214**5. Protected Branch commit (Cursor mode):**215```bash216# Run on 'main' branch217echo '{"command":"git commit -m \"feat: valid message\""}' | GIT_GUARDRAILS_MODE=cursor ./pre-tool-use.sh218# Expected: exit 2, "Direct commits to protected branch 'main' are forbidden"219```220221**6. Land script exists:**222```bash223test -x scripts/land-branch.sh && echo OK224```225226**7. Allow (Gemini mode):**227```bash228echo '{"tool_input":{"command":"git status"}}' | GIT_GUARDRAILS_MODE=gemini ./pre-tool-use.sh229# Expected: exit 0, {"decision":"allow"}230```231
Also in danielvm-git/bigpowers
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| danielvm-git/bigpowers.cursor/rules/align-grid.mdc · 114 | Cursor rules | lint-formatdo-notagent-behaviour | 65/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/assess-impact.mdc · 114 | Cursor rules | testtesting-strategydeployment | 66/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/audit-code.mdc · 114 | Cursor rules | setuptestlint-formatstyle+4 | 66/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/audit-plan.mdc · 114 | Cursor rules | buildteststylegit | 74/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/build-epic.mdc · 114 | Cursor rules | buildgit | 58/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/change-request.mdc · 114 | Cursor rules | no sections | 48/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/commit-message.mdc · 114 | Cursor rules | lint-formatstyletypesgit+3 | 82/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/compose-workflow.mdc · 114 | Cursor rules | styledo-notagent-behaviour | 65/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/context7-mcp.mdc · 114 | Cursor rules | style | 54/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/craft-skill.mdc · 114 | Cursor rules | stylearchgitdo-not | 69/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/deepen-architecture.mdc · 114 | Cursor rules | testtesting-strategydo-not | 57/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/define-language.mdc · 114 | Cursor rules | lint-formatdo-not | 65/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/define-success.mdc · 114 | Cursor rules | no sections | 4/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/delegate-task.mdc · 114 | Cursor rules | git | 62/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/deploy.mdc · 114 | Cursor rules | setupbuildtestdeployment | 77/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/design-interface.mdc · 114 | Cursor rules | styleagent-behaviour | 58/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/develop-tdd.mdc · 114 | Cursor rules | teststylearchtesting-strategy+5 | 85/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/diagnose-root.mdc · 114 | Cursor rules | no sections | 39/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/diagnose-stall.mdc · 114 | Cursor rules | no sections | 44/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/dispatch-agents.mdc · 114 | Cursor rules | git | 54/100 | 3 days ago |
Diff against .cursor/rules/align-grid.mdc Diff against .cursor/rules/assess-impact.mdc Diff against .cursor/rules/audit-code.mdc Diff against .cursor/rules/audit-plan.mdc Diff against .cursor/rules/build-epic.mdc Diff against .cursor/rules/change-request.mdc Diff against .cursor/rules/commit-message.mdc Diff against .cursor/rules/compose-workflow.mdc Diff against .cursor/rules/context7-mcp.mdc Diff against .cursor/rules/craft-skill.mdc Diff against .cursor/rules/deepen-architecture.mdc Diff against .cursor/rules/define-language.mdc Diff against .cursor/rules/define-success.mdc Diff against .cursor/rules/delegate-task.mdc Diff against .cursor/rules/deploy.mdc Diff against .cursor/rules/design-interface.mdc Diff against .cursor/rules/develop-tdd.mdc Diff against .cursor/rules/diagnose-root.mdc Diff against .cursor/rules/diagnose-stall.mdc Diff against .cursor/rules/dispatch-agents.mdc
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 3 days ago | |
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 3 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 3 days ago |
