← Back to all posts

Hunk: Code Review Without Leaving the Terminal

Title card showing a diff hunk in a terminal pane: context lines, one removal, two emerald additions

TL;DR: Hunk is a TUI for code review, built by Ben Vinegar (ex-Sentry). It renders diffs the way delta does, but adds the two things pagers can’t: GitHub-style line notes on a local diff, and a built-in loop for an AI agent to review your changes and leave those notes itself. The notes are ephemeral and nothing syncs to GitHub - which makes Hunk the best local review tool I’ve tried and useless for team review. This series already covered the collaboration end; this is the other end: reviewing work - increasingly an agent’s work - before anyone else sees it.


Why “local code review” is suddenly a category

Five years ago “review your own diff in a fancy viewer” was a niche aesthetic preference. What changed is whose diff it is. When agents write a meaningful share of the code, the pre-PR read-through stops being a courtesy and becomes the actual quality gate. The review moment moves earlier: not “colleague checks my PR” but “I check the agent’s diff before it becomes a PR at all”. That’s a local activity, and the tooling for it was mostly git diff piped through a pager.

Hunk’s lineage tells the story of that gap closing: GNU diff (1974) → git diff → diff-so-fancy → delta → TUIs like diffnav and lumen → Hunk. Each step adds interactivity; Hunk is the first to add annotation.

The tool in ninety seconds

Two commands cover most of it: hunk diff for uncommitted changes, hunk show for the last commit (or HEAD~N). Vim navigation (hjkl, Ctrl+D/U, [/] between hunks), stacked or side-by-side view, syntax highlighting via Shiki, e opens the file in your editor, ? shows help. Config is TOML in ~/.config/hunk. Two touches worth calling out:

  • hunk stash show - inspect a stash without the pop-and-pray ritual
  • first-class support for both Git and Jujutsu - reportedly the reason Mitchell Hashimoto uses it; if you’re jj-curious, tooling that treats jj as a peer rather than an afterthought is still rare
  • you can set it as your git pager, globally or per repo

Line notes: the feature that makes it review, not viewing

Press a key on a line, type a note, and it hangs there like a GitHub comment - navigate between notes with {/}. Two constraints define what the notes are for: they are not tracked by git, and they evaporate when the session ends. So: a scratchpad for a single review pass, not a record of decisions. For the pre-PR read of a large diff, that’s exactly right - “this endpoint returns an unstructured body”, “why did this test change?” - working memory, externalized, on the exact line it concerns.

If you need the comment to reach someone, that’s the boundary of the tool. More on that below, because it’s the honest core of the review.

The AI review loop

This is the part that earns Hunk a slot in this series rather than a footnote under delta. hunk session runs a small server; hunk skill exposes instructions meant for an agent, not for you. The intended workflow: load the skill into a coding agent, ask it to review the current diff, and the agent leaves line notes in your TUI, side by side with your own. A next session can list those notes, load context and fix them.

The setup is glue rather than native integration - a generic prompt plus a skill path - but the shape is right, and it’s the first tool I’ve seen that treats “agent as reviewer” as a UI problem rather than a chat problem. The note-on-line format constrains the agent usefully: no essays, just claims pinned to code.

I didn’t take the docs’ word for it - I ran the loop with my own agent (Claude, headless, against a real diff in this blog’s repo). The mechanics held up better than expected. The bundled skill file is refreshingly blunt: the TUI is for the user, do NOT run hunk diff yourself - the agent gets a hunk session CLI talking to a local daemon instead. My agent listed the live session, pulled the diff structure as JSON (session review --json - files, hunks, line ranges, no raw patch text unless requested), added a line note with a summary and a rationale (session comment add --new-line 36 ...), and jumped focus to it (session navigate --next-comment). The note landed in the session tagged source: agent, author and all, pinned to the exact line. Two design choices deserve credit: the agent reads structure by default and opts into patch text explicitly (smaller context, fewer hallucinated line numbers), and agent notes are first-class but visibly labelled - you always know which reviewer is a person. Honest scope note: I ran this headless under a fake TTY; the side-by-side “agent notes next to mine” experience in a real terminal is what the review on my own PRs will test next.

Hunk in split view on a real commit from this blog's repo: the files sidebar on the left, the content-schema diff in the middle, and an agent note pinned to line 37 saying the series field is declared but nothing renders it

hunk show on a real commit from this blog’s repo. The note on line 37 came in through hunk session comment add while the TUI was open, the same command my agent used. It is also a fair catch: at that commit series was declared in the schema and rendered nowhere.

The open question this raises: if one agent session reviews and another fixes, at what point is anyone still testing rather than checking? That’s the checking-versus-testing line applied to code review - an agent can verify the diff against stated intentions, but someone still has to have intentions. Keep a human in the loop not for throughput but for that.

Where it doesn’t reach

Hunk is not collaborative, and it doesn’t pretend to be: no session sharing, no sync of notes to GitHub, nothing a teammate will ever see. There’s an open issue about syncing; today it’s a hard boundary. So the division of labor in my toolbox stays clean:

MomentTool
reviewing my own or an agent’s diff, pre-PRHunk
working the PR queue, commenting for othersgh-dash
everyday staging, committing, branch surgeryplain git inside wt-managed worktrees

(Plenty of people pair a diff viewer with LazyGit as the daily driver; my everyday layer is thinner - wt hands me an isolated worktree per branch and plain git does the rest, which makes Hunk the only TUI in the loop rather than the second one.)

One more honest wrinkle: Hunk is an npm-ecosystem tool (built on OpenTUI; the package is hunkdiff - plain hunk on npm is an unrelated multipart parser, a mistake I made so you don’t have to; brew and Nix installs also exist). If your terminal minimalism has opinions about Rust versus Node, delta remains the purist’s pager - but delta doesn’t take notes.

Where it lands in my setup

The natural slot in my workflow is the moment wt already created: one worktree per branch means one review context per branch, and hunk diff inside the worktree is the pre-PR read. I’m starting deliberately small - not as a global git pager, just the explicit review command - because tools earn promotion to defaults here, they don’t get it on day one. I’m still testing it, but it has a good chance of earning a permanent place in my setup.

The test that decides whether it stays, same as every tool in this series: does it remove a reason to leave the terminal? Review was the last one on my list with a browser tab attached. If the agent-review loop holds up on my own PRs, this one closes it.