一键导入
jj-hunk
Programmatic hunk selection for jj (Jujutsu). Use when splitting commits, making partial commits, or selectively squashing changes without interactive UI.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Programmatic hunk selection for jj (Jujutsu). Use when splitting commits, making partial commits, or selectively squashing changes without interactive UI.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Review changes since a fixed point along two axes — Standards (does the code follow this repo's documented coding standards?) and Spec (does the code match the originating shape, revision description, issue, or PRD?). Runs both reviews in parallel sub-agents and reports them side by side. Use when the user wants to review a branch, revision, PR, working-copy changes, or asks to "review since X".
Control Herdr, a terminal multiplexer for coding agents. Use only when the user explicitly mentions Herdr or asks to use Herdr to inspect or control panes, tabs, workspaces, terminals, commands, or communication with another agent. Do not use merely because a task could benefit from a background terminal, delegation, or parallel work.
Use when the user asks for a rich explanation of a code change, diff, branch, or PR. Produces an interactive HTML page, a Notion page, or an interactive Obsidian vault note.
Session mode — coordinate only, delegate all actual work to background minion subagents
Interview-style session that aligns a plan with the existing domain vocabulary, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as decisions crystallise. Use when user wants to stress-test a plan against their project's language and documented decisions.
Transform a workflow description into affordance tables showing UI and Code affordances with their wiring. Use to map existing systems or design new ones from shaped parts.
| name | jj-hunk |
| description | Programmatic hunk selection for jj (Jujutsu). Use when splitting commits, making partial commits, or selectively squashing changes without interactive UI. |
Use jj-hunk for non-interactive hunk selection in jj. Essential for AI agents that need to create clean, logical commits from mixed changes.
jj split -i or jj squash -icargo install jj-hunk
Add to ~/.jjconfig.toml:
[merge-tools.jj-hunk]
program = "jj-hunk"
edit-args = ["select", "$left", "$right"]
jj-hunk list # working copy (@)
jj-hunk list -r <rev> # any revision
Output (JSON):
{
"src/foo.rs": [
{"index": 0, "type": "replace", "removed": "old\n", "added": "new\n"},
{"index": 1, "type": "insert", "removed": "", "added": "// added\n"}
],
"src/bar.rs": [
{"index": 0, "type": "delete", "removed": "removed\n", "added": ""}
]
}
Select hunks by index or use file-level actions:
{
"files": {
"src/foo.rs": {"hunks": [0]},
"src/bar.rs": {"action": "keep"},
"src/baz.rs": {"action": "reset"}
},
"default": "reset"
}
| Spec | Effect |
|---|---|
{"hunks": [0, 2]} | Include only hunks 0 and 2 |
{"action": "keep"} | Include all changes |
{"action": "reset"} | Discard all changes |
"default": "reset" | Unlisted files are discarded |
"default": "keep" | Unlisted files are kept |
# Split: selected hunks → first commit, rest → second commit
jj-hunk split '<spec>' "commit message"
jj-hunk split -r <rev> '<spec>' "commit message" # split any revision
# Commit: selected hunks committed, rest stays in working copy
jj-hunk commit '<spec>' "commit message"
# Squash: selected hunks squashed into parent
jj-hunk squash '<spec>'
jj-hunk squash -r <rev> '<spec>' # squash any revision into its parent
You have refactoring and a new feature mixed together:
# 1. See what hunks exist
jj-hunk list
# 2. Split out the refactoring first
jj-hunk split '{"files": {"src/lib.rs": {"hunks": [0, 1]}}, "default": "reset"}' \
"refactor: extract helper function"
# 3. Remaining changes become second commit
jj describe -m "feat: add new feature"
Keep experimental code in working copy while committing the fix:
jj-hunk commit '{"files": {"src/bug.rs": {"action": "keep"}}, "default": "reset"}' \
"fix: handle null case"
jj-hunk squash '{"files": {"src/tests.rs": {"action": "keep"}}, "default": "reset"}'
jj-hunk split '{"files": {"src/wip.rs": {"action": "reset"}}, "default": "keep"}' \
"feat: complete implementation"
# List hunks in a specific revision
jj-hunk list -r urx
# Split it — examples go to first commit, rest stays
jj-hunk split -r urx \
'{"files": {"examples/README.md": {"action": "keep"}}, "default": "reset"}' \
"examples of extensions"
The commands above are wrappers. For direct control:
# Write spec to file
echo '{"files": {"src/foo.rs": {"hunks": [0]}}, "default": "reset"}' > /tmp/spec.json
# Run jj with the tool
JJ_HUNK_SELECTION=/tmp/spec.json jj split -i --tool=jj-hunk -m "message"
| Type | Meaning |
|---|---|
insert | New lines added |
delete | Lines removed |
replace | Lines changed (removed + added) |
jj-hunk list to see hunk indices before building specs"default": "reset" is safer (explicit inclusion), "default": "keep" is convenient for excluding specific filesjj describe to refine commit messages