| name | description | argument-hint | user-invocable | |
|---|---|---|---|---|
prepare-review |
Break up branch changes into smaller, logically-grouped commits for easier code review |
|
true |
Break up the changes on the current branch into smaller, logically-grouped commits for easier code review.
$ARGUMENTS- The base branch/commit to compare against (defaults tomain)
Enter plan mode and analyze the changes:
-
Determine base reference:
- If
$ARGUMENTSprovided, use it as base - Otherwise default to
main(ormasterif main doesn't exist) - Store the current HEAD SHA for later verification
- If
-
Get diff info:
git diff <base>...HEAD --stat- files changedgit log <base>..HEAD --oneline- existing commits (if any)git diff <base>...HEAD- full diff
-
Analyze the changes to identify logical groupings based on:
- Functional cohesion: Related functionality together
- Refactoring vs features: Separate refactoring from new features
- Tests: Keep with code they test, or separate if the test changes are large
- Infrastructure: Config, dependencies, build changes in own commits
- Error handling: Often can be its own commit
-
Write a plan proposing N commits (where N is appropriate - could be 2-10+):
- Each commit needs: title, files/hunks, bullet points of changes
- Order commits so each one compiles/works independently if possible
-
Exit plan mode and wait for user approval
Once approved, execute the restructuring:
-
Setup:
# Save current state ORIGINAL_HEAD=$(git rev-parse HEAD) CURRENT_BRANCH=$(git branch --show-current) # Create new branch and reset to base git checkout -b ${CURRENT_BRANCH}-review git reset --soft <base> git restore --staged .
-
For each commit in the plan:
- Stage files with
git add <file>for whole files - Use
git add -p <file>with stdin for partial staging (hunks) - Run project formatter if detected (cargo fmt, prettier, black, etc.)
- Create commit with descriptive message and Co-Authored-By trailer
- Stage files with
-
Verification:
git diff $ORIGINAL_HEADshould show no differences (trees match)- Run
<formatter> --checkif applicable - Show
git log --oneline <base>..HEADof new commits
Good commit boundaries:
- Import/dependency changes
- Type/interface definitions
- Implementation of a single function/method
- Test additions for specific functionality
- Documentation updates
- Renaming/refactoring (no behavior change)
- Bug fixes (separate from features)
Avoid:
- Mixing unrelated changes
- Splitting a single logical change across commits
- Commits that don't compile/pass tests independently
# Compare against main (default)
/prepare-review
# Compare against specific branch
/prepare-review origin/develop
# Compare against specific commit
/prepare-review abc123For a branch with 15 changed files (auth + logging changes) vs main:
- Add logging infrastructure (3 files)
- Refactor auth types (2 files)
- Implement OAuth flow (5 files)
- Add auth middleware (3 files)
- Add auth tests (2 files)