git-guardrails-claude-code

git-guardrails-claude-code is a skill for Claude Code, Codex from klimentij/klimkit. It costs 62 tokens per session (588 once invoked), scanned B, a copy of git-guardrails-claude-code, MIT.

A skill that adds Claude Code safety hooks, which check commands before they run, to block selected destructive Git operations such as pushing, deleting branches, or discarding changes.

In plain words
What is it for?
Use it to install project-wide or user-wide protections against dangerous Git commands in Claude Code.
Why use it?
It reduces the chance that an agent will accidentally publish code, erase work, or rewrite Git history.

Skill for Claude CodeCodex

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.

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

Made for: Claude Code, Codex.

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/klimentij/klimkit/git-guardrails-claude-code.svg)](https://agentmods.dev/skills/klimentij/klimkit/git-guardrails-claude-code)
Your own site
<a href="https://agentmods.dev/skills/klimentij/klimkit/git-guardrails-claude-code"><img src="https://agentmods.dev/badge/skills/klimentij/klimkit/git-guardrails-claude-code.svg" alt="Measured on agentmods" height="20"></a>
Per session 62 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 588 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. Scan, not verified.
Origin 92% copy Near-identical to another mod 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 $0.00062 $0.00588
Opus 5 $0.00031 $0.00294
Sonnet 5 $0.00012 $0.00118
Haiku 4.5 $0.00006 $0.00059

Measured 4d ago against content hash 03c4de7613c7, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 4d 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`)?
Origin

This is a copy

92% identical to git-guardrails-claude-code — 2 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

third_party/mattpocock-skills/skills/misc/git-guardrails-claude-code/SKILL.md · 96 lines

How it starts

The opening of the file, as written. The whole thing — 96 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 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: 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:

Project (.claude/settings.json):

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

Global (~/.claude/settings.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 any patterns from the blocked list. Edit the copied script accordingly.

5. Verify

Run a quick test:

echo '{"tool_input":{"command":"git push origin main"}}' | <path-to-script>

Should exit with code 2 and print a BLOCKED message to stderr.

Read the full file on GitHub · 96 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. 4d ago First seen · 96 lines · 62 tokens per session scan B 03c4de7613c7

Subscribe to this mod's changes

git-guardrails-claude-code is a skill published in the GitHub repository klimentij/klimkit (7 stars, last pushed 24d ago), licensed MIT. It adds 62 tokens to every session and 588 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it B with 1 finding (reads agent configuration directories). It is 92% identical to git-guardrails-claude-code, differing in 2 lines, and is treated as a copy.

Related

Other skills, from other repositories

happiness-skill

当用户问「怎么才能更幸福/为什么得到了还不满足/怎么减少焦虑」时调用。 核心理念: 幸福是缺憾感清空的默认状态, 是可训练的技能; 欲望是与自己的契约(得到前不快乐), 同时只留一个重大欲望; 活在当下。 不适用于: 临床抑郁等需要专业治疗的场景(本书方法不能替代医疗)。 Triggers: 幸福/不快乐/欲望/焦虑/知足/活在当下/happiness/desire/anxiety.

kangarooking/cangjie-skill · 136 tokens

agr-cli

Install, share, sync, and create AI agent skills across coding tools (Claude Code, Cursor, Codex, OpenCode, Copilot, Pi) using the agr CLI. Use whenever the user mentions agr, agr.toml, agr.lock, agrx, or asks to: add a skill ("install the pdf skill", "agr add ..."), sync agent resources across tools, share skills…

computerlovetech/agr · 147 tokens

agr-release

Release process for the agr package. Handles version bumping (major/minor/patch/beta), changelog updates, pre-release quality checks, git tagging, and monitoring the GitHub Actions publish pipeline. Use this skill whenever the user wants to cut a release, bump the version, publish to PyPI, or asks about the release…

computerlovetech/agr · 91 tokens

linkedin-post

You take a YouTube video transcript and produce a single LinkedIn post draft.

owainlewis/youtube-tutorials · 0 tokens

kafka-consumer-lag

Analyse Kafka consumer group lag using the Lenses MCP server. Diagnoses lag causes (throughput bottlenecks, rebalancing, partition skew, stalled consumers) and suggests remediation. Use when user says "check consumer lag", "why are consumers slow", "lag report" or asks about consumer group health or offset progress.…

lensesio/agentic-engineering-for-apache-kafka · 84 tokens

mechanical-preprocess

Bash-first mechanical pattern cleanup pipeline — handles em-dash removal, forbidden words, and repetitive structures at scale BEFORE AI agents touch the text. Processes 30+ chapters efficiently.

felipelobomotta-blip/book-genesis-v4 · 41 tokens