Split the current jj commit into multiple focused, self-contained, easy to
review commits.
Current commit
jj show --git
$ARGUMENTS
Principles
- One concern per commit: e.g. bug fix, feature, refactor, or config change
- Each commit passes all checks: format, lint, typecheck, build, test
- Tests go in the same commit as the code they test
- Never mix refactors with behavioral changes
- Prefer thin vertical slices, one complete feature end-to-end, over horizontal
layers
- No orphaned code: use every added API, abstraction, or stub within the same
commit. Don't split so small that a commit contains dead code
Workflow
- Read the diff above. If the commit is already small and self-contained, tell
the user and stop
- Identify logical groupings and order them from most foundational to most
dependent. When a boundary is ambiguous, keep changes together
- Infer verification commands from project signals (e.g.
package.json,
Makefile, CI config). If there are none, ask the user
- Present the plan as a numbered list:
- Commit N:
<imperative-mood description>: <file or hunk list>
- One sentence justifying each split boundary
- The verification commands you will run after each split
- Ask for confirmation
- Split each commit except the last. After each split, edit the newly created
parent commit (
jj edit @-) and run the verification commands
- Give every resulting commit a description with
jj describe
- After all splits, run
jj log -r 'ancestors(@, <commit count>)' and show the
resulting stack
How to split
By file
Use jj split with file patterns to put specific files in the first commit:
jj split -m "<first commit description>" -- <files for first commit>
The remaining files stay in the second commit.
By hunk
When a single file contains changes that belong in different commits, edit the
file directly:
- Edit the file to contain only the changes for the first commit (remove hunks
that belong later)
- Run
jj new to start the next commit
- Re-edit the file to restore the hunks removed in step 1
- Verify with
jj log -r '@-::@' and jj diff -r @-
Fixing mistakes
Use these when verification fails because changes are in the wrong commit.
Move files between child and parent commits
# Move from child to parent
jj squash --from @+ --into @ -- <files>
# Move from parent to child
jj squash --from @ --into @+ -- <files>
Move hunks between commits
When the boundary falls inside a file, edit the file directly:
- While on the commit that should lose the hunk, remove it from the file
- Switch to the other commit and restore the hunk there
- Verify both commits
1---2name: jj-split3description: Split the current `jj` commit into multiple focused, self-contained, easy to review commits.4---56Split the current `jj` commit into multiple focused, self-contained, easy to7review commits.89# Current commit1011```!12jj show --git13```1415$ARGUMENTS1617# Principles1819- One concern per commit: e.g. bug fix, feature, refactor, or config change20- Each commit passes all checks: format, lint, typecheck, build, test21- Tests go in the same commit as the code they test22- Never mix refactors with behavioral changes23- Prefer thin vertical slices, one complete feature end-to-end, over horizontal24 layers25- No orphaned code: use every added API, abstraction, or stub within the same26 commit. Don't split so small that a commit contains dead code2728# Workflow29301. Read the diff above. If the commit is already small and self-contained, tell31 the user and stop322. Identify logical groupings and order them from most foundational to most33 dependent. When a boundary is ambiguous, keep changes together343. Infer verification commands from project signals (e.g. `package.json`,35 `Makefile`, CI config). If there are none, ask the user364. Present the plan as a numbered list:37 - Commit N: `<imperative-mood description>: <file or hunk list>`38 - One sentence justifying each split boundary39 - The verification commands you will run after each split40 - Ask for confirmation415. Split each commit except the last. After each split, edit the newly created42 parent commit (`jj edit @-`) and run the verification commands436. Give every resulting commit a description with `jj describe`447. After all splits, run `jj log -r 'ancestors(@, <commit count>)'` and show the45 resulting stack4647# How to split4849## By file5051Use `jj split` with file patterns to put specific files in the first commit:5253```sh54jj split -m "<first commit description>" -- <files for first commit>55```5657The remaining files stay in the second commit.5859## By hunk6061When a single file contains changes that belong in different commits, edit the62file directly:63641. Edit the file to contain only the changes for the first commit (remove hunks65 that belong later)662. Run `jj new` to start the next commit673. Re-edit the file to restore the hunks removed in step 1684. Verify with `jj log -r '@-::@'` and `jj diff -r @-`6970# Fixing mistakes7172Use these when verification fails because changes are in the wrong commit.7374## Move files between child and parent commits7576```sh77# Move from child to parent78jj squash --from @+ --into @ -- <files>7980# Move from parent to child81jj squash --from @ --into @+ -- <files>82```8384## Move hunks between commits8586When the boundary falls inside a file, edit the file directly:87881. While on the commit that should lose the hunk, remove it from the file892. Switch to the other commit and restore the hunk there903. Verify both commits