git-destructive-op-guard

git-destructive-op-guard is a skill for Claude Code, Codex from magic3007/dotfiles. It costs 256 tokens per session (3,661 once invoked), scanned C, original, MIT.

A guard for destructive Git commands that can overwrite local changes, plus documented evidence about what those commands do. It blocks several restoration and branch-switching commands when enabled, but does not block every destructive command.

In plain words
What is it for?
It helps protect shared checkouts from accidental restores, hard resets, stashes, and branch switches, and explains when staging changes creates a recoverable Git object.
Why use it?
Commands such as restoring or resetting files can permanently remove unstaged edits because Git may never have stored them. The guard reduces that risk, while its documented limits show why users must still be careful with commands such as cleaning untracked files.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit It helps protect shared checkouts from accidental restores, hard resets, stashes, and branch switches, and explains when staging changes creates a recoverable Git object.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/magic3007/dotfiles/git-destructive-op-guard
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 magic3007/dotfiles --skill git-destructive-op-guard
Clone the repo
git clone --depth 1 https://github.com/magic3007/dotfiles

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-destructive-op-guard

README.md
[![agentmods](https://agentmods.dev/badge/skills/magic3007/dotfiles/git-destructive-op-guard/github.svg)](https://agentmods.dev/skills/magic3007/dotfiles/git-destructive-op-guard)
Your own site
<a href="https://agentmods.dev/skills/magic3007/dotfiles/git-destructive-op-guard"><img src="https://agentmods.dev/badge/skills/magic3007/dotfiles/git-destructive-op-guard/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-destructive-op-guard

Your own site · 80×15
<a href="https://agentmods.dev/skills/magic3007/dotfiles/git-destructive-op-guard"><img src="https://agentmods.dev/badge/skills/magic3007/dotfiles/git-destructive-op-guard.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 256 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,661 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 2 findings. 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.00256 $0.03661
Opus 5.5 $0.00102 $0.01464
Sonnet 5.5 $0.00051 $0.00732
Haiku 4.5 $0.00026 $0.00366

Measured 4d ago against content hash 0069926a42c5, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade C, and why

git-destructive-op-guard scanned grade C with 2 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 4d ago.

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.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

- 非 git 的同类事故:脚本内 `rm -rf`、`cp` 覆写、installer 覆盖配置

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

| F8 | eval 内核里 `sh("git checkout -- .")` 同样被拦(走 bash 工具),但 `subprocess.run(["git","checkout","--","."])` 直接执行成功并破坏工作区 | `sh()` 抛 ShellError exit 1;`subprocess.run` 返回 0,文件被改回旧值 | 在 eval 单元格里分别跑两种调用 | 同上 | 2026-11-13 |
skills/git-destructive-op-guard/SKILL.md · 144 lines

How it starts

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

共享 checkout 里的破坏性 git 命令

Facts

# 事实 证据 复核命令 生效条件 记录日期
F1 git checkout -- . 把工作区全部未暂存改动还原为索引内容,git status --porcelain 随即变空 夹具仓库两文件均 M,执行后 git status 无输出,内容回到 v1 在一次性仓库改两个已跟踪文件后执行 git checkout -- .,再看 git status --porcelain git 2.34+ 2026-11-13
F2 已暂存改动能活过 git checkout -- .;工作区从索引重建,内容还在对象库 夹具中 git add 后执行,mine.txt 仍为 staged-v2,git rev-parse :mine.txt 有 blob 同上,改动先 git add 再执行 同上 2026-11-13
F3 被 git checkout -- . 抹掉的未暂存内容不可恢复:git fsck --lost-found 找不到对应 blob 夹具执行后 git fsck --lost-found | grep -c blob 输出 0 同上,执行后跑 git fsck --lost-found 未暂存 = 从未 git add 2026-11-13
F4 bash.gitGuard: true 时,git checkout -- .、git checkout HEAD -- .、git restore --worktree .、git reset --hard、git stash、git switch <branch> 全部被拒,exit=1,工作区不变 六条命令逐条执行,均 exit=1 且 cat 目标文件仍为新值 git checkout -- . 于脏工作区(须在共用 checkout 内) omp 18.20.0, bash.gitGuard: true 2026-11-13
F5 bash.gitGuard 不拦 git clean -fdx;该命令 exit=0 并删掉未跟踪文件 夹具中被删文件 ls 报 No such file or directory 一次性仓库放一个未跟踪文件后 git clean -fdx omp 18.20.0 2026-11-13
F6 bash.patterns 加 {"match":"git clean*","approval":"deny"} 后,bash 工具整条命令被拒:Tool "bash" is blocked by tool policy. + Blocked by bash pattern: git clean*;git clean -n* 前置 allow 项仍放行 dry-run 单条 git clean -fdx 被拒,单条 git clean -n --dry-run exit=0 git clean -fdx 于一次性仓库 同上,规则顺序 allow 在 deny 前 2026-11-13
F7 在 git worktree add <path> -b <br> 建的自有 worktree 内,同类命令放行且自动保存:git checkout: saved your uncommitted changes as <sha> on refs/omp/discarded first 自有 worktree 内 git checkout -- . exit=0 并打印该行 建 worktree 后在其中改文件再执行 同上 2026-11-13
F8 eval 内核里 sh("git checkout -- .") 同样被拦(走 bash 工具),但 subprocess.run(["git","checkout","--","."]) 直接执行成功并破坏工作区 sh() 抛 ShellError exit 1;subprocess.run 返回 0,文件被改回旧值 在 eval 单元格里分别跑两种调用 同上 2026-11-13

Model

Read the full file on GitHub · 144 lines

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 Changed 0069926a42c5
  2. 16d ago First seen · 144 lines · 256 tokens per session scan C 060cce421271

Subscribe to this mod's changes

git-destructive-op-guard is a skill published in the GitHub repository magic3007/dotfiles (11 stars, last pushed 5d ago), licensed MIT. It adds 256 tokens to every session and 3,661 once invoked, about $0.0010 per session on Opus 5.5. A static security scan graded it C with 2 findings (recursive force delete, runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-11-14.

Related

git-destructive-op-guard compared with skills from other repositories

git-destructive-op-guard next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
git-destructive-op-guardmagic3007/dotfilesSkill115d agoMITC256Claude Code, Codex
merge-readyurmzd/dotfilesSkill64d agoApache-2.0A208Claude Code
sync-releaseurmzd/dotfilesSkill64d agoApache-2.0A136Claude Code
setup-ciurmzd/dotfilesSkill64d agoApache-2.0A119Claude Code
landurmzd/dotfilesSkill64d agoApache-2.0A168Claude Code
prurmzd/dotfilesSkill64d agoApache-2.0A161Claude Code
work-statusurmzd/dotfilesSkill64d agoApache-2.0A187Claude Code