Local AI code reviewer for your git workflow. Powered by Ollama
Project description
git-sage
Local AI code review right before you push. No cloud. No subscriptions. No data leaving your machine.
git-sage hooks into your git workflow and runs a code review using a locally hosted LLM via Ollama. When you run git push, the tool intercepts it, sends your staged diff to the model, and either approves the push or asks you to revise, all on your machine, in seconds.
$ git push
Staged: 3 file(s) +47 / -12
╭─ Summary ───────────────────────────────────────────────────────────╮
│ Adds a /login endpoint with bcrypt password hashing. │
╰─────────────────────────────────────────────────────────────────────╯
Issues (2 found)
● 1. The SECRET_KEY is hardcoded as a string literal on line 14.
● 2. There is no rate limiting on the /login route.
Suggestions (1)
◆ 1. Load SECRET_KEY from os.getenv('SECRET_KEY') instead.
╭─────────────────────────────────────────────────────────────────────╮
│ ✗ REVISE │
│ Address the issues above before pushing. │
╰─────────────────────────────────────────────────────────────────────╯
Push aborted by git-sage. Fix the issues above, or run:
git push --no-verify to bypass the hook.
Why git-sage?
Most AI code review tools sit at the pull request stage, by then your code has already reached a remote server. A hardcoded secret has already been pushed. A vulnerable dependency is already on a branch other developers may have pulled.
git-sage moves the review to your local machine, before any code leaves it. If the model finds a problem, the push is aborted and you fix it right there in your editor.
Requirements
- Python 3.9+
- Ollama installed and running
- macOS, Linux, or Windows (WSL2)
- ~5 GB disk space for the default model
No GPU required. Runs on any modern laptop.
Quick start
1. Install Ollama and pull the model
brew install ollama # macOS — see docs for Linux/Windows
ollama serve
ollama pull qwen2.5-coder:7b
2. Install git-sage
pip install git-sage
3. Install the hook in your repo
cd your-project
git-sage install
4. Push as normal
git push # review runs automatically
Commands
| Command | Description |
|---|---|
git-sage review |
Manually review staged changes |
git-sage review --model llama3.2 |
Use a different local model |
git-sage review --context "Adds OAuth" |
Provide context to the model |
git-sage review --diff-mode head |
Review the last commit instead |
git-sage review --diff-mode branch --base main |
Review the whole branch |
git-sage review --force |
Review but don't abort push on REVISE |
git-sage install |
Install the pre-push hook |
git-sage uninstall |
Remove the pre-push hook |
git-sage status |
Check Ollama availability and hook status |
git-sage models |
List locally available Ollama models |
How it works
git push
→ .git/hooks/pre-push fires
→ git-sage review --hook
→ git diff --cached (extract the staged diff)
→ build prompt (diff + system instructions)
→ POST localhost:11434 (Ollama local API)
→ parse response (SUMMARY / ISSUES / SUGGESTIONS / VERDICT)
→ render to terminal (rich coloured output)
→ exit 0 (APPROVE) or exit 1 (REVISE, aborts push)
For a full breakdown of the architecture and each module, see the Architecture docs.
Bypassing the hook
git push --no-verify
Project structure
git_sage/
cli.py CLI entrypoint (click)
diff.py Git diff extraction
prompt.py Prompt builder
ollama.py Ollama HTTP client
parser.py Response parser
output.py Terminal renderer (rich)
hook.py Git hook installer
tests/
test_parser.py
test_diff.py
test_prompt.py
docs/ Docusaurus documentation site
CHANGELOG.md Version history
Running tests
pip install pytest
pytest tests/ -v
Tests are self-contained; no Ollama or git repo needed.
Contributing
Contributions are welcome. See the Contributing guide for how to get started, issue templates, and a PR template.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file git_sage-0.1.0.tar.gz.
File metadata
- Download URL: git_sage-0.1.0.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
427e48d07b8a0c41a8c9f799ab7f185835dc7b2ada25554142388a2dbcb551a3
|
|
| MD5 |
bc6d6b77c90941dce08cc94b242abbf7
|
|
| BLAKE2b-256 |
0c988b34bc177d4bd2d899f8af92f1cf4c26016ad38c7a9ca26e3814c4a1cfb1
|
File details
Details for the file git_sage-0.1.0-py3-none-any.whl.
File metadata
- Download URL: git_sage-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2aa70c3fc2c4f0aabbef185ba1129191e696310a6d859a1915f179b098bf4ea3
|
|
| MD5 |
a9eece3e84960cf21ca1b5ab21bc2ffe
|
|
| BLAKE2b-256 |
c9c347b15729cb939b8715d833b347fa003963741489211db955bd74cabe7400
|