rework-commits
Skill1 starsChanged 4 months agoMITView on GitHub
Explicit-invocation workflow for safely reorganizing completed branch work into small, dependency-ordered, semantic Git commits, proving the rewritten tree matches the original result, and optionally pushing the polished history. Use only when the user directly invokes the rework-commits skill.
- Deletes or force-pushes
- Commits and pushes
In this repository3 other files it gives its agents.
- debug-with-evidenceSkill
- lock-tests-firstSkill
- review-changesSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
19 rules. About 0 are common, 15 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈15
Distinctive · estimate
This author's own choices. Worth a look.
4
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 a default, protected, or shared branch.
- Distinctive: line 14
Never use git reset --hard, plain git push --force, or automatic stashing.
- Distinctive: line 15
Never include unrelated user changes, secrets, generated artifacts, or ignored files in a commit.
- Very specific: line 16
Prefer non-interactive Git commands.
- Distinctive: line 17
Treat an explicit request to rework commits as authorization to rewrite local feature-branch history after creating the recovery point.
- Distinctive: line 22
Read applicable repository instructions.
- Distinctive: line 24
Stop on the default branch or during a merge, rebase, cherry-pick, or bisect.
- Distinctive: line 27
If the worktree is dirty, do not stash or stage everything automatically.
- Very specific: line 31
Create a uniquely named local backup branch under backup/rework-commits-...
- Distinctive: line 32
Keep the backup until the rewritten branch is verified and any requested push succeeds.
- Distinctive: line 34
Use the user-specified base when provided.
- Distinctive: line 40
Keep refactors separate from behavior changes unless separation would make either commit invalid.
- Distinctive: line 42
Ensure each proposed commit leaves the repository coherent and is small enough to review independently.
- Distinctive: line 48
Run focused verification for the commit when feasible before continuing.
- Distinctive: line 53
If validation fails, stop and restore or offer recovery from the backup branch rather than improvising.
- Distinctive: line 56
If published history was rewritten, explain the impact and obtain confirmation immediately before using git push --force-with-lease.
- Very specific: line 57
Never force-push a shared branch or use plain --force.
- Distinctive: line 59
Keep the backup branch until push verification succeeds.
- Very specific: line 60
Use the review-changes skill to run the final review and generate reviewer questions and pull-request context from the polished history.
≈ “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
Rework Commits
Optimize history for human review without changing the final code. Preserve a recovery path before rewriting anything.
Safety Rules
- Never rewrite a default, protected, or shared branch.
- Never use
git reset --hard, plaingit push --force, or automatic stashing. - Never include unrelated user changes, secrets, generated artifacts, or ignored files in a commit.
- Prefer non-interactive Git commands. Set
GIT_EDITOR=trueonly for commands that could otherwise open an editor. - Treat an explicit request to rework commits as authorization to rewrite local feature-branch history after creating the recovery point. Always obtain confirmation immediately before force-pushing previously published history.
Workflow
- Inspect repository state.
- Read applicable repository instructions.
- Identify the current branch, default branch, upstream, merge base, worktree status, in-progress Git operations, and commits unique to the branch.
- Stop on the default branch or during a merge, rebase, cherry-pick, or bisect.
- Require a clean, complete snapshot.
- Inventory staged, unstaged, and untracked files.
- If the worktree is dirty, do not stash or stage everything automatically. Ask the user to finish or scope the changes, or obtain approval for a temporary WIP snapshot containing explicitly listed in-scope files.
- Continue only when the intended final result is represented by a clean
HEAD.
- Establish the recovery point.
- Record the original branch name, commit hash, and tree hash.
- Create a uniquely named local backup branch under
backup/rework-commits-...pointing to the original tip and report its name. - Keep the backup until the rewritten branch is verified and any requested push succeeds.
- Determine the exact rewrite scope.
- Use the user-specified base when provided; otherwise derive the repository's default branch and merge base.
- Inspect the complete base-to-tip diff and every branch commit before planning.
- Exclude pre-existing upstream work and unrelated changes.
- Plan semantic commits before resetting.
- Give each commit one reviewable purpose and explain why it exists.
- Order prerequisites before dependents: schema and configuration, domain or backend behavior, API or integration, UI, then documentation or cleanup when applicable.
- Keep refactors separate from behavior changes unless separation would make either commit invalid.
- Pair tests with the behavior they verify, except for an intentionally protected test-first contract commit.
- Ensure each proposed commit leaves the repository coherent and is small enough to review independently.
- Rebuild the branch.
- Show the proposed commit sequence before rewriting.
- Reset the feature branch to the merge base with a non-destructive mixed reset so the final tree remains in the worktree.
- Stage explicit paths or hunks for one planned commit at a time; never use
git add .as a shortcut. - Inspect the staged diff, confirm it contains exactly one concern, then commit with a descriptive message that explains intent.
- Run focused verification for the commit when feasible before continuing.
- Prove content preservation.
- Confirm the worktree is clean.
- Compare the rewritten
HEADwith the original tip and require an empty diff; compare tree hashes when possible. - Review the new log and base-to-head diff to confirm every original change appears exactly once and no new content was introduced.
- If validation fails, stop and restore or offer recovery from the backup branch rather than improvising.
- Push only when requested.
- For an unpublished branch, push normally and set the upstream.
- If published history was rewritten, explain the impact and obtain confirmation immediately before using
git push --force-with-lease. - Never force-push a shared branch or use plain
--force.
- Finish the handoff.
- Keep the backup branch until push verification succeeds; remove it only with user approval.
- Use the
review-changesskill to run the final review and generate reviewer questions and pull-request context from the polished history.
Output
Report the merge base, recovery branch and original hash, final commit sequence, verification run per commit, proof that the final tree is unchanged, push status, and exact recovery instructions if anything failed.
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.

