DEV Community

Cover image for I Built a Local AI Code Reviewer That Reads Your Entire Codebase (and PRs!) for Free
Bimasha Zaman
Bimasha Zaman

Posted on

I Built a Local AI Code Reviewer That Reads Your Entire Codebase (and PRs!) for Free

As developers, we all want AI to review our code. But sending proprietary, unreleased code to third-party cloud APIs (like OpenAI or Anthropic) isn't always an option—especially if you're working on client projects or under strict NDAs.

I wanted an AI code reviewer that was 100% private, free, and actually understood the context of my entire project. So, I built one using Python and Ollama.

Here’s a look at what it does and how you can use it!


What it does

It’s a CLI tool that uses local LLMs (like qwen2.5-coder or llama3) to review your code. No API keys, no subscriptions, and zero data leaves your machine.

But I didn't want to just paste code snippets into a terminal. I wanted a tool that actually fits into a developer's workflow. Here is what it supports:

1. Review an Entire Codebase
Just point it at your project folder. The app will recursively gather your files, automatically ignoring bulky folders like node_modules, .git, vendor, and .next, and give you a full architectural review.

python3 app.py ./my-project/
Enter fullscreen mode Exit fullscreen mode

2. Review Pull Requests Automatically
Want to review a PR? Just pass the GitHub PR URL. The tool auto-detects that it's a diff, fetches the changes, and switches into "PR Review Mode." Instead of looking at architecture, it zeroes in on the + lines to find bugs, edge cases, and missing tests introduced by the PR.

python3 app.py https://github.com/facebook/react/pull/30000
Enter fullscreen mode Exit fullscreen mode

(Working on a private repo? Just pipe it: gh pr diff 123 | python3 app.py)

3. Pipe Anything Into It
You can pipe individual files, diffs, or snippets straight from your terminal.

cat src/main.py | python3 app.py
Enter fullscreen mode Exit fullscreen mode

🛠️ How to run it yourself

  1. Install Ollama and pull a solid coding model:
   ollama pull qwen2.5-coder
Enter fullscreen mode Exit fullscreen mode
  1. Clone the repo and install the requirements:
   pip install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode
  1. Run it!
   python3 app.py ./your-code
Enter fullscreen mode Exit fullscreen mode

💡 The Magic Under the Hood

The script dynamically switches its prompt based on what you feed it. If you give it a directory, it looks for separation of concerns and system design. If you feed it a Git Diff, it laser-focuses on unintended side effects and edge cases in the modified lines.

Give it a try and let me know what you think! What features would you like to see added next?

GitHub logo bimashazaman / AI-Code-Reviewer-Ollama-LLM

Imagine you're coding, and before committing your code, your own local AI reviews it. No OpenAI. No internet. No API costs. Runs entirely on Ollama.

AI Code Reviewer

Review code locally with Ollama. No API keys, no cloud — your code stays on your machine.

Setup

  1. Install Ollama and pull a model:
ollama pull qwen2.5-coder
Enter fullscreen mode Exit fullscreen mode
  1. Install dependencies:
pip install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode

Usage

You can use the AI Code Reviewer to analyze an entire codebase, a single file, or a quick snippet.

Review an Entire Codebase

Simply provide the path to your project folder. The tool will automatically gather your code while ignoring massive folders (like node_modules, .git, vendor) and large data files to keep the review efficient.

python3 app.py ./my-project/
Enter fullscreen mode Exit fullscreen mode

Review a Single File

Pass the exact file you want to review.

python3 app.py src/main.py
Enter fullscreen mode Exit fullscreen mode

Review a Snippet (Interactive)

Run the script without any arguments. You can paste your code directly into the terminal. Type END on a new line when you're finished.

python3 app.py
Enter fullscreen mode Exit fullscreen mode

Pipe Code In

You can also…




Top comments (0)