git-guardrails-claude-code

git-guardrails-claude-code is a skill for Claude Code from OutlineDriven/odin-gemini-cli-extension. It costs 71 tokens per session (797 once invoked), scanned B, original, Apache-2.0.

A Claude Code safety hook that checks proposed shell commands before they run and blocks selected destructive Git operations, such as hard resets, force pushes, and deleting untracked files.

In plain words
What is it for?
Use it to install project-local or global guardrails that prevent dangerous Git commands before Claude Code executes them.
Why use it?
It reduces the risk of accidentally overwriting local work, deleting repository data, or changing remote history.

Skill for Claude Code

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

Good fit Use it to install project-local or global guardrails that prevent dangerous Git commands before Claude Code executes them.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/outlinedriven/odin-gemini-cli-extension/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 OutlineDriven/odin-gemini-cli-extension --skill git-guardrails-claude-code
Clone the repo
git clone --depth 1 https://github.com/OutlineDriven/odin-gemini-cli-extension

Made for: Claude Code.

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/outlinedriven/odin-gemini-cli-extension/git-guardrails-claude-code.svg)](https://agentmods.dev/skills/outlinedriven/odin-gemini-cli-extension/git-guardrails-claude-code)
Your own site
<a href="https://agentmods.dev/skills/outlinedriven/odin-gemini-cli-extension/git-guardrails-claude-code"><img src="https://agentmods.dev/badge/skills/outlinedriven/odin-gemini-cli-extension/git-guardrails-claude-code.svg" alt="Measured on agentmods" height="20"></a>
Per session 71 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 797 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.00071 $0.00797
Opus 5 $0.00036 $0.00398
Sonnet 5 $0.00014 $0.00159
Haiku 4.5 $0.00007 $0.00080

Measured 7d ago against content hash 05c56ec7f3c5, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, 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 7d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (hook.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.

- **Global** — `~/.claude/settings.json` and `~/.claude/hooks/block-dangerous-git.sh`. Applies to every project.
skills/skills/git-guardrails-claude-code/SKILL.md · 95 lines

How it starts

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

Bash-tool PreToolUse hook. The harness invokes the script with the candidate command on stdin as JSON; the script greps for dangerous patterns and exits non-zero with an explanatory stderr message, which the harness surfaces to the model as a refusal. The model cannot override the block.

Blocked patterns (default)

  • git push — all variants, including --force and --force-with-lease.
  • git reset --hard — discards working tree and index irreversibly.
  • git clean -f and git clean -fd — deletes untracked files and directories.
  • git branch -D — force-deletes a branch, including unmerged work.
  • git checkout . and git restore . — bulk-overwrites uncommitted changes.

Install

1. Choose scope

  • Project-local.claude/settings.json and .claude/hooks/block-dangerous-git.sh. Travels with the repository.
  • Global~/.claude/settings.json and ~/.claude/hooks/block-dangerous-git.sh. Applies to every project.

2. Place the hook script

Write the script (content below) to the chosen hooks directory. Mark executable with chmod +x.

3. Register the hook

Project (.claude/settings.json):

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

4. Verify

echo '{"tool_input":{"command":"git push origin main"}}' | /path/to/block-dangerous-git.sh

Expected: exit code 2, stderr contains BLOCKED:. A benign command (git status) must exit 0 with no output.

Hook script (block-dangerous-git.sh)

#!/bin/bash

INPUT=$(cat)
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command')

DANGEROUS_PATTERNS=(
  "git push"
  "git reset --hard"
  "git clean -fd"
  "git clean -f"
  "git branch -D"
  "git checkout \."
  "git restore \."
  "push --force"
  "reset --hard"
)

for pattern in "${DANGEROUS_PATTERNS[@]}"; do
  if echo "$COMMAND" | grep -qE "$pattern"; then
    echo "BLOCKED: '$COMMAND' matches dangerous pattern '$pattern'. The user has prevented you from doing this." >&2
    exit 2
  fi
done

exit 0

Read the full file on GitHub · 95 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. 7d ago First seen · 95 lines · 71 tokens per session scan B 05c56ec7f3c5

Subscribe to this mod's changes

git-guardrails-claude-code is a skill published in the GitHub repository OutlineDriven/odin-gemini-cli-extension (5 stars, last pushed 2mo ago), licensed Apache-2.0. It adds 71 tokens to every session and 797 once invoked, about $0.0004 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

git-branchless

Enforce idiomatic git-branchless during planning and executing tasks — detached-HEAD-first work, in-memory rebase via git move, event-log recovery via git undo, deferred branch creation, speculative-merge git sync for base updates. Use when planning or executing multi-commit work, history rewrites, stack edits…

OutlineDriven/odin-codex-plugin · 131 tokens

qa

Conversational QA mode — user reports bugs in plain language, agent clarifies minimally, files GitHub issues that survive refactors. Trigger on "QA", "QA session", or ad-hoc bug reporting without a fixed deliverable shape. Distinct from branch-scoped and PR-scoped review.

OutlineDriven/odin-codex-plugin · 62 tokens

setup-pre-commit

Install git pre-commit hooks via the project's hook tool — Husky+lint-staged (JS), pre-commit (Python/OCaml), lefthook (Go), cargo-husky (Rust). Use when the user wants commit-time formatting, linting, type-checking, or test gates. Detects ecosystem first.

OutlineDriven/odin-codex-plugin · 73 tokens

pr-merge-base

Merge one or more PRs into the base branch with queue-like sequencing and conflict resolution. Use when merging PRs that may conflict with each other or the base, requiring ordered application and intelligent conflict handling.

OutlineDriven/odin-codex-plugin · 46 tokens

request-refactor-plan

Plan a refactor as a sequence of tiny, working commits via adversarial interview. Default output is a markdown plan at /docs/refactor-plans/ .md; pass --emit-issue to also file a GitHub issue. Trigger on structural refactors (rename, extract, move, split, dedupe) — NOT new features.

OutlineDriven/odin-codex-plugin · 80 tokens

setup-gitignore

Initialize or idempotently revise the repo's .gitignore by composing gitignore.io templates, AI-tooling/IDE patterns, and confirmed noise from git status. Use when the user says "set up gitignore", "fix gitignore", or untracked files keep appearing in git status.

OutlineDriven/odin-codex-plugin · 64 tokens