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
Metadata
Release files for git-sage 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| git_sage-0.1.0.tar.gz | 16.4 kB | Without provenance | Details for git_sage-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| git_sage-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for git_sage-0.1.0-py3-none-any.whl |
Total release size: 31.6 kB
Release files / git_sage-0.1.0.tar.gz
| Download URL | git_sage-0.1.0.tar.gz |
|---|---|
| Size | 16.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
427e48d07b8a0c41a8c9f799ab7f185835dc7b2ada25554142388a2dbcb551a3
|
|
BLAKE2b-256 checksum How to use checksums |
0c988b34bc177d4bd2d899f8af92f1cf4c26016ad38c7a9ca26e3814c4a1cfb1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / git_sage-0.1.0-py3-none-any.whl
| Download URL | git_sage-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2aa70c3fc2c4f0aabbef185ba1129191e696310a6d859a1915f179b098bf4ea3
|
|
BLAKE2b-256 checksum How to use checksums |
c9c347b15729cb939b8715d833b347fa003963741489211db955bd74cabe7400
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for git-sage 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.