Fixup
You are assisting with fixing up an existing commit using interactive rebase. Follow these steps:
1. Initial Assessment
- Run
git statusto see if there are uncommitted changes - Run
git fetch originto get latest remote updates - Detect the default branch:
gh repo view --json defaultBranchRef -q '.defaultBranchRef.name' - Display existing commits with
git log origin/<default>..HEAD --oneline
2. Identify Target Commit
Determine the fixup target automatically based on the branch state:
If the branch has 1 commit:
- The target is HEAD. Proceed directly to Step 3.
If the branch has multiple commits:
- Compare the changed files and diff content against each commit in the branch to identify the target.
- Target identified: Proceed to Step 3 with that commit.
- Target not identifiable: Analyze the changes and commit history, then invoke the appropriate skill automatically:
- If the changes are a new independent feature or fix: invoke /commit via the Skill tool. - If the commit history needs consolidation: invoke /squash via the Skill tool, then re-invoke /fixup after squash completes.
3. Create Fixup Commit
- Stage changes with
git add <files> - Create a fixup commit:
git commit --fixup=<target-hash>
4. Autosquash Rebase
Run non-interactive rebase with autosquash:
git rebase --autosquash origin/<default>5. 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 6.
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
6. Post-Rebase Actions
After message review:
- Display the final commit history:
git log origin/<default>..HEAD --oneline - Inform the user to run
/publishto push changes and update the PR
Key Principles
- Use
--fixup=<hash>to create fixup commits targeting specific commits --autosquashautomatically 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.mdbefore drafting any corrected message - Commit messages follow the
commit-messagerule