{"slug": "show-hn-diff-glance-cli-that-turns-a-git-diff-into-a-summary-and-a-diagram", "title": "Show HN: Diff Glance – CLI that turns a Git diff into a summary and a diagram", "summary": "Diff Glance, a new command-line tool announced on Hacker News, turns Git diffs into plain-English summaries and architecture diagrams using AI. The tool, requiring Node.js 18+ and an OpenAI-compatible API key, supports multiple providers including OpenAI, Google Gemini, OpenRouter, Groq, and Ollama, and serves results via a local HTTP viewer. It filters out lockfiles and binaries before sending the diff to the model, and offers flags for staged changes, specific commits, JSON output, and custom model endpoints.", "body_md": "Turn messy git diffs into plain-English summaries and architecture diagrams.\n\n```\nnpx diff-glance\nnpx diff-glance origin/main HEAD\n```\n\nRequires Node.js 18+, `git`\n\non `PATH`\n\n, and an OpenAI-compatible API key (or a local Ollama endpoint). Default range is `HEAD`\n\nvs the worktree (staged + unstaged + untracked). If the worktree is clean, that falls back to `--commit HEAD`\n\n. The second command diffs two refs. There is no stdin pipe.\n\n``` bash\n$ diff-glance\ndiff-glance: analyzing diff...\ndiff-glance: generating summary...\ndiff-glance: viewer at http://127.0.0.1:53102\ndiff-glance: press Ctrl+C to stop\n```\n\nThe local viewer (bound to `127.0.0.1`\n\n) opens in your browser:\n\nUse `--json`\n\nto print the same analysis to stdout, or `-o report.html`\n\nto write the HTML file instead of serving it.\n\n- Line-by-line diffs do not answer “what changed and what might break.”\n- A 30-second ELI5 plus a module graph is a usable mental model before a PR review.\n- Lockfiles, binaries, and generated dirs are dropped before the model sees the patch.\n- The viewer is an ephemeral local HTTP server. Nothing is uploaded except the truncated diff you send to the model you configured.\n\n| Provider | How it is selected | Default model |\n|---|---|---|\n| OpenAI | `OPENAI_API_KEY` |\n`gpt-4o-mini` |\n| Google Gemini | `GEMINI_API_KEY` or `GOOGLE_API_KEY` |\n`gemini-3.6-flash` |\n| OpenRouter | `OPENROUTER_API_KEY` |\n`openai/gpt-4o-mini` |\n| Groq | `GROQ_API_KEY` |\n`llama-3.3-70b-versatile` |\n| Ollama | `--base-url http://127.0.0.1:11434/v1` |\n`llama3.2` |\n| Custom | `--base-url` + `--api-key` |\n`gpt-4o-mini` unless the URL matches a row above |\n\nAnthropic is not a native SDK path. Route it through OpenRouter (`--model anthropic/claude-sonnet-4`\n\n) or any other OpenAI-compatible gateway. Vertex AI works the same way: pass its OpenAI-compatible `--base-url`\n\n.\n\nIf more than one key is set, resolution order is: `--api-key`\n\n→ `DIFF_GLANCE_API_KEY`\n\n→ `OPENAI_API_KEY`\n\n→ `OPENROUTER_API_KEY`\n\n→ `GROQ_API_KEY`\n\n→ `GEMINI_API_KEY`\n\n/ `GOOGLE_API_KEY`\n\n/ `GOOGLE_GENERATIVE_AI_API_KEY`\n\n. A dummy key of `ollama`\n\nis used only when the base URL is local and no other key is present.\n\n| Flag | Behavior |\n|---|---|\n`[from]` `[to]` |\nGit refs. One arg diffs that ref vs the worktree; two args diffs `from..to` . |\n`-s, --staged` |\nStaged changes only (`git diff --cached` ). |\n`-c, --commit <sha>` |\nThat commit vs its parent (`<sha>^!` ). |\n`-m, --model <id>` |\nModel id. |\n`--base-url <url>` |\nOpenAI-compatible API base URL. |\n`--api-key <key>` |\nAPI key. |\n`-p, --port <n>` |\nViewer port. `0` (default) picks an ephemeral port. |\n`--host <host>` |\nViewer bind host. Default `127.0.0.1` . |\n`--no-open` |\nDo not open a browser. |\n`--json` |\nPrint analysis JSON to stdout; skip the viewer. |\n`--max-chars <n>` |\nMax diff characters sent to the model. Default `80000` . |\n`-o, --output <file>` |\nWrite HTML to a file instead of serving. |\n\n```\ndiff-glance --staged\ndiff-glance --commit HEAD\ndiff-glance --json\ndiff-glance -o glance.html --no-open\ndiff-glance --base-url http://127.0.0.1:11434/v1 --model llama3.2\n```\n\n| Variable | Role |\n|---|---|\n`OPENAI_API_KEY` |\nOpenAI key (also used as a generic key if you set a custom base URL). |\n`OPENAI_BASE_URL` |\nOpenAI-compatible base URL. |\n`OPENAI_MODEL` |\nModel id fallback. |\n`DIFF_GLANCE_API_KEY` |\nOverrides other keys except `--api-key` . |\n`DIFF_GLANCE_BASE_URL` |\nOverrides `OPENAI_BASE_URL` . |\n`DIFF_GLANCE_MODEL` |\nOverrides `OPENAI_MODEL` . |\n`OPENROUTER_API_KEY` |\nSelects OpenRouter. |\n`GROQ_API_KEY` |\nSelects Groq. |\n`GEMINI_API_KEY` / `GOOGLE_API_KEY` / `GOOGLE_GENERATIVE_AI_API_KEY` |\nSelects Gemini. |\n`DIFF_GLANCE_DEBUG` |\nIf set, print the raw error after the one-line stderr message. |\n\n`--base-url`\n\nand `--model`\n\nbeat the env vars. There is no `AI_BASE_URL`\n\nor `AI_MODEL`\n\n.\n\nThe HTML viewer never leaves the machine. It listens on `127.0.0.1`\n\nand serves one generated page.\n\nCloud providers receive the truncated unified diff (lockfiles and binaries already stripped). Point `--base-url`\n\nat `http://127.0.0.1:11434/v1`\n\n(Ollama or any other local OpenAI-compatible server) and the request stays on localhost — no `--local`\n\nflag; the loopback URL is what keeps the payload off the network.\n\n```\ngit clone https://github.com/alvynmcq/diff-glance.git\ncd diff-glance\nnpm install\nnpm run dev\n```\n\n`npm run dev`\n\nruns `tsx src/index.ts`\n\n. `npm run build`\n\nemits `dist/`\n\nfor `node bin/diff-glance.js`\n\n. `npm run typecheck`\n\nruns `tsc --noEmit`\n\n.", "url": "https://wpnews.pro/news/show-hn-diff-glance-cli-that-turns-a-git-diff-into-a-summary-and-a-diagram", "canonical_source": "https://github.com/alvynmcq/diff-glance", "published_at": "2026-08-27 13:05:09+00:00", "updated_at": "2026-08-27 13:19:10.179179+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools"], "entities": ["Diff Glance", "OpenAI", "Google Gemini", "OpenRouter", "Groq", "Ollama"], "alternates": {"html": "https://wpnews.pro/news/show-hn-diff-glance-cli-that-turns-a-git-diff-into-a-summary-and-a-diagram", "markdown": "https://wpnews.pro/news/show-hn-diff-glance-cli-that-turns-a-git-diff-into-a-summary-and-a-diagram.md", "text": "https://wpnews.pro/news/show-hn-diff-glance-cli-that-turns-a-git-diff-into-a-summary-and-a-diagram.txt", "jsonld": "https://wpnews.pro/news/show-hn-diff-glance-cli-that-turns-a-git-diff-into-a-summary-and-a-diagram.jsonld"}}