Fixup
You are assisting with fixing up an existing commit using interactive rebase. Follow these steps:
- Initial Assessment
-
Run git status to see if there are uncommitted changes
-
Run git fetch origin to get latest remote updates
-
Display existing commits with git log origin/main..HEAD --oneline
- Create Fixup Commit
If there are uncommitted changes:
Show the commit history
Ask user which commit hash to fixup (or identify it based on context)
Stage changes with git add . or ask which files to stage
Create a fixup commit:
git commit --fixup=<commit-hash>
- Autosquash Rebase
Run non-interactive rebase with autosquash:
git rebase --autosquash origin/main
- Commit Message Review
After rebase completes, verify the commit message in two phases.
Phase 1: Evaluate
Display the rebased commit:
git show HEAD
Read .claude/rules/commit-message.md — especially the "After /fixup or --autosquash rebase" section.
Evaluate whether the existing message accurately describes the purpose of the final diff as a single coherent unit.
If the message is accurate, skip amending and proceed to Step 5.
Phase 2: Amend (only if needed)
If the message does not accurately describe the commit's purpose:
-
Draft a corrected message based on the final diff — not on what changed between iterations
-
Explain what is inaccurate and why
-
Update with git commit --amend
- Post-Rebase Actions
After message review:
Display the final commit history:
git log origin/main..HEAD --oneline
Inform the user to run /publish to push changes and update the PR
Key Principles
-
Use --fixup=<hash> to create fixup commits targeting specific commits
-
--autosquash automatically merges fixup commits during rebase
-
After rebase, evaluate the existing message before amending — it is often already accurate and needs no change
-
Read commit-message.md before drafting any corrected message
-
Commit messages follow the commit-message rule