# hunk

> Terminal diff viewer for reviewing Git, GitHub, Jujutsu, and Sapling changesets, with inline agent annotations, split/unified layouts, and watch mode.

Stars: 9.7k · Language: TypeScript · License: MIT · Categories: Git

- Repository: https://github.com/modem-dev/hunk
- Website: https://hunk.dev
- Page: https://www.trmn.sh/tools/hunk

## Install

- Install script: `curl -fsSL https://hunk.dev/install.sh | sh`
- Homebrew: `brew install hunk`
- npm: `npm i -g hunkdiff`

## Overview

Hunk is a terminal diff viewer for reviewing changesets, particularly ones written by coding agents. It mirrors Git's diff-style commands but opens the result in a review UI: a multi-file review stream with sidebar navigation, split, unified, or responsive auto layouts, and inline AI or agent annotations beside the code. It is built on OpenTUI and Pierre diffs, and supports keyboard, mouse, pager, and Git difftool use.

It covers several sources of changes. `hunk diff` reviews working-tree changes including untracked files, `hunk show` reviews a commit, and `hunk log` browses history (interactive on a terminal, static output when piped, with optional graph view and commit range selection). `hunk gh pr`, `hunk gh commit`, and `hunk gh compare` open GitHub pull requests, commits, and comparisons without the GitHub CLI; `GH_TOKEN` or `GITHUB_TOKEN` is used for private repos. It auto-detects Jujutsu and Sapling checkouts and uses native revsets there. Raw inputs work too: `hunk diff --files before.ts after.ts` or `git diff --no-color | hunk patch -`. The `--watch` flag reloads the review as files or the working tree change.

For agent workflows, a review can be left open in one terminal while an agent loads the skill file from `hunk skill path` and works against the live session, adding annotations. Hunk ships as a standalone binary (no Node.js needed except for the npm install) on macOS, Linux, and Windows, and updates itself with `hunk update`. It suits developers who review AI-generated or large multi-file diffs from the terminal.

### Installation

```bash
# via Install script
curl -fsSL https://hunk.dev/install.sh | sh
```

```bash
# via Homebrew
brew install hunk
```

```bash
# via npm
npm i -g hunkdiff
```

![Hunk split view with sidebar and inline AI notes](https://media.trmn.sh/cached/fb9a7c65d7f92fbeb77b4e728b54f6cea14a6690542c83479aaea4e5a8281f84.webp)

![Hunk unified view with mouse-selectable menus](https://media.trmn.sh/cached/e77a2761a4132101b3b58ea6b60cc24e8a843ea4f0ddc1e6f63fb58cd9ef82e4.webp)

## Alternatives

- [git-crypt](https://www.trmn.sh/tools/git-crypt.md): Transparent file encryption for Git repositories using AES-256, encrypting files on commit and decrypting on checkout (C++, 10.0k stars)
- [gitoxide](https://www.trmn.sh/tools/gitoxide.md): Pure Rust implementation of Git, offered as the gix library crate plus gix and ein command-line binaries for testing the API and running workflow tools. (Rust, 12.1k stars)
- [onefetch](https://www.trmn.sh/tools/onefetch.md): Command-line tool that displays Git repository information and code statistics in terminal (Rust, 12.1k stars)
- [soft-serve](https://www.trmn.sh/tools/soft-serve.md): Self-hostable Git server with SSH-accessible TUI for command-line repository management and browsing. (Go, 7.3k stars)
- [gh-dash](https://www.trmn.sh/tools/gh-dash.md): Terminal UI for GitHub that lists configurable pull request and issue sections, with vim-style hotkeys, custom actions, and a YAML config file. (Go, 12.7k stars)

---

Canonical: https://www.trmn.sh/tools/hunk
