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.
- 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)
- Node.js 18+
- Git
- Ollama installed and running locally
Install Ollama:
https://ollama.com/download
Clone this repository:
git clone https://github.com/stavgian/code-review-agent.git
cd code-review-agent
npm installPull the model once:
npm run setup:ollama(uses llama3.1 by default)
git add <files>npm run reviewThe 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"review.jscollects the stagedgit 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.
=== 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.
To change the model, edit:
model: "llama3.1"in review.js.
Modify the system prompt there to adjust strictness or tone.
Run review without committing:
npm run reviewDebug hook:
bash -x .husky/pre-commitMake hook executable:
chmod +x .husky/pre-commitMIT