Skip to content

stavgian/code-review-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code Review Agent (Ollama + Node.js)

A lightweight, local AI code reviewer that analyzes your staged git changes and provides structured feedback.
Everything runs on your machine using Ollama, so no code ever leaves your device.

Features

  • Reviews only staged git diffs
  • Runs automatically before each commit (Husky pre-commit hook)
  • Structured output: Summary, Issues, Suggestions
  • Local and private — zero cloud usage
  • Works with any language (diff-based)

Requirements

  • Node.js 18+
  • Git
  • Ollama installed and running locally

Install Ollama:
https://ollama.com/download

Installation

Clone this repository:

git clone https://github.com/stavgian/code-review-agent.git
cd code-review-agent
npm install

Pull the model once:

npm run setup:ollama

(uses llama3.1 by default)

Usage

1. Stage your changes

git add <files>

2. Run the review manually

npm run review

3. Automatic review (pre-commit hook)

The project includes a Husky pre-commit hook.

Whenever you run:

git commit -m "your message"

the AI review executes automatically.

To skip the hook:

HUSKY=0 git commit -m "skip review"

How it Works

  • review.js collects the staged git diff
  • Sends it to Ollama using the Chat API
  • Ollama returns a human-readable code review
  • Husky blocks/continues commits based on script completion

Everything is local.

Example Output

=== CODE REVIEW ===

Summary:
- Minor formatting issues detected.

Issues:
1) [MEDIUM] Missing error handling
   - Function does not handle null input.

Suggestions:
- Add validation for input params.
- Consider extracting repeated logic into helpers.

Configuration

To change the model, edit:

model: "llama3.1"

in review.js.

Modify the system prompt there to adjust strictness or tone.

Development

Run review without committing:

npm run review

Debug hook:

bash -x .husky/pre-commit

Make hook executable:

chmod +x .husky/pre-commit

License

MIT

About

A lightweight, local AI code reviewer that analyzes your staged git changes and provides structured feedback.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors