setup-git-guardrails

setup-git-guardrails is a skill for Claude Code, Codex from toverux/cantrips. It costs 0 tokens per session (861 once invoked), scanned A, original, MIT.

A setup guide for a safety hook that stops an AI coding tool before it runs selected dangerous Git commands. Git is a version-control system used to track code changes.

In plain words
What is it for?
Use it to block commands such as force-pushing, hard resets, forced cleanup, deleting branches, and restoring all files in Claude Code or Codex CLI.
Why use it?
It reduces the chance of accidentally deleting local work, rewriting history, or sending changes to a remote repository. The hook asks whether to protect one project or all projects and which coding tool to configure.

Skill for Claude CodeCodex

Written for Claude Code and Codex: disable-model-invocation in frontmatter, but also agents/openai.yaml present. Also seen: reads .claude/ paths; mentions Claude Code; mentions Codex.

Part of the cantrips plugin — 25 skills, 1 agent shipped together

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/toverux/cantrips/setup-git-guardrails
Any agent
npx skills add toverux/cantrips --skill setup-git-guardrails
Clone the repo
git clone --depth 1 https://github.com/toverux/cantrips

Made for: Claude Code, Codex.

Or install cantrips, the plugin that ships this one along with the rest of its 25 skills, 1 agent.

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 setup-git-guardrails

README.md
[![agentmods](https://agentmods.dev/badge/skills/toverux/cantrips/setup-git-guardrails.svg)](https://agentmods.dev/skills/toverux/cantrips/setup-git-guardrails)
Your own site
<a href="https://agentmods.dev/skills/toverux/cantrips/setup-git-guardrails"><img src="https://agentmods.dev/badge/skills/toverux/cantrips/setup-git-guardrails.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 861 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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.00000 $0.00861
Opus 5 $0.00000 $0.00430
Sonnet 5 $0.00000 $0.00172
Haiku 4.5 $0.00000 $0.00086

Measured yesterday against content hash a34dd3c1b395, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

setup-git-guardrails scanned grade A with 0 findings 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 yesterday.

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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/setup-git-guardrails/SKILL.md · 77 lines

How it starts

The opening of the file, as written. The whole thing — 77 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 the agent 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, the agent sees a message telling it that it does not have authority to access these commands.

Steps

1. Ask harness and scope

Ask the user for whatever the arguments did not already supply: which harness — Claude Code, Codex CLI, or both — and install for this project only or all projects?

2. Copy the hook script

The bundled script is at: scripts/block-dangerous-git.sh

Copy it to the target location based on harness and scope:

  • Claude Code, project: .claude/hooks/block-dangerous-git.sh
  • Claude Code, global: ~/.claude/hooks/block-dangerous-git.sh
  • Codex CLI, project: .codex/hooks/block-dangerous-git.sh
  • Codex CLI, global: ~/.codex/hooks/block-dangerous-git.sh

Make it executable with chmod +x.

The script needs bash, jq and grep on PATH — state that to the user, since jq ships with none of the three platforms by default. Without it the script reads an empty command, matches nothing, and exits 0, which is the allow verdict: the guardrail installs and passes everything.

3. Add hook to config

Read HOOK-CONFIG.md and work through the section for each harness being installed.

If the config file already exists, merge the hook into existing hooks.PreToolUse array — don't overwrite other settings.

On Codex, finish by having the user trust the entry under /hooks; the hook does not run until they do.

4. Ask about customization

Ask if user wants to add or remove any patterns from the blocked list. Edit every copy step 2 wrote, so a both-harness install does not end up guarding two different lists. The entries are extended regexes matched against the whole command, not literal text.

Read the full file on GitHub · 77 lines

Files

What ships with it

3 files 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. yesterday Changed a34dd3c1b395
  2. 6d ago First seen · 77 lines · 0 tokens per session scan A de29c2b1c7ca

Subscribe to this mod's changes

setup-git-guardrails is a skill published in the GitHub repository toverux/cantrips (2 stars, last pushed 2d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 861 tokens. A static security scan graded it A with 0 findings. 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

git-workflow

This skill should be used when the user asks to "create git commit", "manage branches", "follow git workflow", "use Conventional Commits", "handle merge conflicts", or asks about git branching strategies, version control best practices, pull request workflows. Provides comprehensive Git workflow guidance for team…

Galaxy-Dawn/claude-scholar · 64 tokens

daily-paper-generator

Use when the user asks to generate daily paper digests on a general topic. This skill supports both arXiv and bioRxiv (or either one), then produces structured Chinese/English summaries for selected papers.

Galaxy-Dawn/claude-scholar · 47 tokens

review

5-pass structured code review — correctness, security, performance, readability, consistency.

SethGammon/Citadel · 17 tokens

wiki

Markdown-first knowledge base where the LLM acts as librarian. Ingests raw sources, compiles and interlinks topic files, self-maintains an index. No vector DB or embeddings required -- uses LLM-native navigation over structured markdown up to 400K words.

SethGammon/Citadel · 56 tokens

marshal

Meta-orchestrator that takes any direction — broad, specific, or vague — and autonomously chains skills and context into actionable work. Gathers context from codebase, docs, and memory. Only asks the user when it genuinely cannot proceed. Single-session orchestrator.

SethGammon/Citadel · 56 tokens

codex-autoresearch

Run autonomous, measurable experiments in a Git repository: change one hypothesis, verify a numeric metric, keep improvements, and revert failures. Use when the user wants Codex to keep iterating toward a numeric target in the foreground or as a detached background run. Do not use for ordinary one-shot coding…

leo-lilinxiao/codex-autoresearch · 80 tokens