git-surgery
Skill0 starsChanged 3 months agoMITView on GitHub
Safe interactive Git history operations — split commits, squash, rebase, cherry-pick, revert — with mandatory dry-run safety gates before any rewrite
- Deletes or force-pushes
- Commits and pushes
In this repository2 other files it gives its agents.
- api-debuggerSkill
- test-doctorSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 6 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
1
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 13
NEVER rewrite history without a dry run first.
- Distinctive: line 14
NEVER use git push --force unless the user explicitly types the command themselves.
- Distinctive: line 15
Always operate on a clean tree: git status --porcelain must be empty (or stash first).
- Distinctive: line 17
After any rewrite, verify: git log --oneline -5 and git status.
- Very specific: line 25
Commit each chunk with a focused message: git commit -m "...".
- Distinctive: line 26
When done: git rebase --continue or git status to confirm clean.
- Distinctive: line 27
Verify the final log reads cleanly.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 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 Surgery
Perform git history operations safely. Every history rewrite must be planned, dry-run first, and executed only after explicit user approval.
Core rules
- NEVER rewrite history without a dry run first.
- NEVER use
git push --forceunless the user explicitly types the command themselves. - Always operate on a clean tree:
git status --porcelainmust be empty (or stash first). - Record the current HEAD before any operation:
git rev-parse HEAD— note it for the user. - After any rewrite, verify:
git log --oneline -5andgit status.
Common operations
Split a commit
git log --oneline -10— identify the commit to split.git rebase -i <commit>^and mark the commit asedit(or rungit reset --soft <commit>^).- Stage changes in logical chunks:
git add -p <file>orgit add <files>. - Commit each chunk with a focused message:
git commit -m "...". - When done:
git rebase --continueorgit statusto confirm clean. - Verify the final log reads cleanly.
Undo an unpushed commit (soft reset)
git reset --soft HEAD~1keeps changes staged;git reset --mixed HEAD~1keeps them unstaged. Confirm intent first: does the user want to keep the changes?
Cherry-pick
git log --oneline --all | head -20to find the target commit.git cherry-pick <sha>— expect conflicts; resolve withgit statusandgit add, thengit cherry-pick --continue.- To abort:
git cherry-pick --abort.
Revert (safe for pushed history)
git revert <sha>creates an inverse commit — the ONLY safe way to undo pushed history.
Squash last N commits
git rebase -i HEAD~N— set all but the first tosquash.- Preserve the first commit message as the summary; keep the body informative.
Conflict resolution protocol
git statusto enumerate conflicts.- For each conflicted file: show both sides (
git diff --cc <file>or open it). - Resolve deliberately — ask the user when semantics are ambiguous.
git addeach resolved file, then finish the operation.
Safety checklist (run before every rewrite)
- Working tree clean (or stashed)
- HEAD recorded
- Dry-run/plan shown to user
- User approved the exact commands
- No force-push unless user typed it themselves
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.

