AI-powered code review in your terminal.
One command. Instant feedback. Catches security vulnerabilities, bugs, and bad patterns before they hit production.
Install ยท Quick Start ยท Usage ยท Providers ยท Contributing
codereview sends your code to an LLM and returns a structured, color-coded review directly in your terminal โ with severity ratings, line references, and concrete fix suggestions.
No browser. No PR required. No waiting for teammates. Just:
codereview app.py
- Solo developers โ get a second pair of eyes without waiting for anyone
- Pre-commit check โ catch bugs before they reach the PR
- Learning tool โ understand why code is problematic, not just that it is
- CI integration โ add to your pipeline for automated review gates
- Free โ works with Groq (free tier, no credit card) or fully offline with Ollama
| Severity | What it finds | Example |
|---|---|---|
| ๐ด Critical | Security vulnerabilities, data loss, crashes | SQL injection, eval() on user input, hardcoded secrets |
| ๐ก Warning | Bugs, missing error handling, race conditions | Division by zero, unhandled exceptions, resource leaks |
| ๐ต Info | Performance improvements, better patterns | Unnecessary allocations, missing caching, N+1 queries |
| โช Style | Naming, formatting, documentation | Missing docstrings, inconsistent naming, dead code |
git clone https://github.com/jaydendancer12/ai-code-review.git
cd ai-code-review
./install.shOr manually:
git clone https://github.com/jaydendancer12/ai-code-review.git
cd ai-code-review
pip install -e .All dependencies (rich, requests) install automatically. Nothing else to configure.
codereview needs an LLM to analyze your code. The fastest free option is Groq โ no credit card, no trial, just free.
- Go to console.groq.com
- Sign up with Google or GitHub (takes 30 seconds)
- Click API Keys then Create API Key
- Copy the key (starts with gsk_)
export GROQ_API_KEY="gsk_your_key_here"To make it permanent (so you don't have to set it every terminal session):
# For zsh (default on Mac)
echo 'export GROQ_API_KEY="gsk_your_key_here"' >> ~/.zshrc
source ~/.zshrc
# For bash (default on Linux)
echo 'export GROQ_API_KEY="gsk_your_key_here"' >> ~/.bashrc
source ~/.bashrccodereview --init groqcodereview yourfile.pyThat's it. You're running AI code reviews.
First time running? Just type codereview with no arguments and it will walk you through the entire setup.
codereview app.pycodereview src/auth.py src/db.py src/api.pygit add .
codereview --stagedcodereview --last 3codereview --diff origin/maincat suspicious_code.py | codereview --stdincodereview app.py --model gpt-4codereview app.py --provider ollamacodereview --setupcodereview works with any OpenAI-compatible API. Pick what works for you:
export GROQ_API_KEY="gsk_your_key_here"
codereview --init groq- Cost: Free tier, no credit card required
- Speed: Fastest inference available
- Model: Llama 3.3 70B
- Get a key: console.groq.com
# 1. Install Ollama
# Mac: Download from https://ollama.com
# Linux: curl -fsSL https://ollama.com/install.sh | sh
# 2. Pull a model
ollama pull llama3
# 3. Start the server
ollama serve
# 4. Initialize (no API key needed)
codereview --init ollama- Cost: Free forever
- Speed: Depends on your hardware
- Privacy: Code never leaves your machine
- Model: Any model Ollama supports
export OPENAI_API_KEY="sk-..."
codereview --init openai- Cost: Pay per token
- Model: GPT-3.5 Turbo (default), GPT-4 with --model gpt-4
- Get a key: platform.openai.com
export ANTHROPIC_API_KEY="sk-ant-..."
codereview --init anthropic- Cost: Pay per token
- Model: Claude 3 Haiku (default)
- Get a key: console.anthropic.com
Config is stored at ~/.codereview/config.json:
{
"provider": "groq",
"model": "llama-3.3-70b-versatile",
"base_url": "https://api.groq.com/openai/v1",
"max_tokens": 2048,
"temperature": 0.2
}API keys are never stored in the config file. They are read from environment variables only.
export CODEREVIEW_API_KEY="any-key" # Universal override
export CODEREVIEW_MODEL="gpt-4" # Override modelcodereview app.py --model gpt-4 --provider openaiYour Code --> codereview CLI --> LLM API --> Structured Terminal Output
(file/diff) (prompt builder) (any provider) (color-coded findings)
- Input โ codereview reads your file, git diff, staged changes, or stdin
- Prompt โ Constructs a focused review prompt with strict rules to prevent hallucinated issues
- LLM โ Sends to any OpenAI-compatible API (Groq, OpenAI, Anthropic, Ollama)
- Parse โ Extracts structured JSON from the LLM response
- Display โ Renders color-coded, severity-sorted findings in your terminal
- Structured output โ Severity ratings, file references, concrete suggestions
- No hallucinations โ Prompt engineering ensures the LLM only flags issues it can see in your code
- Works on diffs โ Review only what changed, not the entire codebase
- One command โ No copy-pasting into a browser
- Offline capable โ Run with Ollama, your code never leaves your machine
- Free โ No subscription required
$ codereview api/auth.py
Score: 3/10
๐ด CRITICAL โ Hardcoded JWT secret
Secret key is hardcoded on line 12.
Suggestion: Use environment variable: os.environ["JWT_SECRET"]
๐ด CRITICAL โ No password hashing
Passwords stored in plaintext on line 34.
Suggestion: Use bcrypt: bcrypt.hashpw(password, bcrypt.gensalt())
๐ก WARNING โ Token never expires
JWT tokens have no expiration set.
Suggestion: Add exp claim with timedelta
$ git add .
$ codereview --staged
Score: 8/10
๐ต INFO โ Consider adding error handling
The new API endpoint doesn't catch ConnectionError.
Suggestion: Wrap in try/except with retry logic.
$ codereview --last 3
Score: 9/10
โช STYLE โ Inconsistent naming
Mix of snake_case and camelCase in utils.py
Suggestion: Stick to snake_case per PEP 8.
Add to your GitHub Actions workflow:
name: Code Review
on: [pull_request]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- run: pip install ai-code-review
- run: codereview --diff origin/main
env:
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}ai-code-review/
โโโ codereview/
โ โโโ __init__.py # Version
โ โโโ cli.py # Command-line interface + first-run setup
โ โโโ reviewer.py # LLM API calls + response parsing
โ โโโ formatter.py # Rich terminal output formatting
โ โโโ git_utils.py # Git diff/file extraction utilities
โ โโโ config.py # Configuration management + API key handling
โโโ tests/
โ โโโ test_reviewer.py # Review parsing tests
โ โโโ test_git_utils.py # Git utility tests
โโโ setup.py
โโโ pyproject.toml
โโโ LICENSE
โโโ README.md
You haven't set your API key. The fastest free option:
# 1. Get a free key at https://console.groq.com
# 2. Set it:
export GROQ_API_KEY="gsk_your_key_here"
codereview --init groqYour HTTP client is being blocked by Cloudflare. Make sure you're up to date:
git pull
pip install -e .The model was deprecated. Re-initialize to get the latest model:
codereview --init groqOllama server isn't running:
ollama serveThen try again in a new terminal.
Dependencies didn't install. Run:
pip install rich requestsOr reinstall:
pip install -e .The install didn't add it to your PATH. Use directly:
python3 -m codereview.cli yourfile.pyOr create an alias:
echo 'alias codereview="python3 -m codereview.cli"' >> ~/.zshrc
source ~/.zshrcPRs welcome! This project is actively maintained.
git clone https://github.com/jaydendancer12/ai-code-review.git
cd ai-code-review
pip install -e .
pip install pytestpytest -v- Use type hints on all functions
- Write docstrings for all public functions
- Follow PEP 8
- Add tests for new features
- Fork the repo
- Create a feature branch: git checkout -b feat/my-feature
- Make changes and add tests
- Run pytest to verify
- Submit a PR with a clear description
- Directory scanning โ codereview src/ reviews all files recursively
- Config profiles โ switch between providers with codereview --profile work
- Output formats โ JSON, Markdown, SARIF for CI integration
- Git hooks โ auto-review on git commit
- VS Code extension โ review from your editor
- Review history โ track improvements over time
- Custom rules โ define your own review criteria
- Multi-language support โ language-specific review prompts
MIT โ see LICENSE
If codereview saved you from a bug, give it a โญ
Built by Jayden Dancer