git-guardrails-claude-code

git-guardrails-claude-code is a skill for Claude Code from wakqasahmed/skills. It costs 70 tokens per session (1,055 once invoked), scanned B, original, MIT.

A set of Claude Code hooks that blocks selected dangerous Git commands before they run. Git is the version-control system used to track code changes and branches.

In plain words
What is it for?
For blocking force-pushes, direct pushes to main, master, or staging, hard resets, forced cleanup, branch deletion, and bare commands that discard changes.
Why use it?
It reduces the risk of losing uncommitted work or changing protected branches by mistake. Normal pushes to feature branches remain allowed.

Skill for Claude Code

Written for Claude Code: $CLAUDE_PROJECT_DIR variable. Also seen: reads .claude/ paths; mentions Claude Code.

Part of the skills plugin — 26 skills shipped together

Good fit For blocking force-pushes, direct pushes to main, master, or staging, hard resets, forced cleanup, branch deletion, and bare commands that discard changes.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/wakqasahmed/skills/git-guardrails-claude-code
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.

Any agent
npx skills add wakqasahmed/skills --skill git-guardrails-claude-code
Clone the repo
git clone --depth 1 https://github.com/wakqasahmed/skills

Made for: Claude Code.

Or install skills, the plugin that ships this one along with the rest of its 26 skills.

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 git-guardrails-claude-code

README.md
[![agentmods](https://agentmods.dev/badge/skills/wakqasahmed/skills/git-guardrails-claude-code/github.svg)](https://agentmods.dev/skills/wakqasahmed/skills/git-guardrails-claude-code)
Your own site
<a href="https://agentmods.dev/skills/wakqasahmed/skills/git-guardrails-claude-code"><img src="https://agentmods.dev/badge/skills/wakqasahmed/skills/git-guardrails-claude-code/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 git-guardrails-claude-code

Your own site · 80×15
<a href="https://agentmods.dev/skills/wakqasahmed/skills/git-guardrails-claude-code"><img src="https://agentmods.dev/badge/skills/wakqasahmed/skills/git-guardrails-claude-code.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 70 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,055 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.00070 $0.01055
Opus 5 $0.00035 $0.00528
Sonnet 5 $0.00014 $0.00211
Haiku 4.5 $0.00007 $0.00105

Measured 10d ago against content hash 59794aec852d, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade B, and why

git-guardrails-claude-code 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 10d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/block-dangerous-git.sh), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

Ask the user: install for **this project only** (`.claude/settings.json`) or **all projects** (`~/.claude/settings.json`)?
skills/engineering/git-guardrails-claude-code/SKILL.md · 85 lines

How it starts

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

Setup Git Guardrails

Sets up a PreToolUse hook that intercepts and blocks a fixed list of destructive git commands before Claude executes them.

Source: adapted from mattpocock/skills — misc/git-guardrails-claude-code, imported 2026-08-26. Upstream blocks every invocation of git push, including plain feature-branch pushes. This adaptation narrows that to force-push and direct pushes to protected branches only, because system-level/core.md's git workflow requires routine feature-branch pushes for the standard worktree → branch → push → PR flow — blocking all pushes would make this repo's own workflow unusable. The rest of upstream's blocked-command list (reset --hard, clean -f/-fd, branch -D, bare checkout/restore) is unchanged.

What Gets Blocked

  • git push with --force / --force-with-lease / -f
  • git push directly to main, master, or staging
  • git reset --hard
  • git clean -f / git clean -fd
  • git branch -D
  • git checkout . / git restore . (bare, discards uncommitted changes)

Routine git push origin <feature-branch> is not blocked.

When blocked, Claude sees a message telling it that it does not have authority to run the command.

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

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, merging into any existing hooks.PreToolUse array — don't overwrite other settings:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "~/.claude/hooks/block-dangerous-git.sh"
          }
        ]
      }
    ]
  }
}

Read the full file on GitHub · 85 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 10d ago First seen · 85 lines · 70 tokens per session scan B 59794aec852d

Subscribe to this mod's changes

git-guardrails-claude-code is a skill published in the GitHub repository wakqasahmed/skills (2 stars, last pushed 15d ago), licensed MIT. It adds 70 tokens to every session and 1,055 once invoked, about $0.0003 per session on Opus 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-08-31.

Related

Other skills, from other repositories

prowler-commit

Creates professional git commits following conventional-commits format. Trigger: When creating commits, after completing code changes, when user asks to commit.

prowler-cloud/prowler · 33 tokens

gh-auth-isolation

Safely manage multiple GitHub identities (EMU + personal) in agent workflows.

github/gh-aw · 20 tokens

comet-github

A routing guide for Comet-related GitHub work. It directs requests about pull requests, issues, CI failures, ideas, and fixes to the appropriate review or implementation process.

rpamis/comet · 72 tokens

github-skill

Work with GitHub via the gh CLI — clone repositories, create/list/merge pull requests, create/list issues, and run any other gh command (API calls, workflow runs, releases, repo administration). List operations return parsed JSON.

zeenie-ai/OpenCompany · 51 tokens

re0-merge

Review and land an external contribution the way this suite does: gate it against the thesis, land it with the author's credit intact, complete a new skill rather than merging it raw, then approve, credit, and explain before closing. Use when reviewing a pull request, as any collaborator or maintainer, not only the…

LilMGenius/paperthin · 70 tokens

nvca-chart-release

Release NVCA Operator chart changes from the native monorepo source to the vendored Helm chart. Use when updating the vendored NVCA Operator chart, changing NVCA image refs, publishing helm-nvca-operator, or validating the chart against a self-managed control plane.

NVIDIA/nvcf · 61 tokens