agentleFS
TyrannicAweTyrannicAwe/claude-skills-pack/skills/git-surgery/SKILL.md

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

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
  1. Distinctive:

    NEVER rewrite history without a dry run first.

    line 13
  2. Distinctive:

    NEVER use git push --force unless the user explicitly types the command themselves.

    line 14
  3. Distinctive:

    Always operate on a clean tree: git status --porcelain must be empty (or stash first).

    line 15
  4. Distinctive:

    After any rewrite, verify: git log --oneline -5 and git status.

    line 17
  5. Very specific:

    Commit each chunk with a focused message: git commit -m "...".

    line 25
  6. Distinctive:

    When done: git rebase --continue or git status to confirm clean.

    line 26
  7. Distinctive:

    Verify the final log reads cleanly.

    line 27

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

  1. NEVER rewrite history without a dry run first.
  2. NEVER use git push --force unless the user explicitly types the command themselves.
  3. Always operate on a clean tree: git status --porcelain must be empty (or stash first).
  4. Record the current HEAD before any operation: git rev-parse HEAD — note it for the user.
  5. After any rewrite, verify: git log --oneline -5 and git status.

Common operations

Split a commit

  1. git log --oneline -10 — identify the commit to split.
  2. git rebase -i <commit>^ and mark the commit as edit (or run git reset --soft <commit>^).
  3. Stage changes in logical chunks: git add -p <file> or git add <files>.
  4. Commit each chunk with a focused message: git commit -m "...".
  5. When done: git rebase --continue or git status to confirm clean.
  6. Verify the final log reads cleanly.

Undo an unpushed commit (soft reset)

  • git reset --soft HEAD~1 keeps changes staged; git reset --mixed HEAD~1 keeps them unstaged. Confirm intent first: does the user want to keep the changes?

Cherry-pick

  1. git log --oneline --all | head -20 to find the target commit.
  2. git cherry-pick <sha> — expect conflicts; resolve with git status and git add, then git cherry-pick --continue.
  3. 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

  1. git rebase -i HEAD~N — set all but the first to squash.
  2. Preserve the first commit message as the summary; keep the body informative.

Conflict resolution protocol

  1. git status to enumerate conflicts.
  2. For each conflicted file: show both sides (git diff --cc <file> or open it).
  3. Resolve deliberately — ask the user when semantics are ambiguous.
  4. git add each 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

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.