Hunk is a terminal diff viewer for reviewing agent-authored changesets with a desktop-style UI.
- full-screen multi-file review stream
- split, stacked, and responsive auto layouts
- keyboard and mouse navigation
- optional agent rationale beside annotated hunks
- Git pager and difftool integration
npm i -g hunkdiff- Node.js 18+
- Git for
hunk diff,hunk show,hunk stash show, and pager integration
Review your current working tree:
hunk diffReview staged changes:
hunk diff --stagedReview a commit:
hunk show HEAD~1Compare two files directly:
hunk diff before.ts after.tsOpen a patch from stdin:
git diff --no-color | hunk patch -| Capability | hunk | difftastic | delta | diff |
|---|---|---|---|---|
| Dedicated interactive review UI | ✅ | ❌ | ❌ | ❌ |
| Multi-file review stream with navigation sidebar | ✅ | ❌ | ❌ | ❌ |
| Agent / AI rationale sidecar | ✅ | ❌ | ❌ | ❌ |
| Split diffs | ✅ | ✅ | ✅ | ✅ |
| Stacked diffs | ✅ | ✅ | ✅ | ✅ |
| Auto responsive layouts | ✅ | ❌ | ❌ | ❌ |
| Themes | ✅ | ❌ | ✅ | ❌ |
| Syntax highlighting | ✅ | ✅ | ✅ | ❌ |
| Syntax-aware / structural diffing | ❌ | ✅ | ❌ | ❌ |
| Mouse support inside the diff viewer | ✅ | ❌ | ❌ | ❌ |
| Runtime toggles for wrapping / line numbers / hunk metadata | ✅ | ❌ | ❌ | ❌ |
| Pager-compatible mode | ✅ | ✅ | ✅ | ✅ |
Quick local timing snapshot from one Linux machine on the same 120-line TypeScript file pair. Metric: time until a changed marker first became visible.
| Tool | Avg first-visible changed output |
|---|---|
diff |
~37 ms |
delta --paging=never |
~35 ms |
hunk diff |
~219 ms |
difft --display side-by-side |
~266 ms |
Takeaway:
diffanddeltaare fastest here because they print plain diff text and exit.hunkspends more startup time on an interactive UI, syntax highlighting, navigation state, and optional agent context.difftasticspends more startup time on structural diffing.
hunk— print CLI helphunk diff— review working tree changeshunk diff --staged/hunk diff --cached— review staged changeshunk diff <ref>— review changes versus a branch, tag, or commit-ishhunk diff <ref1>..<ref2>/hunk diff <ref1>...<ref2>— review Git rangeshunk diff -- <pathspec...>— limit review to selected pathshunk show [ref]— review the last commit or a specific refhunk stash show [ref]— review a stash entryhunk patch [file|-]— review a patch file or stdinhunk pager— act as a Git pager wrapper, opening Hunk for diff-like stdin and falling back to plain text paging otherwisehunk difftool <left> <right> [path]— integrate with Git difftool
1split view2stacked view0auto layouttcycle themesatoggle the agent panelltoggle line numberswtoggle line wrappingmtoggle hunk metadata[/]move between hunksspace/bpage forward and backward/focus the file filtertabcycle focus regionsqorEscquit
Use Hunk directly for full-screen review:
hunk diff
hunk diff --staged
hunk diff main...feature
hunk show
hunk stash showUse Hunk as a pager for git diff and git show:
git config --global core.pager 'hunk patch -'Or scope it just to diff/show:
git config --global pager.diff 'hunk patch -'
git config --global pager.show 'hunk patch -'Use Hunk as a Git difftool:
git config --global diff.tool hunk
git config --global difftool.hunk.cmd 'hunk difftool "$LOCAL" "$REMOTE" "$MERGED"'Hunk reads layered TOML config with this precedence:
- built-in defaults
- global config:
$XDG_CONFIG_HOME/hunk/config.tomlor~/.config/hunk/config.toml - repo-local config:
.hunk/config.toml - command-specific sections like
[diff],[show],[stash-show],[patch],[difftool] [pager]when Hunk is running in pager mode- explicit CLI flags
Example:
theme = "midnight"
mode = "auto"
line_numbers = true
wrap_lines = false
hunk_headers = true
agent_notes = false
[pager]
mode = "stack"
line_numbers = false
[diff]
mode = "split"Supported one-off CLI overrides:
--mode <auto|split|stack>--theme <theme>--line-numbers/--no-line-numbers--wrap/--no-wrap--hunk-headers/--no-hunk-headers--agent-notes/--no-agent-notes
Use --agent-context <file> to load a JSON sidecar and show agent rationale next to the diff.
The order of files in the sidecar is significant. Hunk uses that order for the sidebar and the main review stream so an agent can present a review narrative instead of raw patch order.
{
"version": 1,
"summary": "High-level change summary from the agent.",
"files": [
{
"path": "src/core/loaders.ts",
"summary": "Normalizes git and patch inputs into one changeset model.",
"annotations": [
{
"newRange": [120, 156],
"summary": "Adds the patch loader entrypoint.",
"rationale": "Keeps all diff sources flowing through one normalized shape.",
"tags": ["parser", "architecture"],
"confidence": "high"
}
]
}
]
}For local agent-driven review, keep a transient sidecar at .hunk/latest.json and load it with:
hunk diff --agent-context .hunk/latest.jsonInstall dependencies:
bun installValidate a change:
bun run typecheck
bun test
bun run test:tty-smokeBuild the npm runtime bundle used for publishing:
bun run build:npm
bun run check:packStage the prebuilt npm packages for the current host and smoke test the install path without Bun on PATH:
bun run build:prebuilt:npm
bun run check:prebuilt-pack
bun run smoke:prebuilt-installPrepare the multi-platform release directories from downloaded build artifacts and dry-run the publish order:
bun run build:prebuilt:artifact
bun run stage:prebuilt:release
bun run check:prebuilt-pack
bun run publish:prebuilt:npm -- --dry-runThe automated tag/manual release workflow lives in .github/workflows/release-prebuilt-npm.yml.