DEV Community

Uzain Ahmed
Uzain Ahmed

Posted on

diff-review: a local pre-push code reviewer built for a friend

Hacktoberfest Weekend Challenge: Build for a Friend Submission 🤝

This is a submission for the Hacktoberfest Weekend Challenge: Build for a Friend

What I Built

diff-review is a small CLI and git pre-push hook. When you run git push, it grabs the diff, drops the noise (lockfiles, build output, binaries), sends it to an open-weight model through Ollama, and prints up to five short bullets about likely bugs, leftover debug code, and missing tests. Then your push continues.

It never blocks a push unless you opt in with --strict. If the model is offline, it prints "review skipped" and moves on.

I built it for a friend who is a developer and still getting comfortable with the terminal. He wanted a quick sanity check on his code before pushing, without sending it to a hosted service.

I showed it to him, and his feedback was honest: it would be better with a smarter model, and better still with a UI. The terminal-only setup is hard for him right now. I've put that in the "What's next" section below because it's the most useful thing I learned.

Demo

Code

diff-review

Local CLI and git pre-push hook that reviews your diff using an open-weight model running on your machine.

Example

diff-review · gemma3:1b via ollama · diff-file · 1 of 1 files · 142 lines
- src/api.ts: fetch result is used without checking response.ok
- src/api.ts: console.log left in getUser()

Why local and open-weight

  • Code never leaves your machine by default (Ollama runs locally). If you use OpenRouter, the diff is sent to that hosted service (see privacy note below).
  • Model is swappable via CLI flags, environment variables, or config; no code changes.
  • Free to run. Small 1B models give shallow reviews and are advisory only - they may miss things and sometimes produce unhelpful output. We also include rule-based checks plus model review (deterministic checks that catch obvious issues without invoking a model), and we honestly note that a 1B model adds little on top of those checks.

Quick

…

How I Built It

TypeScript on Node with zero runtime dependencies. I wrote a PRD and had OpenCode, an open-source coding agent, build the project from it. Then I tested it myself in a throwaway demo repo, including the case where the model is unreachable.

The default model is gemma3:1b, served locally by Ollama. The provider and model are config values, so you can point it at a bigger local model or at OpenRouter (the README documents the privacy tradeoff of sending the diff to a hosted service).

I picked a 1B model so it downloads quickly and runs on any laptop, and I'll be upfront about the cost: it's weak at code review. It misses subtle bugs and sometimes just echoes the prompt. The tool filters and formats its output to keep it short, but a 1B model can only do so much.

Why Does Open Innovation Matter?

Privacy: by default, the diff never leaves the machine. For a check on unreleased code, a closed API would mean sending it to a third party.

Swappable: the model is a config value, not a dependency. My friend's main complaint was model quality, and with an open setup the fix is changing one setting, not switching products.

Free and offline: no API key, no per-token cost, and it works without internet.

Top comments (0)