git-safety-net
Audits, preserves and recovers local Git state before cleanup: unpushed or wrong-branch commits, dirty worktrees, duplicate clones, stashes, dangling commits, squash-merge uncertainty
Install / Use
npx skills add daymade/claude-code-skills --skill git-safety-netInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
Development & EngineeringSupported Platforms
Our assessment of git-safety-net
git-safety-net scores 84/100 on our quality scale, 2896th of 4,698 Development & Engineering skills we index.
Its SKILL.md is 65 KB long, well organised into 16 sections with 10 code examples: long enough that it reads more like full documentation than a focused instruction file, which agents can find harder to follow.
With 1,426 GitHub stars, it is one of the more widely adopted skills in the catalogue.
Maintenance, license and trust
- The repository was last updated about 2 months ago, so git-safety-net is actively maintained.
- Our last check on 2026-10-14 found the source still online.
- It is released under the MIT license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit β read the skill file before letting an agent act on it.
Safety scan
No issues foundOur scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful.
AI review by kimi-k2.7-code on 2026-10-03. Automated pattern scan on 2026-10-03. It catches known dangerous patterns, not every risk β read a skill before letting an agent act on it.
git-safety-net compared with similar skills
All 4 of these similar skills score higher than git-safety-net; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| git-safety-net (this skill)by daymade | 84 | 1.4k | 53d ago | SKILL.md |
| taste-skillby Leonxlnx | 100 | 116.8k | 8d ago | CLAUDE.md |
| Agent-Reachby Panniantong | 100 | 112.3k | 8d ago | CLAUDE.md |
| ai-job-searchby ai-job-search-dev | 100 | 72.1k | today | CLAUDE.md |
| claude-howtoby luongnv89 | 100 | 47.3k | 2d ago | CLAUDE.md |
Frequently asked questions
- How do I install git-safety-net?
- Run
npx skills add daymade/claude-code-skills --skill git-safety-net. The install tabs above show the steps for each supported agent. - Which AI agents does git-safety-net work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is git-safety-net safe to use?
- Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful. It is MIT-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is git-safety-net still maintained?
- The repository was last updated about 2 months ago, so git-safety-net is actively maintained.
Skill content
View source on GitHubname: git-safety-net description: >- Audits, preserves and recovers local Git state before cleanup: unpushed or wrong-branch commits, dirty worktrees, duplicate clones, stashes, dangling commits, squash-merge uncertainty. Use when the user fears lost work, wants to recover a commit, asks if a branch is actually merged, asks whether a branch, worktree or clone is safe to delete, or wants one clean main (θ――ε εζ― / θΏζ沑ζδΈ’ηδΈθ₯Ώ). Not for GitHub PR operations.
Git Safety Net
Prevent losing work in a tangle of branches/stashes/rebases, and recover it forensically when something already went sideways. The commands here are all non-destructive or additive until a step is explicitly labeled destructive β recovery must never make the loss worse.
Outcome contract β keep the safety net subordinate to the user's job
Before Mode B/E or any command that writes a ref or backup, state the following in the conversation (do not create another file):
- Outcome: the user-visible end state, in the user's words.
- Current phase: what is authorized now. "Later" work is not authorized in this phase.
- Authorized targets: named objects this phase may inspect, plus the subset it may change.
- Stop condition: observable facts that end the task.
Then enforce these boundaries:
- Evidence scope is not action scope. A read-only audit may discover another clone, ref, repository, or dangling object. That discovery may widen the report; it does not authorize preserving, uploading, merging, deleting, or otherwise changing the newly found object.
- Authorization is object-specific, not repository-wide by implication. "Take over", "continue", or "finish the cleanup" applies only to the checkout/ref/PR the user identified. A collaborator-owned worktree, branch, or PR discovered later stays report-only until the user names it as a change target. If the user says to leave it alone, record that exclusion and do not inspect its working-tree contents, back it up, merge it, unlock/remove it, or mutate its refs.
- Preserve the smallest set threatened by the next authorized destructive action. If the current phase is only commit/push/verify and no deletion, reset, gc, history rewrite, or worktree removal is authorized, do not create an all-refs bundle or pin every dangler.
- Classify an artifact before choosing its transport. Durable project source follows the repository's normal Git/LFS policy. A temporary recovery artifact (bundle, working-tree diff, snapshot, transport chunk) belongs in a repository-external backup directory. Do not stage, commit, push, or route it through Git LFS merely to make the backup remote; Git LFS is for durable versioned project binaries, not a fallback transport for temporary recovery material.
- Keep preservation and retirement as separate phases. A verified recovery artifact proves recoverability; it does not prove the business code landed. Keep it through the destructive action and the content-level postconditions. Retire an exact task-owned temporary artifact only when every payload is landed or proven superseded and the artifact itself has explicit cleanup authorization. Keep backup-only, unresolved, and mixed artifacts.
- Treat a new storage or execution surface as a scope change. A second repository, new remote, cloud upload, Git LFS, or full-history export requires re-planning and explicit authority when the stated outcome actually depends on it. Do not solve a transport problem the user did not ask to create.
- Prove completion in the user's world. A remote containing the intended commit, preserved WIP, and the requested branch/worktree state are outcomes. Bundle counts, checksums, upload receipts, and audit breadth are supporting evidence, never substitutes for that outcome. Stop when the contract is satisfied; record unrelated findings separately without acting on them.
Entry router β pick the mode from what the user is worried about
| The user says / needsβ¦ | Go to | |---|---| | "I think I lost a commit / branch / stash", "recover the deleted X", "git reflog" | Mode A β Recover | | "did I lose anything?", "what worktrees/stashes/branches remain?", after a messy session | Mode B β Audit & preserve | | "is everything merged?", "what's still not on main?", before deleting old branches | Mode C β Verify merged | | "so this never happens again", starting parallel/multi-branch work | Mode D β Prevent | | "clean up worktrees/stashes/branches", "converge everything onto main", "only keep one main branch" | Mode E β Retire safely | | "an audit already said it's clean, but is anything else lost?", "check again" | Mode B, starting at Step 0 β a repeat request usually means the first pass had the wrong scope, not that it looked carelessly |
When in doubt, run the smallest read-only probe that selects a mode. Use Mode B Step 0's machine-wide discovery only when the outcome is an exhaustive loss audit or the target checkout is unknown. A named repository/branch/worktree task stays named; findings outside that target are report-only until the user expands the authorized targets.
Load-bearing rules (internalize these; the modes apply them)
- Get the EVIDENCE SCOPE right before you trust any verdict, without silently expanding the
work scope: every instrument here only sees the repository it runs in.
git worktree list,git branch -a,git fsck,git stash list,git log --not --remotesβ all of them are structurally blind to an independent clone of the same repository elsewhere on the machine. A linked worktree (git worktree add) has a gitlink file pointing home, so it shows up; a secondgit clonehas its own complete.gitand no back-reference, so it shows up in nothing. Rungit_find_all_checkouts.shfirst only for an exhaustive audit or unknown target; otherwise audit the named target. Real incident: a repository audited clean, every branch pushed, while 440 lines of a working feature sat as untracked files in a sibling clone onerm -rffrom gone. Scope has a second axis: TIME. Everyorigin/*ref is a cached snapshot from your last fetch, not the remote β sogit fetch --all --prunebefore you trust any verdict that depends on one. Read a stale cache in the right direction: for "what would be lost" it errs safe (it can over-report unpushed work, never hide it), which is why the scripts here still run offline. For "is this already upstream?" it fails the other way β work the remote already has reads as unique, so you re-ship it, and if the remote improved it meanwhile your "restore" silently reverts those improvements while looking like a rescue. Real incident: a comparison base one day old made an already-merged change look unshipped; the rescue PR would have reverted three fixes a later review added on top, one of them a security fix. Scope has a third axis: the REF SET itself moves. A branch inventory and a verified bundle prove what existed at one instant; they do not authorize deletion five minutes later. Immediately before deleting, re-enumerate local refs and hosting-service branches, then require every target ref to still equal the object recorded in the bundle. A new branch, a moved tip, or a new parallel PR reopens classification and requires a new bundle. Do not delete against a stale inventory. Scope has a fourth axis: OWNERSHIP. Repository visibility does not make every visible object part of this task. Partition discovered refs/worktrees/PRs into change-authorized, inspect-only, and explicitly excluded sets before acting; compute cleanup success over the authorized set. - Run
git_loss_audit.shfor the authoritative "what would be lost" check within a checkout. It compares the current HEAD, every linked-worktree HEAD, local branches, and tags against every remote, then inspects each worktree for tracked/untracked changes plus stashes and dangling commits. The shortergit log HEAD --branches --tags --not --remotesmisses a detached HEAD in a different worktree and all uncommitted files. Ahead/behind counts do not answer this. Run it in the named checkout, and in additional Step 0 checkouts only after each is explicitly change-authorized. Run this repository-wide script only when every surface it enumeratesβlinked worktrees, local refs/tags, stashes, and dangling commitsβis inside the declared evidence scope. It has no exclusion flags. Otherwise limit the claim to the authorized checkout/ref and use its ownstatus,HEAD, upstream/remote identity, andgit log HEAD --not --remotesas scoped evidence; report the other surfaces as not audited. git reflogis the first move for "I lost a commit," notfsck. Reflog records every HEAD position (commits, checkouts, resets, rebases) for ~90 days and the lost commit is usually in its top few lines.git fsckis the deeper net for commits reflog can't reach.- Preserve before you clean up β and know which backup tool can actually reach the work.
Pin at-risk/dangling commits somewhere garbage collection can't reach them before deleting a
branch, running
gc, or force-pushing. Cleanup is reversible only while a ref (or the reflog window) still points at the work. Critical asymmetry:bundle,archive, andformat-patchcan only reach objects git already knows about. An untracked file that was nevergit added and neverstash -ued is invisible to those formats β the copy on disk is the only copy, so preserving it means literally copying the file out. Backing up "the repository" and believing untracked work came along is how a clean-looking backup silently omits the only thing at risk. When the backup is a branch pushed into an already-existing repository rather than this one's own remote, verify shared history before the push (Mode B Step 2) β a similar name proves nothing. - Verify "merged" by CONTENT, never by commit count β and know that most content checks are
also unsound. After a squash-merge,
main..branchshows the branch's original commits as "unmerged" even though their content is on main β often 100+ phantom commits. But swapping counts for the nearest content check is not enough: in one audit, three successive "surely this is content-level now" instruments each returned a wrong answer βgit cherry(squash rewrites patch-ids β false UNMERGED), a three-dotdiff base...refused to ask "what does base lack" (three-dot answers a different question and under-reported missing files by 5Γ), and a file-level existence check (a file present on base can still be missing the ref's lines). Only the trial merge (git merge-tree, whatgit_verify_branch_merged.shruns) was right every time. Diff-form and rung-by-rung reliability: references/merge_verification.md. - For a high-stakes exhaustive "is everything merged?" call that will authorize deletion, verify adversarially. One independent reviewer is the default. Use multiple reviewers only when distinct repositories or evidence axes cannot be covered by one pass and the user has authorized that fan-out. Make one pass try to falsify the declared evidence scope (rule 1), but keep any newly found target report-only under the Outcome contract.
Mode A β Recover lost work
A commit/branch/stash that "disappeared" is almost always still in the object store for ~90 days β
why that is true, and what ends it, is references/recovery_playbook.md Β§ Mental model: nothing is gone
until gc runs. The ladder there is indexed by symptom, so go straight to your rung β
Β§ Ladder step 1 β git reflog (where most recoveries end),
Β§ Ladder step 2 β dropp
Truncated for display β read the full file on GitHub.
Related Skills
taste-skill
116.8kAgent skills that give coding agents taste: art direction, reference images and a browser check instead of generic AI pages
Agent-Reach
112.3kGive your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu β one CLI, zero API fees.
ai-job-search
72.1kThe job search that runs on your machine. AI job application framework built on Claude Code: evaluate postings, tailor CVs, write cover letters, prep interviews. Fork it and own it.
claude-howto
47.3kA visual, example-driven guide to Claude Code β from basic concepts to advanced agents, with copy-paste templates that bring immediate value.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit β see the Safety scan above for what the skill file itself contains.
