git-rescue
Skill0 starsChanged 4 months agoMITView on GitHub
Recover work that looks lost in git — after a bad `reset --hard`, a botched rebase or merge, a commit on the wrong branch, a deleted branch, a lost stash, commits orphaned in detached HEAD, or a force-push that overwrote history. Use this the moment the user says anything like "I lost my changes", "my commits are gone", "I reset and now it's empty", "the rebase destroyed everything", "I committed to main by accident", or "someone force-pushed over my work". Also use it BEFORE running any recovery command the user suggests themselves — panicked users propose destructive fixes.
- Deletes or force-pushes
2 other projects use a version of this.
Adopted by
Most recently taken up by
- chrisselig/claude-code-toolkittheir own version, first seen Oct 9, 2026
- 2867203296/hermes-agenttheir own version, first seen Aug 19, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- chrisselig/claude-code-toolkit★ 1same name
- 2867203296/hermes-agent★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository46 other files it gives its agents.
- atomic-ioSkill
- backfill-pilotSkill
- backpressure-guardSkill
- blast-guardSkill
- changelogSkill
- cipher-guardSkill
- clipboard-guardSkill
- clock-sweepSkill
- codebase-tourSkill
- consent-guardSkill
- devlogSkill
- dormancy-guardSkill
- env-detectiveSkill
- erasure-guardSkill
- export-guardSkill
- failover-guardSkill
- import-guardSkill
- job-wardenSkill
- migration-guardSkill
- overwrite-guardSkill
- pagination-guardSkill
- portability-auditSkill
- pref-guardSkill
- proration-guardSkill
- push-guardSkill
- quote-guardSkill
- reaccept-guardSkill
- readme-forgeSkill
- recall-guardSkill
- residency-guardSkill
- restore-guardSkill
- resync-guardSkill
- rollout-guardSkill
- rotation-guardSkill
- seat-guardSkill
- secret-spillSkill
- security-sweepSkill
- selectall-guardSkill
- ship-itSkill
- skew-checkSkill
- stale-guardSkill
- storm-guardSkill
- sunset-guardSkill
- throttle-guardSkill
- tombstoneSkill
- trail-guardSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 12
Before ANY recovery action, snapshot the current state so your rescue can't cause a second accident:
- Very specific: line 23
Ask (or determine from the transcript) what the last few commands were — history | tail or the user's memory.
- Very specific: line 29
Uncommitted work is the hard case: Never-staged changes wiped by checkout -- ./reset --hard are genuinely unrecoverable from git — say so …
- Very specific: line 51
If gc has run and the object is truly gone, say that plainly and pivot to editor history / remote copies / CI artifacts.
- Distinctive: line 52
Never force-push during a rescue unless the user explicitly asks to restore a remote branch, and confirm the exact sha with them first.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
git-rescue
Someone who thinks they just lost hours of work is panicking, and panicked people (and agents) make it worse by running more destructive commands. Your job is the calm paramedic: secure the scene, then diagnose, then recover. Almost nothing in git is actually gone — committed work survives reset --hard, rebases, branch deletion, and force-pushes for weeks, because git only unlinks objects, it doesn't erase them until garbage collection (default grace: 2+ weeks).
Rule zero: make things recoverable before you recover
Before ANY recovery action, snapshot the current state so your rescue can't cause a second accident:
git branch rescue-backup-$(date +%s) # pin current HEAD (if there are commits worth pinning)
git stash push -u -m "rescue: working tree" # if the working tree has uncommitted changes worth keepingAnd while rescuing, never run reset --hard, checkout -- ., clean, rebase, or push --force until you have positively located the lost work and stated where it is. One destructive command at a time, each one explained first.
Diagnose: find where the work actually is
Ask (or determine from the transcript) what the last few commands were — history | tail or the user's memory. Then look, in order:
git reflog— the flight recorder. Every position HEAD has held in this clone, even through resets and rebases.git reflog show <branch>for a specific branch. The lost commit is almost always here.git stash list— work people forgot they stashed, or that a tool auto-stashed (rebase --autostash!).git fsck --lost-found— dangling commits and blobs that no ref or reflog entry points to anymore (e.g. after a deleted branch whose reflog went with it). Inspect candidates withgit show <sha>.- The remote — if it was ever pushed,
git fetchand checkorigin/<branch>. For a force-push that overwrote a remote branch: the old tip is still in the pusher's reflog, and on GitHub it survives in the events API (gh api repos/OWNER/REPO/eventsshows thebeforesha of the push) and asgit fetch origin <old-sha>often still works. - Uncommitted work is the hard case. Never-staged changes wiped by
checkout -- ./reset --hardare genuinely unrecoverable from git — say so honestly, then check editor local history (VS Code Timeline, JetBrains Local History), which frequently saves the day.
Identify the exact sha(s) of the lost work and show the user the evidence (git log --oneline -3 <sha>, git show --stat <sha>) before touching anything.
Recover: smallest safe operation that gets it back
- Lost commits after reset/rebase:
git branch recovered <sha>— pin them to a name first, decide how to integrate second (merge/cherry-pick/reset). Pinning is zero-risk. - Botched rebase/merge:
git reset --hard <pre-rebase-sha from reflog>— only after the backup branch exists.ORIG_HEADusually points there too. - Committed on the wrong branch: pin the commit,
git checkout right-branch && git cherry-pick <sha>, then move the wrong branch back:git checkout wrong-branch && git reset --keep HEAD~1(--keep, not--hard— it refuses rather than eats uncommitted changes). - Deleted branch:
git branch <name> <sha>from reflog/fsck. - Dropped stash:
git fsck --unreachable | grep commit, inspect,git stash apply <sha>. - Detached HEAD commits:
git branch recovered <sha from reflog>.
Confirm, then clean up
Prove the rescue worked — show the recovered diff or run the tests — before deleting any rescue-backup-* branch. Leave the backups in place if there is any doubt; a stray branch costs nothing, a second loss costs trust.
Close with one sentence on prevention only if it's specific to what happened (e.g. "git reset --keep refuses instead of destroying next time"). No lectures — they just had a bad day.
Boundaries
- Reflog is per-clone: it can't see commits made on another machine or CI. Say so instead of implying everything is always recoverable.
- If
gchas run and the object is truly gone, say that plainly and pivot to editor history / remote copies / CI artifacts. - Never force-push during a rescue unless the user explicitly asks to restore a remote branch, and confirm the exact sha with them first.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

