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: |4 Split the current `jj` commit into multiple focused, self-contained, easy to5 review commits.6argument-hint: '[extra guidance on how to split]'7allowed-tools:8 - Bash(jj show *)9 - Bash(jj log *)10 - Bash(jj diff *)11 - Bash(jj describe *)12 - Bash(jj split *)13 - Bash(jj new *)14 - Bash(jj edit *)15 - Bash(jj describe *)16 - Bash(jj squash *)17---1819Split the current `jj` commit into multiple focused, self-contained, easy to20review commits.2122# Current commit2324```!25jj show --git26```2728$ARGUMENTS2930# Principles3132- One concern per commit: e.g. bug fix, feature, refactor, or config change33- Each commit passes all checks: format, lint, typecheck, build, test34- Tests go in the same commit as the code they test35- Never mix refactors with behavioral changes36- Prefer thin vertical slices, one complete feature end-to-end, over horizontal37 layers38- No orphaned code: use every added API, abstraction, or stub within the same39 commit. Don't split so small that a commit contains dead code4041# Workflow42431. Read the diff above. If the commit is already small and self-contained, tell44 the user and stop452. Identify logical groupings and order them from most foundational to most46 dependent. When a boundary is ambiguous, keep changes together473. Infer verification commands from project signals (e.g. `package.json`,48 `Makefile`, CI config). If there are none, ask the user494. Present the plan as a numbered list:50 - Commit N: `<imperative-mood description>: <file or hunk list>`51 - One sentence justifying each split boundary52 - The verification commands you will run after each split53 - Ask for confirmation545. Split each commit except the last. After each split, edit the newly created55 parent commit (`jj edit @-`) and run the verification commands566. Give every resulting commit a description with `jj describe`577. After all splits, run `jj log -r 'ancestors(@, <commit count>)'` and show the58 resulting stack5960# How to split6162## By file6364Use `jj split` with file patterns to put specific files in the first commit:6566```sh67jj split -m "<first commit description>" -- <files for first commit>68```6970The remaining files stay in the second commit.7172## By hunk7374When a single file contains changes that belong in different commits, edit the75file directly:76771. Edit the file to contain only the changes for the first commit (remove hunks78 that belong later)792. Run `jj new` to start the next commit803. Re-edit the file to restore the hunks removed in step 1814. Verify with `jj log -r '@-::@'` and `jj diff -r @-`8283# Fixing mistakes8485Use these when verification fails because changes are in the wrong commit.8687## Move files between child and parent commits8889```sh90# Move from child to parent91jj squash --from @+ --into @ -- <files>9293# Move from parent to child94jj squash --from @ --into @+ -- <files>95```9697## Move hunks between commits9899When the boundary falls inside a file, edit the file directly:1001011. While on the commit that should lose the hunk, remove it from the file1022. Switch to the other commit and restore the hunk there1033. Verify both commits