@hdehler/diffai
v1.0.0
Published
A beautiful git diff viewer — diff branches clearly and export structured summaries for AI
Downloads
23
Readme
diffai
A beautiful, interactive git diff viewer built for reviewing AI-written code. Side-by-side layout, mouse scroll, multi-repo support, and structured output that Claude can read directly.
Why
When you use AI to write code and then commit it, the changes blur together quickly. git diff in the terminal is noisy, Cursor's diff view disappears once you're on a branch, and trying to understand what was actually changed — and why it matters — is hard.
diffai gives you a proper side-by-side viewer with keyboard and trackpad navigation, a web UI for deep dives, and --summary / --json flags you can pipe straight into Claude.
Install
Requirements: Node.js 18+
# Clone and install globally
git clone https://github.com/harrydehler/diffai.git ~/diffai
cd ~/diffai
npm install
npm install -g .Install tab completion (zsh / bash):
diffai completion install
# Then restart your terminal, or:
source ~/.zshrcUsage
diffai # current branch vs main (interactive TUI)
diffai main feature-branch # compare any two branches
diffai HEAD~5 HEAD # last 5 commits
diffai abc123 def456 # compare two SHAs
diffai --repo inventory # diff a saved repo (see: config)
diffai --all # diff all saved repos in sequenceViews
Interactive TUI (default)
Running diffai in a terminal opens a full-screen viewer.
────────────────────────────────────────────────────────────────
src/auth.js modified +12 -4
main → feature-login 3/5 ██████████░░░░░░
────────────────────────────────────────────────────────────────
BEFORE │ AFTER
────────────────────────────────────────────────────────────────
4 - const jwt = require("jsonw… │ 4 + import jwt from 'jsonwebto…
5 const db = require('./db') │ 5 import db from './db.js'Keyboard controls:
| Key | Action |
|-----|--------|
| → / n / Enter | Next file |
| ← / p | Previous file |
| ↑ / k | Scroll up 1 line |
| ↓ / j | Scroll down 1 line |
| Space / d | Page down |
| u | Page up |
| 1–9 | Jump to file by number |
| o | Back to overview |
| q / Ctrl+C | Quit |
Trackpad / mouse wheel also scrolls up and down within a file.
Web UI
diffai --web
diffai main feature-branch --webOpens a GitHub-style diff in your browser — file sidebar, sticky file headers, side-by-side layout, keyboard shortcuts. Best for large diffs or sharing.
Other output modes
diffai --flat # non-interactive, scrollable output (piping / CI)
diffai --stat # file overview only — no diff body
diffai --summary # plain-text summary — paste into Claude
diffai --json # structured JSON — Claude or scripts can parse this directly
diffai --file src/ # filter to files whose path contains this stringMulti-repo config
Save repo shortcuts so you don't have to type paths:
diffai config add inventory ~/inventory
diffai config add sales ~/sales-display
diffai config add rma ~/rma
diffai config list # list all saved repos
diffai config remove sales # remove oneThen use them anywhere:
diffai --repo inventory # inventory: current branch vs main
diffai --repo inventory main feat # inventory: specific branches
diffai --all # diff every saved repo in sequence
diffai --all --summary # AI summary across all reposUsing with Claude
diffai --summary and diffai --json are designed to be fed directly into Claude.
Quick paste:
diffai --summary | pbcopy # copy to clipboard, paste into ClaudeIn a Claude Code session:
# Claude can run this directly
diffai --json
diffai --repo inventory --summaryAsk Claude things like:
- "Walk me through what changed and why each change matters"
- "Which of these changes could introduce bugs?"
- "Summarize this diff for a PR description"
The /diffai-review custom command (if installed) runs the full analysis automatically — it fetches the diff, looks up function definitions, and explains the context behind each change.
Untracked files
diffai automatically includes untracked files (new files not yet committed) when comparing against your current branch. They appear at the end of the file list marked as added.
Tab completion
After running diffai completion install, tab-completing works for:
- Branch names — auto-fetched from
git branch -a - Saved repo names — auto-fetched from your config
diffai main <TAB> # complete branch names
diffai --repo <TAB> # complete saved repo namesOptions reference
diffai [base] [head] [options]
Arguments:
base Base ref to compare against (default: main/master)
head Head ref to compare (default: current branch)
Options:
-r, --repo <name> Run against a saved repo by name
-A, --all Run across all saved repos in sequence
-w, --web Open a web UI in the browser
-s, --stat File overview only
-F, --flat Non-interactive scrollable output
-S, --summary Plain-text summary for Claude
-j, --json Structured JSON output
-f, --file <pattern> Show only files whose path contains this string
-C, --cwd <path> Run against a repo at this path
-h, --help Show help
-V, --version Show versionLicense
MIT — Harry Dehler
