difit is a CLI tool that lets you view and review local git diffs with a GitHub-style viewer. In addition to clean visuals, comments can be copied as prompts for AI. The local code review tool for the AI era!
Try it first
npx difit # View the latest commit diff in WebUIInstall and use
npm install -g difit
difit # View the latest commit diff in WebUIEnable use from AI agents
npx skills add yoshiko-pg/difit # Add the Skill to your agentdifit <target> # View single commit diff
difit <target> [compare-with] # Compare two commits/branchesdifit # HEAD (latest) commit
difit 6f4a9b7 # Specific commit
difit feature # Latest commit on feature branchdifit @ main # Compare with main branch (@ is alias for HEAD)
difit feature main # Compare branches
difit . origin/main # Compare working directory with remote maindifit supports special keywords for common diff scenarios:
difit . # All uncommitted changes (staging area + unstaged)
difit staged # Staging area changes
difit working # Unstaged changes onlydifit --pr https://github.com/owner/repo/pull/123--pr mode fetches patches by running gh pr diff --patch under the hood.
Authentication is handled by GitHub CLI:
- Login once (recommended):
gh auth login - Token-based auth (CI/non-interactive): set
GH_TOKENorGITHUB_TOKEN
For Enterprise Server PRs, authenticate GitHub CLI against your Enterprise host:
gh auth login --hostname YOUR-ENTERPRISE-SERVER- Or set
GH_HOST=YOUR-ENTERPRISE-SERVERwithGH_TOKEN/GITHUB_TOKEN
By using a pipe to pass unified diffs via stdin, you can view diffs from any tool with difit.
# View diffs from other tools
diff -u file1.txt file2.txt | difit
# Review saved patches
cat changes.patch | difit
# Compare against merge base
git diff --merge-base main feature | difit
# Review an entire existing file as newly added
git diff -- /dev/null path/to/file | difit
# Explicit stdin mode
git diff --cached | difit -Stdin mode is selected with intent-first rules:
-explicitly enables stdin mode- If positional arguments (
<target>/[compare-with]),--pr, or--tuiare provided, difit treats the command as Git/PR/TUI mode and does not auto-read stdin - Auto stdin detection applies only when no explicit mode is selected and stdin is a pipe/file/socket
| Flag | Default | Description |
|---|---|---|
<target> |
HEAD | Commit hash, tag, HEAD~n, branch, or special arguments |
[compare-with] |
- | Optional second commit to compare with (shows diff between the two) |
--pr <url> |
- | GitHub PR URL to review (e.g., https://github.com/owner/repo/pull/123) |
--port |
4966 | Preferred port; falls back to +1 if occupied |
--host |
127.0.0.1 | Host address to bind server to (use 0.0.0.0 for external access) |
--no-open |
false | Don't automatically open browser |
--mode |
split | Display mode: unified or split |
--tui |
false | Use terminal UI mode instead of WebUI |
--clean |
false | Clear all existing comments and viewed files on startup |
--include-untracked |
false | Automatically include untracked files in diff (only with . or working) |
--keep-alive |
false | Keep server running after browser disconnects (stop manually with Ctrl+C) |
difit includes a review comment system that makes it easy to provide feedback to AI coding agents:
- Add Comments: Click the comment button on any diff line or drag to select a range
- Edit Comments: Edit existing comments with the edit button
- Generate Prompts: Comments include a "Copy Prompt" button that formats the context for AI coding agents
- Copy All: Use "Copy All Prompt" to copy all comments in a structured format
- Persistent Storage: Comments are saved in browser localStorage per commit
src/components/Button.tsx:L42 # This line is automatically added
Make this variable name more descriptiveFor range selections:
src/components/Button.tsx:L42-L48 # This line is automatically added
This section is unnecessaryYou can install the following Skill to request reviews from users with difit.
npx skills add yoshiko-pg/difitAfter an agent edits code, it will start the difit server.
- JavaScript/TypeScript:
.js,.jsx,.ts,.tsx - Web Technologies: HTML, CSS, JSON, XML, Markdown
- Shell Scripts:
.sh,.bash,.zsh,.fish - Backend Languages: PHP, SQL, Ruby, Java, Scala, Perl
- Systems Languages: C, C++, C#, Rust, Go
- Mobile Languages: Swift, Kotlin, Dart
- Infrastructure as Code: Terraform (HCL)
- Others: Python, Protobuf, YAML, Solidity, Vim script
difit automatically identifies and collapses certain files to keep your view clean:
- Deleted files: Removed files are auto-collapsed since they don't require close review
- Generated files: Auto-generated code is collapsed by default. This includes:
- Lock files (
package-lock.json,go.mod,Cargo.lock,Gemfile.lock, etc.) - Minified files (
*.min.js,*.min.css) - Source maps (
*.map) - Generated code:
- Orval (
*.msw.ts,*.zod.ts,*.api.ts) - Dart (
*.g.dart,*.freezed.dart) - C# (
*.g.cs,*.designer.cs) - Protobuf (
*.pb.go,*.pb.cc,*.pb.h)
- Orval (
- Frameworks:
- Ruby on Rails (
db/schema.rb) - Laravel (
_ide_helper.php) - Gradle (
gradle.lockfile) - Python (
uv.lock,pdm.lock)
- Ruby on Rails (
- Generic generated files (
*.generated.cs,*.generated.ts,*.generated.js) - Content-based detection:
- Files containing
@generatedmarker - Files containing
DO NOT EDITheader - Language-specific generated headers (Go, Python, etc.)
- Files containing
- Lock files (
# Install dependencies
pnpm install
# Start development server (with hot reload)
# This runs both Vite dev server and CLI with NODE_ENV=development
pnpm run dev
# Build and start production server
pnpm run start <target>
# Build for production
pnpm run build
# Run tests
pnpm test
# Run typecheck, lint, and format
pnpm run check
pnpm run formatpnpm run dev: Starts both Vite dev server (with hot reload) and CLI server simultaneouslypnpm run start <target>: Builds everything and starts production server (for testing final build)- Development mode: Uses Vite's dev server for hot reload and fast development
- Production mode: Serves built static files (used by npx and production builds)
- CLI: Commander.js for argument parsing with comprehensive validation
- Backend: Express server with simple-git for diff processing
- GitHub Integration: GitHub CLI (
gh pr diff --patch) for PR patch retrieval - Frontend: React 18 + TypeScript + Vite
- Styling: Tailwind CSS v4 with GitHub-like dark theme
- Syntax Highlighting: Prism.js with dynamic language loading
- Testing: Vitest for unit tests with co-located test files
- Quality: oxlint, oxfmt, lefthook pre-commit hooks
- Node.js ≥ 21.0.0
- Git repository with commits to review
- GitHub CLI (
gh) for--prmode
MIT

