jj-hunk/SKILL.md
Programmatic hunk selection for jj (Jujutsu). Use when splitting commits, making partial commits, or selectively squashing changes without interactive UI.
npx skillsauth add sanurb/skills jj-hunkInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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 messagesdevelopment
Sets up an `## Agent skills` block in AGENTS.md/CLAUDE.md and `docs/agents/` so the engineering skills know this repo's issue tracker (GitHub, GitLab, fp, or local markdown), triage label vocabulary, and domain doc layout. Run before first use of `fp-plan`, `fp-implement`, `fp-review`, `to-issues`, `to-prd`, `triage`, `diagnose`, `tdd`, `improve-codebase-architecture`, or `zoom-out` — or if those skills appear to be missing context about the issue tracker, triage labels, or domain docs.
development
Build a throwaway prototype to flush out a design before committing to it. Routes between two branches — a runnable terminal app for state/business-logic questions, or several radically different UI variations toggleable from one route. Use when the user wants to prototype, sanity-check a data model or state machine, mock up a UI, explore design options, or says "prototype this", "let me play with it", "try a few designs".
tools
Control herdr (a terminal-native agent multiplexer) from inside it. Manage workspaces and tabs, split panes, spawn sibling agents, read pane output, and wait for state changes — all via CLI commands that talk to the running herdr instance over a local unix socket. Use when running inside herdr (HERDR_ENV=1). Do not use outside herdr.
documentation
Compact the current conversation into a handoff document for another agent to pick up.