# diff-glance

> A CLI tool that turns git diffs into plain-English ELI5 summaries and Mermaid architecture diagrams using AI models.

diff-glance is an open-source CLI tool written in TypeScript that converts git diffs into human-readable summaries and module architecture diagrams. It runs via `npx diff-glance` and requires Node.js 18+, `git` on the PATH, and an OpenAI-compatible API key or a local Ollama endpoint. The tool is published on npm under the MIT license.

## What It Is

diff-glance sits between raw `git diff` output and a developer's mental model of what actually changed. Instead of reading line-by-line patches, you get a 30-second ELI5 summary and a Mermaid-based module graph that shows how the changed files relate to each other. The output is served through an ephemeral local HTTP server bound to `127.0.0.1`, so the rendered HTML viewer never leaves the machine. You can also export the analysis as JSON (`--json`) or write a standalone HTML file (`-o report.html`).

## How It Works

When invoked, diff-glance collects the git diff for the specified range (defaulting to `HEAD` vs the worktree, including staged, unstaged, and untracked changes), strips lockfiles, binaries, and generated directories, then sends the truncated unified diff to the configured AI model. The model returns a structured analysis that the tool renders into the local viewer. Key CLI flags include:

- `[from] [to]` — diff between two git refs
- `--staged` — staged changes only
- `--commit <sha>` — a single commit vs its parent
- `--json` — print raw analysis JSON to stdout
- `--max-chars <n>` — cap diff characters sent to the model (default 80,000)
- `--no-open` — skip auto-opening the browser

## Provider and Model Support

diff-glance supports multiple AI providers selected automatically by which environment variable is set. Supported providers include OpenAI (default model `gpt-4o-mini`), Google Gemini (`gemini-3.6-flash`), OpenRouter (`openai/gpt-4o-mini`), Groq (`llama-3.3-70b-versatile`), and Ollama for fully local inference (`llama3.2`). A custom `--base-url` flag accepts any OpenAI-compatible endpoint, including Vertex AI and Anthropic via OpenRouter. Key resolution order prioritizes `--api-key` over environment variables, with Ollama activated automatically when the base URL is a loopback address and no other key is present.

## Privacy and Local-First Design

The README explicitly states that the HTML viewer listens only on `127.0.0.1` and serves a single generated page — nothing is uploaded except the truncated diff sent to whichever model is configured. Pointing `--base-url` at a local Ollama server keeps the entire request on localhost with no network egress. Lockfiles and binaries are stripped before the model sees the patch, reducing both token usage and accidental secret exposure.

## Current Status

The repository was created and last updated on 2025-08-27, with the project at an early stage (5 stars, 0 forks). It is actively published to npm and available via `npx diff-glance`. The core language is TypeScript and the project is licensed MIT.

## Features
- Plain-English ELI5 summaries of git diffs
- Mermaid architecture diagrams of changed modules
- Local ephemeral HTTP viewer bound to 127.0.0.1
- JSON output mode (--json)
- HTML file export (-o report.html)
- Staged-only diff mode (--staged)
- Single commit diff mode (--commit <sha>)
- Configurable max diff characters sent to model
- Lockfile, binary, and generated directory filtering
- Support for OpenAI, Gemini, OpenRouter, Groq, and Ollama providers
- Custom OpenAI-compatible base URL support
- Fully local inference via Ollama

## Integrations
OpenAI, Google Gemini, OpenRouter, Groq, Ollama, Vertex AI, Anthropic (via OpenRouter), Git, npm, Node.js

## Platforms
WEB, API, CLI

## Pricing
Open Source

## Links
- Website: https://github.com/alvynmcq/diff-glance
- Documentation: https://github.com/alvynmcq/diff-glance#readme
- Repository: https://github.com/alvynmcq/diff-glance
- EveryDev.ai: https://www.everydev.ai/tools/diff-glance
