Precision-first AI code review — run locally, deploy anywhere
Pascal is an open-source AI code review agent that runs on your infrastructure — hooked to your local model (Ollama, vLLM, llama.cpp) or any BYOK provider (OpenRouter, OpenAI, Anthropic, NVIDIA NIM, Nous, Google). It posts review comments directly to GitHub PRs via a GitHub App, with a precision-first approach that minimizes noise while catching real issues.
| Feature | Pascal |
|---|---|
| Local-first | Run on your GPU via http://localhost:8080/v1 — zero API costs, zero data leaves your machine |
| BYOK | Bring your own keys: OpenRouter, OpenAI, Anthropic, NVIDIA, Nous, Google |
| GitHub native | Real GitHub App — posts inline comments, respects your repo permissions |
| Precision gates | Confidence thresholds, category-aware filtering, spend caps per review |
| Deploy anywhere | Single Docker image: docker run -e ... pascal — webhook server + worker in one container |
| Open source | MIT licensed — audit, extend, self-host |
- Python 3.12+
- A GitHub App with Pull requests: Read & Write, Contents: Read, Webhooks: Active
- A local model server (Ollama, vLLM, llama.cpp) on
http://localhost:8765/v1or an API key for a remote provider
git clone https://github.com/dooodledad/Pascal.git
cd Pascal
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env# Required for GitHub delivery
GITHUB_APP_ID=123456
GITHUB_APP_PRIVATE_KEY_PATH=/path/to/private-key.pem
GITHUB_WEBHOOK_SECRET=your-webhook-secret
REVIEW_MAX_REVIEW_COST_USD=0.50
REVIEW_MAX_COMPLETION_TOKENS=2048
# Local model (Ollama, vLLM, llama.cpp on port 8080)
LOCAL_API_KEY=your-local-key
REVIEW_MODEL=auto # or pin a specific model id
# Remote providers (pick one or more)
OPENROUTER_API_KEY=sk-or-...
NVIDIA_API_KEY=...
NOUS_API_KEY=...unset PYTHONPATH
python -m delivery.server
# Listens on http://127.0.0.1:8765/github/webhookunset PYTHONPATH
python -m delivery.worker --once # process one job and exit
# or omit --once to poll continuouslydocker build -t pascal .
docker run -d \
-e GITHUB_APP_ID=123456 \
-e GITHUB_APP_PRIVATE_KEY_PATH=/app/private-key.pem \
-e GITHUB_WEBHOOK_SECRET=your-webhook-secret \
-e REVIEW_MAX_REVIEW_COST_USD=0.50 \
-e REVIEW_MAX_COMPLETION_TOKENS=2048 \
-e LOCAL_API_KEY=your-local-key \
-v /host/path/to/key.pem:/app/private-key.pem:ro \
-v pascal-data:/app/data \
-p 8765:8765 \
pascalTo have a fully working end-to-end review system, create and configure a GitHub App:
- Go to Settings → Developer settings → GitHub Apps → New GitHub App
- GitHub App name: e.g.,
pascal-code-review(must be unique) - Homepage URL: your repo URL (e.g.,
https://github.com/dooodledad/Pascal) - Webhook: Active ✓
- Webhook URL:
https://<your-domain>/github/webhook(or use ngrok for local testing:https://<ngrok-id>.ngrok.io/github/webhook) - Webhook secret: generate a random string (store in
.envasGITHUB_WEBHOOK_SECRET)
- Webhook URL:
- Permissions (Repository permissions):
- Pull requests: Read & write
- Contents: Read
- Commit statuses: Read & write (optional, for status feedback)
- Issues: Read & write (optional, for future conversational features)
- Metadata: Read (auto-granted)
- Subscribe to events (Repository events):
- Pull request ✓
- Issue comment ✓ (for future conversational commands like
@pascal review)
- Where can this GitHub App be installed?: Any account (or specific org)
- Click Create GitHub App
- After creation, scroll to Private keys → Generate a private key
- Save the
.pemfile securely (e.g.,~/.config/pascal/private-key.pem) - Set path in
.env:GITHUB_APP_PRIVATE_KEY_PATH=/path/to/private-key.pem
- In the GitHub App settings, go to Install App
- Choose the account/org and repositories where Pascal should review PRs
- Note the Installation ID (shown in URL after install:
.../installations/<ID>) — not needed in config but useful for debugging
- The secret you set in step 1 must match
GITHUB_WEBHOOK_SECRETin your.env - Used to verify
X-Hub-Signature-256on every webhook payload
# Terminal 1: start ngrok tunnel to your local server
ngrok http 8765
# Terminal 2: run the webhook server
unset PYTHONPATH
python -m delivery.server
# Listens on http://127.0.0.1:8765/github/webhook- Copy the ngrok HTTPS URL (e.g.,
https://abc123.ngrok.io) and update the GitHub App's Webhook URL tohttps://abc123.ngrok.io/github/webhook
- Open a PR in a repo where the app is installed
- Watch the webhook server logs: you should see
webhook ... queued job=... - Run the worker:
python -m delivery.worker --once - Check the PR: Pascal should post a review (dry-run by default, set
REVIEW_DRY_RUN=falsefor live)
- Dry-run (default): fetches PR, reviews, stores result, does not post to GitHub
- Live: set
REVIEW_DRY_RUN=falsein.env→ posts inline comments (or APPROVE on clean PRs)
| Event | Action | Description |
|---|---|---|
pull_request |
opened, reopened, synchronize, ready_for_review | Queues a review |
issue_comment |
created | Future: @pascal review / @pascal explain <n> commands |
- GitHub App created with correct permissions
- Private key stored securely (not in repo)
- Webhook URL points to production server (HTTPS)
- Webhook secret matches
.env -
REVIEW_DRY_RUN=falsefor live reviews - Server runs behind reverse proxy (nginx/Traefik) with TLS
- Worker runs continuously (
python -m delivery.workerwithout--once) - Monitoring: watch
delivery.sqlite3size, worker logs
┌─────────────────────────────────────────────────────────────────┐
│ GitHub Webhook │
└──────────────────────────┬──────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ delivery/server (HTTP) │
│ • Verifies X-Hub-Signature-256 │
│ • Durable queue (SQLite) │
└──────────────────────────┬──────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ delivery/worker (queue consumer) │
│ • Leases jobs, enforces budget │
│ • Fetches PR via GitHub App │
│ • Calls engine.reviewer │
└──────────────────────────┬──────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ engine/ │
│ • Routes to provider (OpenRouter, local, NVIDIA, Nous, ...) │
│ • Precision gate (confidence, category thresholds) │
│ • Spend attestation per review │
└──────────────────────────┬──────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ GitHub Review API │
│ • Posts inline comments (dry-run by default) │
└─────────────────────────────────────────────────────────────────┘
Each review call returns an object envelope: a short PR summary (written at
the top of the review body) plus the findings. Findings that fix on a single
added line carry a GitHub suggestion block you can apply in one click.
Pascal uses a route chain — each entry in engine/config.py:ROUTES defines a provider endpoint, model(s), and the environment variable that must be set for the route to be active. A route without its key is skipped entirely (never invented, never billed).
RouteSpec("local", "http://localhost:8765/v1", "auto", "LOCAL_API_KEY"),
RouteSpec("openrouter","https://openrouter.ai/api/v1", [...], "OPENROUTER_API_KEY"),
RouteSpec("nvidia", "https://integrate.api.nvidia.com/v1", "z-ai/glm-5.3-flash", "NVIDIA_API_KEY"),Selection priority:
REVIEW_BASE_URL+REVIEW_API_KEY→ explicit single route (experiment hatch)REVIEW_MODEL→ matches any model id inside a route, promotes that route- Default → first keyed route in chain order
Cost guardrail: REVIEW_MAX_BLENDED_RATE (default $0.30/Mtok) — routes whose cheapest eligible endpoint exceeds this refuse and fall through. Only enforced where a pricing catalog exists (OpenRouter).
| Variable | Default | Description |
|---|---|---|
REVIEW_MODEL |
— | Pin a model id from the route chain |
REVIEW_BASE_URL |
— | Explicit route override (experiment hatch) |
REVIEW_API_KEY |
— | Key for explicit route |
REVIEW_MIN_CONFIDENCE |
0.7 | Gate threshold (0–1) |
REVIEW_ALLOW_NITS |
false | Allow nit-picking comments |
REVIEW_REPO_CONTEXT |
false | Fetch surrounding source of changed files (contents API, head SHA) as prompt context |
REVIEW_MAX_BLENDED_RATE |
0.3 | $/Mtok cap (OpenRouter only) |
REVIEW_BATCH_WAIT_S |
1800 | Batch timeout seconds |
REVIEW_MAX_REVIEW_COST_USD |
— | Hard cap per review (worker) |
REVIEW_MAX_COMPLETION_TOKENS |
— | Max output tokens (worker) |
GITHUB_WEBHOOK_HOST |
127.0.0.1 | Webhook bind address |
GITHUB_WEBHOOK_PORT |
8765 | Webhook port |
REVIEW_DELIVERY_DB |
data/delivery.sqlite3 | SQLite ledger path |
Any OpenAI-compatible server on http://localhost:8080/v1 works:
- Ollama:
ollama serve(runs on 11434; useollama serve --port 8080or proxy) - vLLM:
vllm serve <model> --port 8080 - llama.cpp:
./server -m model.gguf --port 8080
Set LOCAL_API_KEY in .env (any non-empty string) and REVIEW_MODEL=auto. In Docker, use REVIEW_BASE_URL=http://host.docker.internal:8080/v1 to reach the host model.
# Run tests
unset PYTHONPATH
.venv/bin/python -m pytest -q
# Run a single review against a local PR record
.venv/bin/python -m scripts.simple_review <pr.jsonl>pascal/
├── engine/ # Core review pipeline
│ ├── config.py # Routes, settings, env loading
│ ├── client.py # Provider routing, spend attestation
│ ├── reviewer.py # Prompt → model → gate → comments
│ ├── prompt.py # System prompts (v6, v11, v14, v15...)
│ └── providers.py # OpenRouter catalog, pricing, pins
├── delivery/ # GitHub App webhook + worker
│ ├── server.py # HTTP webhook ingress
│ ├── worker.py # Queue consumer, dry-run review
│ ├── github.py # GitHub App auth, PR fetch, review post
│ ├── store.py # SQLite queue, leases, spend ledger
│ └── entrypoint.sh # Docker: server (bg) + worker (fg)
├── scripts/ # simple_review: one-off local review runner
└── tests/ # Unit + integration tests
- Fork → branch → PR
- All changes pass
/reviewloop (independent reviewer, zero findings) - Tests green:
pytest -q - No secrets committed (
.envis gitignored)
MIT — see LICENSE.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Built with precision. Deployed with confidence.