git-safety

git-safety is a skill for Claude Code from latestaiagents/agent-skills. It costs 67 tokens per session (2,827 once invoked), scanned A, original, MIT.

A safety guide for Git operations that could lose commits or rewrite shared history. It covers force pushes, resets, rebases, cleaning files, and branch deletion.

In plain words
What is it for?
Use it before force-pushing, resetting, rebasing, cleaning, or deleting Git branches.
Why use it?
It helps prevent unpushed work or teammates' commits from being lost. It also encourages checking the current branch and saved work before risky commands.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: positional $N argument.

Part of the safety plugin — 5 skills shipped together , and of ai-safety-guardrails, latestaiagents

Good fit Use it before force-pushing, resetting, rebasing, cleaning, or deleting Git branches.

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

Made for: Claude Code.

Or install safety, the plugin that ships this one along with the rest of its 5 skills.

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-safety

README.md
[![agentmods](https://agentmods.dev/badge/skills/latestaiagents/agent-skills/git-safety.svg)](https://agentmods.dev/skills/latestaiagents/agent-skills/git-safety)
Your own site
<a href="https://agentmods.dev/skills/latestaiagents/agent-skills/git-safety"><img src="https://agentmods.dev/badge/skills/latestaiagents/agent-skills/git-safety.svg" alt="Measured on agentmods" height="20"></a>
Per session 67 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,827 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 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.00067 $0.02827
Opus 5 $0.00034 $0.01413
Sonnet 5 $0.00013 $0.00565
Haiku 4.5 $0.00007 $0.00283

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

Security

Grade A, and why

git-safety 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 3d 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.

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/safety/ai-safety-guardrails/git-safety/SKILL.md · 395 lines

How it starts

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

Git Safety

CRITICAL: Some Git operations can permanently lose work. This skill prevents commit loss.

Danger Levels

Level Operations Requires
⛔ CRITICAL push --force to shared branch, reset --hard with unpushed work Full verification + explicit confirmation
🔴 HIGH rebase on shared branches, clean -fd, checkout . Stash check + confirmation
🟠 MEDIUM reset --soft/mixed, stash drop, branch -D Verify branch state + confirm
🟢 LOW commit, push, pull, fetch, branch Standard execution

Pre-Operation Protocol

Before Force Push

⛔ **CRITICAL: FORCE PUSH REQUESTED**

**Command:** git push --force origin main

**⚠️ THIS REWRITES SHARED HISTORY**

**Current state:**
- Local branch: main
- Local HEAD: abc1234 "Add new feature"
- Remote HEAD: def5678 "Fix bug in login"

**Commits that will be OVERWRITTEN on remote:**
1. def5678 - "Fix bug in login" (by [email protected], 2 hours ago)
2. ghi9012 - "Update documentation" (by [email protected], 3 hours ago)

**These commits will be LOST if not saved elsewhere:**
- 2 commits by other team members
- Anyone who pulled these will have conflicts

**Safety checks:**
- [ ] Is this your personal branch? NO - this is main ⚠️
- [ ] Have you notified the team? Unknown
- [ ] Are the overwritten commits backed up? Unknown

**Safer alternatives:**
1. `git push --force-with-lease` (fails if remote changed)
2. Create a new branch for your changes
3. Merge instead of rebase
4. Coordinate with team first

**I strongly recommend against force pushing to main.**

If you must proceed, type: "yes, force push to main and overwrite 2 commits"

Before Reset --hard

⛔ **CRITICAL: HARD RESET REQUESTED**

**Command:** git reset --hard HEAD~3

**⚠️ THIS DISCARDS CHANGES PERMANENTLY**

**What will be LOST:**

**Commits to be removed (3):**
1. abc1234 - "Work in progress on feature X"
2. def5678 - "Add unit tests"
3. ghi9012 - "Fix styling issues"

**Uncommitted changes that will be LOST:**
- Modified: src/App.tsx (45 lines changed)
- Modified: src/utils/helper.ts (12 lines changed)
- Untracked: src/components/NewFeature.tsx (new file, 156 lines)

**Recovery options after reset:**
- Commits: Can recover via `git reflog` (within 90 days)
- Staged changes: Can recover via `git fsck --lost-found`
- Untracked files: PERMANENTLY LOST ⚠️

**Before reset, I will:**
1. Stash uncommitted changes: `git stash push -m "backup before reset"`
2. Create backup branch: `git branch backup-before-reset`
3. Note reflog position: HEAD is currently at abc1234

Proceed with backup and reset? Type "yes, reset after backup" to confirm.

Read the full file on GitHub · 395 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. 3d ago First seen · 395 lines · 67 tokens per session scan A bf3d19911c10

Subscribe to this mod's changes

git-safety is a skill published in the GitHub repository latestaiagents/agent-skills (5 stars, last pushed 4mo ago), licensed MIT. It adds 67 tokens to every session and 2,827 once invoked, about $0.0003 per session on Opus 5. 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-09-03.