Skip to content

commandGit and releases

Fixup Commits

Matches staged review fixes to the commits they belong to, creates fixup commits and autosquashes once you approve.

npx workspacetemplates add fixup-commits --tool claude-code

Writes 1 file to .claude/commands/

.claude/commands/fixup-commits.md15 lines · 1.2 KBFile
---
description: Matches staged review fixes to the commits they belong to, creates fixup commits and autosquashes once you approve.
argument-hint: "[base branch, default main]"
---

Turn the staged changes into fixup commits for the branch. Base branch: $ARGUMENTS (use main if empty).

1. Run `git status --short` and `git diff --staged`. If nothing is staged, stop. Never stage files yourself.
2. List the branch commits with `git log --oneline <base>..HEAD`. Stop if HEAD is on the base branch itself.
3. For each staged hunk, run `git blame -L <range> <base>..HEAD -- <file>` on the original lines and note which branch commit last touched them. A hunk touching only new lines of one commit maps to that commit.
4. Show a table: hunk, file, target commit hash and subject, confidence. Mark hunks with no clear owner as "unmatched" and leave them staged.
5. Ask: "Create these fixups?" After a yes, split the index per target and run `git commit --fixup <hash>` for each.
6. Check whether the branch was pushed with `git status -sb`. If it was, warn that autosquash rewrites history and ask again.

Then show `git log --oneline` and ask before running `git rebase -i --autosquash <base>` with GIT_SEQUENCE_EDITOR=true. Never force push.

What it does

Review feedback usually lands as a pile of "address comments" commits that nobody wants in main. This command looks at your staged hunks, finds the earlier commit on your branch that last touched the same lines and prepares a fixup for each.

Nothing is rewritten until you read the plan. The final autosquash happens only after a yes, and it refuses to touch commits that were already pushed to a shared branch.

Example

you › /fixup-commits main

agent › 3 hunks staged. src/cart.ts hunk -> a41c9e2 "Add cart totals" (high). README.md hunk -> 7d02b11 "Document env vars" (high). tests/cart.test.ts hunk -> unmatched. Create these fixups?

Questions

Does it rewrite history right away?
No. It first creates plain fixup commits you can inspect, and the rebase waits for a second confirmation.
What happens to a hunk it cannot place?
It stays staged and is listed as unmatched, so you decide whether it deserves its own commit.
  • Branch Cleanup

    CommandGit and releases

    Free
  • Changelog Entry

    CommandGit and releases

    Free
  • Cherry Pick Fix

    CommandGit and releases

    Free
  • Commit Message

    CommandGit and releases

    Free