The Problem

Reviewing local Git diffs typically means either squinting at terminal output or pushing code to a remote host to get a decent visual. difit removes that round-trip: it serves a GitHub-style "Files changed" view from your local machine, with inline comment support and AI-prompt export built in.

What This Does

difit is a CLI that parses Git diffs and renders them in a local web UI. The core parsing lives in src/server/git-diff.ts, which normalizes repository paths and resolves base commitish values; the React client in src/client/App.tsx handles the full diff review experience, including inline threads, side-by-side rendering, and keyboard navigation.

The repo is a portfolio of four self-contained projects: the main CLI/web app in src/, a VS Code extension in packages/vscode/, performance measurement scripts in scripts/, and dev tooling in dev/. There is no single shared architecture across them; each has its own entry points and responsibilities.

How It Is Wired

Execution starts in src/cli/index.ts, which routes to startServer in src/server/server.ts. That function reaches 44 other functions and owns the HTTP layer, including diff caching and comment session keys. The server reads Git data via src/server/git-diff.ts, which runs external Git commands and parses unified diffs. The client fetches from that API and renders through src/client/App.tsx, which reaches 12 functions directly.

The hub module is src/types/diff.ts: 65 modules depend on it, making any change there high-blast-radius. The other hot spot is src/utils/diffSelection.ts, whose createDiffSelection is called from 14 places and normalizeBaseMode from 10—these are the functions that break the most if changed. The client's App.tsx is the largest file at 1,220 lines and carries the widest ripple when modified.

The call graph shows 732 internal edges, with useKeyboardNavigation (25 calls), useLocalComments (21), and useDiffComments (16) as the most heavily reused hooks. The server touches the filesystem and runs external commands; the client does not. No circular dependencies exist in the 192 analyzed modules.

How To Use It

npx difit              # View the latest commit diff in WebUI
npm install -g difit   # Global install
difit feature main     # Compare two branches
difit .                # All uncommitted changes
difit --pr https://github.com/owner/repo/pull/123  # GitHub PR review

Configuration is minimal: GitHub PR mode requires gh CLI authentication (gh auth login or GH_TOKEN/GITHUB_TOKEN). No other environment variables are documented.

Real-World Use

A developer on a feature branch wants to review before pushing:

difit feature main

Difit serves the diff locally, shows inline comments, and offers a "copy as AI prompt" action. For PR review, difit --pr <url> fetches the patch via gh pr diff --patch and imports unresolved review threads as startup comments, so the reviewer starts with existing context.

Code Health & Issues

Static analysis (not opinion) found 31 findings: 6 high, 25 medium, 0 low. Key issues:

  • High - Hub modules - src/types/diff.ts (65 dependents) and src/client/components/SettingsModal.tsx (14 dependents). High churn risk; keep stable.
  • High - Deep nesting - SettingsModal.tsx, App.tsx, DiffChunk.tsx reach indentation depth 7. Use early returns.
  • High - Oversized files - App.tsx (1,220 lines), NotebookDiffViewer.tsx, server.ts. Split by responsibility.
  • High - Duplicated code - 288 repeated 6-line blocks across 53 files, concentrated in scripts/. Extract shared helpers.
  • Medium - High branching - 151 branch points over 492 lines in useExpandedLines.ts, cli/utils.ts, wordLevelDiff.ts.

Security audit found one high-severity issue: src/server/server.ts sets Access-Control-Allow-Origin: '*', which combined with credentials is a misconfiguration. CI lacks dependency scanning and keeps checkout tokens persistent. Tests, CI, and license are present; no secrets committed.

The Bottom Line

difit is a well-tested, practically useful tool for local diff review, with solid CLI ergonomics and a real VS Code extension. The main risks are architectural: oversized client files and a high-blast-radius type module. Anyone reviewing Git diffs locally—especially AI-assisted review workflows—will find it immediately useful, but the codebase needs decomposition before significant feature work.