agentleFS
himanshi-28himanshi-28/coding-agent-skills/skills/rework-commits/SKILL.md

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

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

    Never rewrite a default, protected, or shared branch.

    line 13
  2. Distinctive:

    Never use git reset --hard, plain git push --force, or automatic stashing.

    line 14
  3. Distinctive:

    Never include unrelated user changes, secrets, generated artifacts, or ignored files in a commit.

    line 15
  4. Very specific:

    Prefer non-interactive Git commands.

    line 16
  5. Distinctive:

    Treat an explicit request to rework commits as authorization to rewrite local feature-branch history after creating the recovery point.

    line 17
  6. Distinctive:

    Read applicable repository instructions.

    line 22
  7. Distinctive:

    Stop on the default branch or during a merge, rebase, cherry-pick, or bisect.

    line 24
  8. Distinctive:

    If the worktree is dirty, do not stash or stage everything automatically.

    line 27
  9. Very specific:

    Create a uniquely named local backup branch under backup/rework-commits-...

    line 31
  10. Distinctive:

    Keep the backup until the rewritten branch is verified and any requested push succeeds.

    line 32
  11. Distinctive:

    Use the user-specified base when provided.

    line 34
  12. Distinctive:

    Keep refactors separate from behavior changes unless separation would make either commit invalid.

    line 40
  13. Distinctive:

    Ensure each proposed commit leaves the repository coherent and is small enough to review independently.

    line 42
  14. Distinctive:

    Run focused verification for the commit when feasible before continuing.

    line 48
  15. Distinctive:

    If validation fails, stop and restore or offer recovery from the backup branch rather than improvising.

    line 53
  16. Distinctive:

    If published history was rewritten, explain the impact and obtain confirmation immediately before using git push --force-with-lease.

    line 56
  17. Very specific:

    Never force-push a shared branch or use plain --force.

    line 57
  18. Distinctive:

    Keep the backup branch until push verification succeeds.

    line 59
  19. Very specific:

    Use the review-changes skill to run the final review and generate reviewer questions and pull-request context from the polished history.

    line 60

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

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

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, plain git 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=true only 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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. Prove content preservation.
    • Confirm the worktree is clean.
    • Compare the rewritten HEAD with 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.
  8. 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.
  9. Finish the handoff.
    • Keep the backup branch until push verification succeeds; remove it only with user approval.
    • Use the review-changes skill 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.

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.