|
1 | 1 | --- |
2 | 2 | name: hunk-review |
3 | | -description: Use when the task involves Hunk review sessions. Helps a coding agent explain what Hunk is, prefer live Hunk session CLI inspection over shell parsing, inspect current review focus, navigate or reload live sessions, and leave inline review comments. |
4 | | -compatibility: Requires Hunk from this repo or the published hunkdiff package. Works best with a real TTY for interactive review. |
| 3 | +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. |
5 | 4 | --- |
6 | 5 |
|
7 | 6 | # Hunk Review |
8 | 7 |
|
9 | | -Use this skill when the task involves Hunk itself or when the user wants an interactive review workflow centered on a live Hunk session. |
| 8 | +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. |
10 | 9 |
|
11 | | -Start by explaining Hunk plainly: **Hunk is a review-first terminal diff viewer for agent-authored changesets.** |
| 10 | +If no session exists, ask the user to launch Hunk in their terminal first. |
12 | 11 |
|
13 | | -## Mental model |
| 12 | +## Workflow |
14 | 13 |
|
15 | | -Keep these product rules in mind: |
16 | | - |
17 | | -- the main pane is one top-to-bottom multi-file review stream |
18 | | -- the sidebar is for navigation, not single-file mode switching |
19 | | -- layouts are `auto`, `split`, and `stack` |
20 | | -- `[` and `]` navigate hunks across the full review stream |
21 | | -- agent notes belong beside the code they explain |
22 | | - |
23 | | -Your job is not just to inspect the diff privately. Use Hunk as a shared explanation surface for the code author. |
24 | | - |
25 | | -## Default operating rule |
26 | | - |
27 | | -If a live Hunk session already exists, prefer `hunk session ...` over scraping terminal output or opening another review window. |
28 | | - |
29 | | -Hunk uses one local-only loopback daemon to broker commands to live sessions. Normal Hunk sessions register automatically. `hunk mcp serve` is for manual startup or debugging only. `HUNK_MCP_DISABLE=1` disables registration for one session. |
30 | | - |
31 | | -## Default review workflow |
32 | | - |
33 | | -Use this loop unless there is a strong reason not to: |
34 | | - |
35 | | -1. `hunk session list` |
36 | | -2. `hunk session context` |
37 | | -3. `hunk session navigate` if the current focus is wrong |
38 | | -4. `hunk session reload -- <hunk command>` if the same live window should show different contents |
39 | | -5. `hunk session comment add` |
| 14 | +``` |
| 15 | +1. hunk session list # find live sessions |
| 16 | +2. hunk session context --repo . # check current focus |
| 17 | +3. hunk session navigate ... # move to the right place |
| 18 | +4. hunk session reload -- <command> # swap contents if needed |
| 19 | +5. hunk session comment add ... # leave review notes |
| 20 | +``` |
40 | 21 |
|
41 | | -Guidelines: |
| 22 | +## Session selection |
42 | 23 |
|
43 | | -- if multiple sessions are live, pass `sessionId` explicitly |
44 | | -- use `--repo <path>` when you want the session whose repo root matches one checkout |
45 | | -- use `hunk session get` only when you need broad session metadata |
46 | | -- keep the visible review state aligned with the explanation you are giving |
47 | | -- prefer concise inline comments tied to real diff lines or hunks |
| 24 | +Every command (except `list`) needs a session target: |
48 | 25 |
|
49 | | -## Precise command patterns |
| 26 | +- `--repo <path>` -- match by repo root (most common) |
| 27 | +- `<session-id>` -- match by exact ID (use when multiple sessions share a repo) |
| 28 | +- If only one session exists, it auto-resolves |
50 | 29 |
|
51 | | -### Navigate precisely |
| 30 | +## Commands |
52 | 31 |
|
53 | | -Use exact `navigate` targets instead of guessing flags: |
| 32 | +### Inspect |
54 | 33 |
|
55 | 34 | ```bash |
56 | | -hunk session navigate --repo . --file README.md --hunk 2 |
57 | | -hunk session navigate --repo . --file src/ui/App.tsx --new-line 372 |
58 | | -hunk session navigate --repo . --file src/ui/App.tsx --old-line 355 |
| 35 | +hunk session list [--json] |
| 36 | +hunk session get (--repo . | <id>) [--json] |
| 37 | +hunk session context (--repo . | <id>) [--json] |
59 | 38 | ``` |
60 | 39 |
|
61 | | -Targeting rules: |
62 | | - |
63 | | -- use `--hunk <n>` for a 1-based hunk number within the file |
64 | | -- use `--new-line <n>` for a line on the new side |
65 | | -- use `--old-line <n>` for a line on the old side |
66 | | -- do not invent extra flags; stick to the supported selectors above |
| 40 | +### Navigate |
67 | 41 |
|
68 | | -### Add and manage comments |
69 | | - |
70 | | -Use exact comment-management syntax: |
| 42 | +Requires `--file` and exactly one of `--hunk`, `--new-line`, or `--old-line`: |
71 | 43 |
|
72 | 44 | ```bash |
73 | | -hunk session comment add --repo . --file README.md --new-line 103 --summary "Tighten this wording" |
74 | | -hunk session comment list --repo . --file README.md |
75 | | -hunk session comment rm --repo . <comment-id> |
76 | | -hunk session comment rm <session-id> <comment-id> |
| 45 | +hunk session navigate --repo . --file src/App.tsx --hunk 2 |
| 46 | +hunk session navigate --repo . --file src/App.tsx --new-line 372 |
| 47 | +hunk session navigate --repo . --file src/App.tsx --old-line 355 |
77 | 48 | ``` |
78 | 49 |
|
79 | | -When passing comment text through a shell, quote `--summary` and `--rationale` defensively. Avoid raw backticks unless you are sure the shell will not interpret them. |
| 50 | +- `--hunk <n>` is 1-based |
| 51 | +- `--new-line`/`--old-line` are 1-based line numbers on that diff side |
80 | 52 |
|
81 | | -## Common commands |
| 53 | +### Reload |
82 | 54 |
|
83 | | -If operating inside the Hunk source repo, prefer the source entrypoint: |
| 55 | +Swaps the live session's contents. Pass a Hunk review command after `--`: |
84 | 56 |
|
85 | 57 | ```bash |
86 | | -bun run src/main.tsx -- diff |
87 | | -bun run src/main.tsx -- show HEAD~1 |
88 | | -``` |
89 | | - |
90 | | -Otherwise use the installed CLI: |
91 | | - |
92 | | -```bash |
93 | | -hunk diff |
94 | | -hunk show |
| 58 | +hunk session reload --repo . -- diff |
| 59 | +hunk session reload --repo . -- show HEAD~1 |
| 60 | +hunk session reload --repo . -- show HEAD~1 -- README.md |
95 | 61 | ``` |
96 | 62 |
|
97 | | -Useful live-session commands: |
| 63 | +### Comments |
98 | 64 |
|
99 | 65 | ```bash |
100 | | -hunk session list |
101 | | -hunk session context --repo . |
102 | | -hunk session navigate --repo . --file README.md --hunk 2 |
103 | | -hunk session reload --repo . -- show HEAD~1 -- README.md |
104 | | -hunk session comment add --repo . --file README.md --new-line 103 --summary "Tighten this wording" |
| 66 | +hunk session comment add --repo . --file README.md --new-line 103 --summary "Tighten this wording" [--rationale "..."] [--author "agent"] |
| 67 | +hunk session comment list --repo . [--file README.md] |
| 68 | +hunk session comment rm --repo . <comment-id> |
| 69 | +hunk session comment clear --repo . --yes [--file README.md] |
105 | 70 | ``` |
106 | 71 |
|
107 | | -Use `hunk diff --agent-context path/to/context.json` when a local rationale sidecar already exists. |
| 72 | +- `comment add` requires `--file`, `--summary`, and exactly one of `--old-line` or `--new-line` |
| 73 | +- Quote `--summary` and `--rationale` defensively in the shell |
108 | 74 |
|
109 | | -## Working-tree review playbook |
| 75 | +## New files in working-tree reviews |
110 | 76 |
|
111 | | -For the common case of steering one live `hunk diff` session while local files are changing: |
| 77 | +Newly created files won't appear in `hunk diff` until Git knows about them: |
112 | 78 |
|
113 | 79 | ```bash |
114 | | -hunk session list |
115 | | -hunk session context --repo . |
116 | | -git add -N src/new-file.ts # if a new file is missing from the review |
117 | | -hunk session reload --repo . -- diff # refresh the live working-tree review |
118 | | -hunk session navigate --repo . --file src/new-file.ts --hunk 1 |
119 | | -hunk session comment add --repo . --file src/new-file.ts --new-line 10 --summary "Explain why this matters" |
| 80 | +git add -N src/new-file.ts |
| 81 | +hunk session reload --repo . -- diff |
120 | 82 | ``` |
121 | 83 |
|
122 | | -Important mental model: |
123 | | - |
124 | | -- live session commands only operate on files visible in the currently loaded review |
125 | | -- for working-tree reviews, that means the file must appear in Git's diff |
126 | | -- newly created files often need `git add -N <path>` before Hunk can navigate to them or attach comments there |
127 | | - |
128 | | -## Comment style |
129 | | - |
130 | | -Prefer comments that help the author understand the change, not comments that just restate the diff. |
| 84 | +## Guiding a review |
131 | 85 |
|
132 | | -Good comments usually do one of these: |
| 86 | +The user may ask you to walk them through a changeset or review code using Hunk. Your role is to narrate: steer the user's view to what matters and leave comments that explain what they're looking at. |
133 | 87 |
|
134 | | -- explain intent |
135 | | -- explain structure |
136 | | -- point out why one hunk matters to the rest of the change |
137 | | -- suggest a specific follow-up or risk to inspect |
| 88 | +Typical flow: |
138 | 89 |
|
139 | | -Keep comments concise and spatially tied to the code they describe. |
| 90 | +1. Load the right content (`reload` if needed) |
| 91 | +2. Navigate to the first interesting file/hunk |
| 92 | +3. Add a comment explaining what's happening and why |
| 93 | +4. Move to the next point of interest -- repeat |
| 94 | +5. Summarize when done |
140 | 95 |
|
141 | | -## Common failure modes |
142 | | - |
143 | | -- `No visible diff file matches ...` |
144 | | - - the file is not part of the currently loaded review |
145 | | - - check `hunk session context --repo .` |
146 | | - - for a new file in a working-tree review, run `git add -N <path>` and then `hunk session reload --repo . -- diff` |
147 | | -- the session is showing the wrong changeset |
148 | | - - use `hunk session reload --repo . -- diff`, `-- show ...`, or another nested Hunk review command |
149 | | -- navigation target is ambiguous |
150 | | - - use one of `--hunk`, `--old-line`, or `--new-line` |
151 | | -- multiple live sessions exist and commands hit the wrong one |
152 | | - - pass `sessionId` explicitly |
153 | | -- no live session exists yet |
154 | | - - launch Hunk in a real terminal, then return to `hunk session list` |
155 | | - |
156 | | -## When no live session exists |
157 | | - |
158 | | -If the user wants interactive review and no live session exists, launch Hunk with a minimal review command, then go back to `hunk session list`. |
159 | | - |
160 | | -Prefer a real terminal or tmux pane over redirected stdout captures. |
161 | | - |
162 | | -## Repo-specific notes |
163 | | - |
164 | | -When using Hunk for agent changes in this repo: |
| 96 | +Guidelines: |
165 | 97 |
|
166 | | -- prefer a real TTY or tmux session for verification |
167 | | -- `.hunk/latest.json` is optional local context, not required repo hygiene |
168 | | -- if new files should appear in review before commit, use `git add -N <path>` |
169 | | -- if testing local source changes, prefer `bun run src/main.tsx -- ...` over an installed binary |
| 98 | +- Work in the order that tells the clearest story, not necessarily file order |
| 99 | +- Navigate before commenting so the user sees the code you're discussing |
| 100 | +- Keep comments focused: intent, structure, risks, or follow-ups |
| 101 | +- Don't comment on every hunk -- highlight what the user wouldn't spot themselves |
170 | 102 |
|
171 | | -## What this skill should steer toward |
| 103 | +## Common errors |
172 | 104 |
|
173 | | -- prefer visible, review-oriented actions over shell parsing of rendered terminal output |
174 | | -- inspect the current live diff session before navigating blindly |
175 | | -- reload the current live session instead of opening a second review window when the user wants to swap contents |
176 | | -- use Hunk to help the code author understand the code, not just to help yourself inspect it |
177 | | -- keep comments concise, concrete, and attached to the right place in the diff |
| 105 | +- **"No visible diff file matches ..."** -- file isn't in the loaded review. Check `context`, then `reload` if needed. |
| 106 | +- **"No active Hunk sessions"** -- ask the user to open Hunk in their terminal. |
| 107 | +- **"Multiple active sessions match"** -- pass `<session-id>` explicitly. |
| 108 | +- **"Specify exactly one navigation target"** -- pick one of `--hunk`, `--old-line`, `--new-line`. |
0 commit comments