▌margin

Review changes in the margin.

A fast, keyboard-first terminal diff viewer for Git changes, patches — and the code your agents keep producing. One static binary. No runtime.

brew install imrajyavardhan12/tap/margin

or download a binary · curl -fsSL https://github.com/imrajyavardhan12/Margin/releases/latest/download/margin-installer.sh | sh

Margin reviewing a Rust diff: navigating hunks, staging one, leaving a review note, marking the file viewed, then exporting the notes as Markdown.
Read the diff, stage the good part, leave a note on the rest, check the file off — then hand the notes back as Markdown.

Why Margin

Built for the agent loop

Mark a file viewed and it stays viewed across rebases and force-pushes — marks are keyed to content, not line numbers, so only files that actually changed come back for a second look.

Annotate a hunk with c, then margin --notes prints every remark as Markdown with path:line anchors. Paste it into a pull request, or hand it straight back to the agent that wrote the code.

Acts on the diff

Stage and unstage hunk by hunk with s / u, or discard one with x. Accepting and rejecting an agent's edits never means switching tools.

Staging touches the index only. Discard — the one destructive key — writes a backup patch to .git/margin/trash/, makes you type yes, and is reversible with margin undo.

Instant, and honest about it

First paint in about 4 ms on a 100-file diff, 15 ms on a 250k-line lockfile — measured with criterion, budgets enforced in CI. Syntax highlighting is budgeted per frame, so no diff can freeze the UI.

A good terminal citizen

Safe as core.pager: piped output is byte-identical to its input, by contract and by test. Honours NO_COLOR, degrades to a real 16-colour palette instead of mangled RGB, and picks a light or dark theme from your terminal's own background.

The whole grammar, roughly

jkline
JKhunk
][file
/search
fjump to file
sustage / unstage
xdiscard
cnote
mviewed
vsplit view
?help
qquit

Full reference →

Every way in

# the working tree, untracked files included
margin
# ...and reload automatically while an agent edits
margin -w

margin diff --staged        # what's staged
margin show HEAD~1          # one commit
margin diff main..feature   # a range
margin diff old.rs new.rs   # two files, no repo needed
git diff | margin patch     # any unified diff on stdin
margin pr 123               # a GitHub PR, through your own gh

margin --json | jq          # structured changeset for scripts
margin --notes              # your review notes as Markdown

No repository handy? examples/ has runnable demo patches.

How it compares

 margindeltadifftasticgitui
Interactive review UIyesnonopartial
Stage / discard by hunkyesnonoyes
Review notes → Markdownyesnonono
Search across the changesetyesvia lessnono
Single binary, no runtimeyesyesyesyes
Structural (AST) diffnonoyesno
Whole-repo managementnononoyes

Margin does one thing: changeset review. For AST diffs use difftastic; for whole-repo work, gitui and lazygit are excellent.

Contribute

The architecture is written down, every significant decision has an ADR, and the whole suite runs without a terminal. Jujutsu support is open and up for grabs.

Star on GitHub Start contributing