I built a local-first LLM code reviewer in Go. Here's the entire pipeline. A developer built CommitBrief, a local-first CLI tool that runs an LLM code review on git diffs before committing. The tool supports providers like Claude, GPT, Gemini, or local Ollama models, and ensures no data leaves the machine unless explicitly chosen. Key engineering includes a hybrid git diff acquisition, multi-layer diff filtering, and a pre-send guard to prevent leaking sensitive files. CommitBrief is a local-first CLI that runs an LLM review over your git diff before a teammate — or your future self — sees it. There's no server and no telemetry; the diff leaves your machine only for the provider you chose, and with a local model like Ollama it never leaves at all. The interesting engineering isn't "call an LLM." It's everything that has to happen around that call so the review stays cheap, safe, and reproducible. Here's the whole path from commitbrief --staged to the findings on your screen. TL;DR git diff range with the provider you pick: Claude, GPT, Gemini, or a fully local Ollama model. Key facts commitbrief commit , and even that only runs one git commit of already-staged changes — it never edits a file. brew install CommitBrief/tap/commitbrief , scoop install commitbrief , or go install github.com/CommitBrief/commitbrief/cmd/commitbrief@latest .Every review walks one linear pipeline. Here it is at altitude before we zoom in: | Stage | What happens | Why it's here | |---|---|---| | 1. Resolve context | Walk up for .git , merge config built-in < global < repo , apply env + flags | One deterministic config per run | | 2. Load rules | ./COMMITBRIEF.md or the embedded default; validate the output template first | Fail on a broken template before spending a token | | 3. Acquire diff | Hybrid go-git + exec git fallback | Worktree state is git's, not a reimplementation's | | 4. Parse + filter | Three ignore layers, then an optional allowlist | Don't pay to review lock files | | 5. Pre-send guard | Refuse to leak .commitbrief/ ; scan for secrets | The diff is about to leave the machine | | 6. Build prompt | Four XML blocks + an immutability guard | Structured and injection-resistant | | 7. Cache lookup | SHA-256 of the exact inputs | A re-run is a disk read, not a bill | | 8. Cost preflight | Estimate tokens, warn over a threshold | No surprise spend | | 9. Provider call | Structured JSON, or verbatim text for CLI providers | The actual review | | 10. Render + gate | Cards / JSON / Markdown, then --fail-on | Human output or a CI exit code | Five of these carry most of the weight. Let's take them in order. You'd think reading a diff is trivial. It is — until you need staged-vs-unstaged, a worktree comparison, and git diff main...feature to all behave exactly like git, on Windows too. CommitBrief runs a hybrid: a primary go-git implementation with a git CLI fallback ADR-0002 . Range operations that go-git models cleanly — commit-vs-first-parent, merge-base range diffs, branch diffs — stay in-process. Staged, unstaged, and arbitrary git diff