Split a large commit into multiple smaller, atomic commits. Target commit
defaults to HEAD if not specified.
-
Identify the target commit. If $ARGUMENTS is provided, use it.
Otherwise default to HEAD.
-
Analyze the commit to understand what it contains:
git show --stat <commit>
git show <commit>
Read the full diff. Identify logical groups following the ordering in
references/philosophy.md:
- Refactoring / cleanup (should be first)
- Type definitions / interfaces / schemas
- Core logic changes
- Edge cases / error handling
- Tests
Documentation belongs with the feature it documents, not as a separate
split. Dependencies and config files go in the commit that first uses them.
-
Propose a split plan to the user. For each proposed commit:
- One-sentence description
- Which files/hunks belong to it
- Why it's a separate concern
Wait for user approval before proceeding.
-
Perform the split using interactive rebase:
git rebase -i <commit>^
Mark the target commit as edit, then:
git reset HEAD^
This unwinds the commit but keeps all changes in the working tree.
-
Stage and commit each group in the agreed order:
git add -p
git commit -m "descriptive message for this group"
Repeat for each logical group. Each commit must:
- Be describable in one sentence
- Leave the codebase in a working state
- Target 50-200 lines
-
Complete the rebase:
git rebase --continue
-
Restack if there are downstream commits:
git restack
-
Verify the result:
git sl
Show the user the new stack. If a test command is available, run tests
across the new commits:
git test run -x '<test-command>' 'stack()'