| name | hunk-review |
|---|---|
| description | Interacts with live Hunk diff review sessions via CLI. Inspects review focus, navigates files and hunks, reloads session contents, and adds inline review comments. Use when the user has a Hunk session running or wants to review diffs interactively. |
Hunk is an interactive terminal diff viewer. The TUI is for the user -- do NOT run hunk diff, hunk show, or other interactive commands directly. Use hunk session * CLI commands to inspect and control live sessions through the local daemon.
If no session exists, ask the user to launch Hunk in their terminal first.
1. hunk session list # find live sessions
2. hunk session get --repo . # inspect path / repo / source
3. hunk session review --repo . --json # inspect file/hunk structure first
4. hunk session review --repo . --include-patch --json # opt into raw diff text only when needed
5. hunk session context --repo . # check current focus when needed
6. hunk session navigate ... # move to the right place
7. hunk session reload -- <command> # swap contents if needed
8. hunk session comment add ... # leave one review note
9. hunk session comment apply ... # apply many agent notes in one stdin batch
Most session commands accept:
--repo <path>-- match the live session by its current loaded repo root (most common)<session-id>-- match by exact ID (use when multiple sessions share a repo)- If only one session exists, it auto-resolves
reload also supports:
--session-path <path>-- match the live Hunk window by its current working directory--source <path>-- load the replacementdiff/showcommand from a different directory
Use --source only for advanced reloads where the live session you want to control is not already associated with the checkout you want to load next. For a normal worktree session, prefer selecting it directly with --repo /path/to/worktree.
hunk session list [--json]
hunk session get (--repo . | <id>) [--json]
hunk session context (--repo . | <id>) [--json]
hunk session review (--repo . | <id>) [--json] [--include-patch]getshows the sessionPath,Repo, andSource, which helps when choosing between--repoand--session-pathRepois what--repomatches;Pathis what--session-pathmatchesreview --jsonreturns file and hunk structure by default; add--include-patchonly when a caller truly needs raw unified diff text
Absolute navigation requires --file and exactly one of --hunk, --new-line, or --old-line:
hunk session navigate --repo . --file src/App.tsx --hunk 2
hunk session navigate --repo . --file src/App.tsx --new-line 372
hunk session navigate --repo . --file src/App.tsx --old-line 355Relative comment navigation jumps between annotated hunks and does not require --file:
hunk session navigate --repo . --next-comment
hunk session navigate --repo . --prev-comment--hunk <n>is 1-based--new-line/--old-lineare 1-based line numbers on that diff side- Use either
--next-commentor--prev-comment, not both
Swaps the live session's contents. Pass a Hunk review command after --:
hunk session reload --repo . -- diff
hunk session reload --repo . -- diff main...feature -- src/ui
hunk session reload --repo . -- show HEAD~1
hunk session reload --repo . -- show HEAD~1 -- README.md
hunk session reload --repo /path/to/worktree -- diff
hunk session reload --session-path /path/to/live-window --source /path/to/other-checkout -- diff- Always include
--before the nested Hunk command --repoor<session-id>usually selects the session you want--sourceis advanced: it does not select the session; it only changes where the replacement review command runs- If the live session is already showing the target worktree, prefer
hunk session reload --repo /path/to/worktree -- diff --session-pathtargets the live window when you need to keep session selection separate from reload source
hunk session comment add --repo . --file README.md --new-line 103 --summary "Tighten this wording" [--rationale "..."] [--author "agent"] [--focus]
printf '%s\n' '{"comments":[{"filePath":"README.md","newLine":103,"summary":"Tighten this wording"}]}' | hunk session comment apply --repo . --stdin [--focus]
hunk session comment list --repo . [--file README.md]
hunk session comment rm --repo . <comment-id>
hunk session comment clear --repo . --yes [--file README.md]comment addis best for one note;comment applyis best when an agent already has several notes readycomment addrequires--file,--summary, and exactly one of--old-lineor--new-linecomment applypayload items requirefilePath,summary, and exactly one target such ashunk,hunkNumber,oldLine, ornewLinecomment applyreads a JSON batch from stdin and validates the full batch before mutating the live session- Pass
--focuswhen you want to jump to the new note or the first note in a batch comment listandcomment clearaccept optional--file- Quote
--summaryand--rationaledefensively in the shell
hunk diff includes untracked files by default. If the user wants tracked changes only, reload with --exclude-untracked:
hunk session reload --repo . -- diff --exclude-untrackedThe user may ask you to walk them through a changeset or review code using Hunk. Start with hunk session review --json to understand the file/hunk structure without inflating agent context, then use --include-patch only for the files you truly need to read in raw diff form. Use context and navigate to line up the user's current view before adding comments.
Your role is to narrate: steer the user's view to what matters and leave comments that explain what they're looking at.
Typical flow:
- Load the right content (
reloadif needed) - Navigate to the first interesting file / hunk
- Add a comment explaining what's happening and why
- If you already have several notes ready, prefer one
comment applybatch over many separate shell invocations - Summarize when done
Guidelines:
- Work in the order that tells the clearest story, not necessarily file order
- Navigate before commenting so the user sees the code you're discussing
- Use
comment applyfor agent-generated batches andcomment addfor one-off notes - Use
--focussparingly when the note itself should actively steer the review - Keep comments focused: intent, structure, risks, or follow-ups
- Don't comment on every hunk -- highlight what the user wouldn't spot themselves
- "No visible diff file matches ..." -- the file is not in the loaded review. Check
context, thenreloadif needed. - "No active Hunk sessions" -- ask the user to open Hunk in their terminal.
- "Multiple active sessions match" -- pass
<session-id>explicitly. - "No active Hunk session matches session path ..." -- for advanced split-path reloads, verify the live window
Pathviahunk session getorlist, then use--session-path. - "Pass the replacement Hunk command after
--" -- include--before the nesteddiff/showcommand. - "Pass --stdin to read batch comments from stdin JSON." --
comment applyonly reads its batch payload from stdin. - "Specify exactly one navigation target" -- pick one of
--hunk,--old-line, or--new-line. - "Specify either --next-comment or --prev-comment, not both." -- choose one comment-navigation direction.