git-safety

A setup guide for Git safety hooks that stop selected risky Git commands before they run. Git is a version-control system; these commands can publish changes, erase uncommitted work, or delete branches and files.

In plain words
What is it for?
It is for installing and configuring pre-command checks that block dangerous Git operations while preserving existing hook settings.
Why use it?
It adds a review point before operations such as pushing, hard resets, cleaning files, or deleting branches. The guide supports project-level or user-wide installation for Claude Code or OMP.

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/voidtechnology/voidtech-claude-plugins/git-safety
Any agent
npx skills add VoidTechnology/voidtech-claude-plugins --skill git-safety
Clone the repo
git clone --depth 1 https://github.com/VoidTechnology/voidtech-claude-plugins

Made for: Claude Code, Codex.

Per session 61 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 908 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. 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 $0.00061 $0.00908
Opus 5 $0.00030 $0.00454
Sonnet 5 $0.00012 $0.00182
Haiku 4.5 $0.00006 $0.00091

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

Security

Grade B, and why

git-safety 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 yesterday.

The scan reads SKILL.md. This mod also ships 2 executable files (scripts/block-dangerous-git-omp.mjs, 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.

| Claude Code | `.claude/settings.json` + `.claude/hooks/` | `~/.claude/settings.json` + `~/.claude/hooks/` |
plugins/voidtech-engineering/skills/git-safety/SKILL.md · 84 lines

How it starts

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

Vendored from mattpocock/skills · MIT © 2026 Matt Pocock · upstream 6eeb81b · 已汉化并完成 VoidTech 插件内自包含适配。LICENSE 见 ../_vendor-licenses/mattpocock-LICENSE

配置 Git 安全钩子

为当前宿主配置执行前钩子,拦截并阻止危险 Git 命令。只安装用户选择的作用范围,不默认写入全局配置。

会被拦截的命令

  • git push(所有变体,包括 --force
  • git reset --hard
  • git clean -f / git clean -fd
  • git branch -D
  • git checkout . / git restore .

命令被拦截时,agent 会收到一条消息,说明该操作不在授权范围内。

步骤

1. 询问作用范围

询问用户仅为当前项目安装,还是为所有项目安装。目标位置取决于宿主:

宿主 项目级 全局级
Claude Code .claude/settings.json + .claude/hooks/ ~/.claude/settings.json + ~/.claude/hooks/
OMP .omp/hooks/pre/block-dangerous-git.mjs ~/.omp/agent/hooks/pre/block-dangerous-git.mjs

2. 安装当前宿主的钩子

Claude Code

随附脚本位于 scripts/block-dangerous-git.sh。使用 ${CLAUDE_PLUGIN_ROOT}/skills/git-safety/scripts/block-dangerous-git.sh 作为源路径,复制到所选范围的 hooks/,并执行 chmod +x

把 command hook 合并进所选 settings.jsonhooks.PreToolUse 数组,不得覆盖已有设置:

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

全局级只把 command 改为 "\"$HOME\"/.claude/hooks/block-dangerous-git.sh"

OMP

通过 skill://git-safety/scripts/block-dangerous-git-omp.mjs 读取随附的 OMP Extension Hook,并把内容原样写入用户选择的目标文件。不要从 OMP 插件缓存猜路径,不要修改插件安装目录。OMP 按约定自动发现 hooks/pre/*.mjs,无需额外 settings 项;新钩子从下次会话开始生效。

3. 询问是否定制

询问用户是否要添加或移除拦截模式;只编辑复制后的文件,不修改插件随附模板。

4. 验证

Claude Code 先确认 jq 可用,再用危险命令 fixture 验证退出码 2:

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

OMP 直接导入复制后的模块并验证危险命令被识别、只读命令被允许:

node --input-type=module -e "import { isDangerousGitCommand as blocked } from '<path-to-hook>'; if (!blocked('git push origin main') || blocked('git status')) process.exit(1)"

Read the full file on GitHub · 84 lines

Files

What ships with it

2 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 First seen · 84 lines · 61 tokens per session scan B f7a185469091

Subscribe to this mod's changes

git-safety is a skill published in the GitHub repository VoidTechnology/voidtech-claude-plugins (2 stars, last pushed 28d ago), licensed Apache-2.0. It adds 61 tokens to every session and 908 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

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

next-cache-components-adoption

Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…

vercel/next.js · 95 tokens

babysit-pr

Babysit a GitHub pull request after creation by continuously polling review comments, CI checks/workflow runs, and mergeability state until the PR is merged/closed or user help is required. Diagnose failures, retry likely flaky failures up to 3 times, auto-fix/push branch-related issues when appropriate, and keep…

openai/codex · 114 tokens

imagegen

Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output…

openai/codex · 113 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens

next-cache-components-optimizer

Drive a Next.js route to instant navigation by setting up an agentic loop, under Cache Components / PPR, on initial load (hard navigation) and client-side navigation (soft navigation). Encode the goal as a failing @next/playwright instant() e2e and work it to green, one verified route at a time; the shipped test then…

vercel/next.js · 170 tokens