A pull request is opened on your project. PR Agent reads the change and comments next to the lines it flags.
You can have it write the description, answer a question in the thread, try a fix, or look again after you push.
CodeRabbit and the other hosted reviewers charge per person and keep your keys. This is free to install. You pay the computer and the AI bill, not a seat per teammate. You pick who reads the code.
- Features
- Installation
- Verification
- Examples
- Recommended hosts
- Pratham's way of hosting
- Local development
- Data privacy
- Documentation
| Feature | When it runs | Command |
|---|---|---|
| Orchestrated review | PR opens in auto; trusted opens or maintainer approval for forks in approval. FEATURE_REVIEW_CADENCE=every_push also reviews each later admitted push |
/review on open PRs |
| PR description | PR opened when FEATURE_DESCRIBE=auto |
/describe |
| Verification | PR synchronize, or an authorized maintainer reply on an inline review thread, when FEATURE_VERIFICATION=auto |
/verify |
| Ask | On demand when FEATURE_ASK=manual |
/ask β¦ or mention the App bot |
| Triage autofix | On demand when FEATURE_TRIAGE=manual |
/triage |
| Cancel review | On demand | /cancel |
| Restart review | On demand (cancels the active run, latest commit) | /review force |
| Help | On demand | /help |
Defaults match .env.example and docs/features.md. FEATURE_REVIEW accepts manual, auto, or approval. off crashes startup. FEATURE_ASK and FEATURE_TRIAGE accept only off or manual. auto aborts startup. FEATURE_REVIEW_CADENCE accepts once or every_push. every_push together with FEATURE_REVIEW=manual crashes startup.
With no open findings, verification skips the agent. It checks the live head first. An older-head run completes degraded instead of clean and leaves any existing verification failure signal in place.
Review rules and slash matching
A review posts one ## PR Agent Review summary. Four specialists read the change: correctness, security, quality, and tests. They stay separate. A finding is posted only when it names the defect, what triggers it, the impact, and a bounded fix.
Slash commands are case-sensitive. The command must be the first non-empty line of a new comment. Who may run them is SLASH_ALLOWED_ASSOCIATIONS, default OWNER,MEMBER,COLLABORATOR. A mention matches the App bot login, not the word @bot.
/review force cancels the active review and starts a fresh one on the latest commit. /cancel stops new review output once the worker sees the cancellation. A request already in flight still finishes. After a close or a merge, /review asks you to reopen a closed pull request and refuses a merged one.
Asking the same comment twice does not post twice. Post a new comment to ask again. Set FEATURE_DESCRIBE=off, FEATURE_ASK=off, and the matching switch when you want that feature to stop calling the model.
The checks, the races, and recovery are in docs/features.md and docs/operations.md.
You need Docker Engine with Compose v2, a GitHub account that can create a GitHub App, one AI provider key, and a host GitHub can reach over HTTPS. A laptop can use a tunnel client instead of public TLS.
Create the GitHub App and paste a real private key before you start Compose. The example key in .env.example is not a real key. Both app containers exit if you start them without a generated App key.
- Open Register a GitHub App.
- Set Homepage URL to this repository (
https://github.com/prathamdby/pr-agent) or your public site. The form requires it. The App does not use it at runtime. - Leave Identifying and authorizing users off. Do not set a callback URL. This App does not use user login.
- Set Webhook URL to
https://<your-host>/webhooksonce you have HTTPS, or a tunnel URL that forwards to/webhooks. You can save the App first and add the URL after the host is up. - Set Webhook secret now. Copy the same value into
WEBHOOK_SECRETlater. - Subscribe to
pull_request,issue_comment,pull_request_review_comment,pull_request_review,workflow_run,check_suite,check_run, andstatus. DefaultFEATURE_REVIEW=approvalingests maintainer Approve only frompull_request_reviewsubmitted. Apull_requestworkflow starting on an awaiting fork's head is also an approval signal, except a fork author associated asCONTRIBUTOR,NONE,FIRST_TIME_CONTRIBUTOR, orFIRST_TIMER. - Set repository permissions (table below). Create the app, generate a private key, and copy the App ID.
- Install the app on the orgs or repos you want reviewed. Creating the App is not enough. If you pick Only select repositories, include the test repo.
| Permission | Access | Why |
|---|---|---|
| Issues | Read & write | PR conversation comments and reactions |
| Pull requests | Read & write | Reviews, inline threads, PR body for /describe |
| Contents | Read | Read code. Add write only for /triage pushes. |
| Metadata | Read | Required by GitHub for apps |
| Checks | Read & write | Review check run + CI summary inputs |
| Actions | Read | Required to subscribe to workflow_run. Condensed job logs when CI fails. |
| Commit statuses | Read | Legacy status events and CI facts. Add write if FEATURE_COMMIT_STATUS=true. |
Before a new review, the App checks its grants on that repository. Missing code or pull request reads, or missing permission to publish the review, stops the run before it reads the checkout or calls the model. Checks, commit statuses, labels, and reactions are optional. Missing access turns only those off and adds one notice. GitHub will not send workflow_run without Actions: Read. Skipping that grant drops workflow-start admission and the CI refresh when Actions finish. Conversation comments and labels accept either Issues or Pull requests at the required level. Reviews do not need Contents write.
A timeout or a rate limit is reported as an unavailable access check, not a missing permission. An already-published review can finish from saved receipts. What the review comment says about CI is in docs/operations.md.
git clone https://github.com/prathamdby/pr-agent.git
cd pr-agent
cp .env.example .envGITHUB_APP_ID=...
GITHUB_APP_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----"
WEBHOOK_SECRET=replace-with-a-strong-secret
PI_PROVIDER=openai
PI_MODEL=gpt-4o-mini
OPENAI_API_KEY=sk-...Paste the GitHub App private key as one line with \n for newlines, or as base64-encoded PEM. A literal multi-line PEM block is the form most likely to break Compose env_file. A placeholder or truncated PEM stops both app containers. Set the provider key before you expect a review to post. An empty OPENAI_API_KEY still boots.
Environment notes
WEBHOOK_SECRETmust match the secret you set on the GitHub App.- Compose overrides
ROLEandDATABASE_URLfor each service. Web and worker use hostnamepostgreson the compose network. TheDATABASE_URLin.env.example(localhost:5432) is for host integration tests and optional host processes. Local development publishes that port fromdocker-compose.dev.yml. Production Compose does not. - Default HTTP port is
7224(Compose and.env.example). Maintainer-local Compose also publishes worker7225. Barenode --env-file-if-exists=.env src/index.tswithoutPORTfalls back to3000. .env.examplesetsLOG_PRETTY=truefor a laptop. On a public host, setLOG_PRETTY=falseor drop the line so production defaults apply. Change the default Postgres password if the host is reachable.- On shutdown the worker stops taking jobs, waits briefly for in-flight work to record its outcome, and exits. Work that outlives that window is recovered by a later worker. Details: docs/operations.md.
- Full env catalog: docs/configuration.md. Feature switches: docs/features.md.
docker compose build
docker compose up -d| Service | Role | What it does |
|---|---|---|
postgres |
database | Durable webhook dedupe, duplicate metadata, work items, pg-boss jobs. Not published to the host. |
pr-agent-web |
ROLE=web |
POST /webhooks, GET /health, GET /ready on port 7224 |
pr-agent-worker |
ROLE=worker |
Consumes ack, review, ask, description, triage, verification, CI-projection, and retention queues |
postgres, pr-agent-web, and pr-agent-worker use restart: unless-stopped. A host reboot starts containers that were running, and docker compose stop keeps a service down across that reboot. A postgres container created before this policy stays down until you run docker compose up -d again. That recreate keeps the data volume. Do not run docker compose down -v.
Postgres is postgres:18.7-alpine. The data volume mounts at /var/lib/postgresql. A database created by Postgres 16 does not open on this image. Dump it with the old image and restore it into a new volume.
Migrations run when each process opens its Postgres pool.
Compose overrides and the production overlay
PR_AGENT_ENV_FILE=/abs/path/to/.env docker compose up -dIf host port 7224 is taken, map another host port and keep the container on 7224:
# under pr-agent-web in a compose override
ports:
- "7227:7224"Do not start docker-compose.prod.yml with the example DATABASE_URL. That overlay replaces the in-compose postgres hostname with ${DATABASE_URL}. Inside the container, localhost is the app container, not the database. The overlay also requires POSTGRES_DB, POSTGRES_USER, and POSTGRES_PASSWORD. Details: docs/operations.md.
If you change GitHub fields after the first start, recreate the app containers:
docker compose up -d --force-recreate pr-agent-web pr-agent-workerGitHub must reach POST /webhooks on the web service over HTTPS. Localhost is the documented exception. Production Compose publishes HTTP 7224 only. Laptop Caddy and the Cloudflare quick tunnel are docker-compose.dev.yml. Production TLS is still operator-owned.
Production. Put TLS in front of pr-agent-web (Caddy, nginx, a load balancer, your PaaS). Forward to container port 7224. A Caddy example lives in docs/operations.md.
Laptop. Use Local development. That Compose file starts a Cloudflare quick tunnel to the web process. Print the public webhook URL and paste it on the GitHub App. Do not point the App at Caddy. A hostname with no running cloudflared service drops every delivery. GitHub can show 200 from the relay while this process sees nothing.
LLM calls run on the worker only.
| What | Env vars | Used for |
|---|---|---|
| General primary | PI_PROVIDER, PI_MODEL |
Specialists, ask, describe, triage, verification, CI-summary authoring |
| Orchestrator (optional) | PI_ORCHESTRATOR_PROVIDER, PI_ORCHESTRATOR_MODEL |
Review orchestrator session; empty means inherit general primary |
| Fallback (optional) | PI_FALLBACK_PROVIDER, PI_FALLBACK_MODEL |
Second attempt onward via retry escalation; both must be set to enable |
PI_PROVIDER=openai
PI_MODEL=gpt-4o-mini
OPENAI_API_KEY=sk-...docker compose up -d --force-recreate pr-agent-workerProvider catalog and models.json
- Without a catalog, worker boot only checks that
PI_PROVIDERis a builtin. An unknownPI_MODELfalls through to that provider's first model API type. The first session then throwsprovider.model_not_found. Web never validates the model id. A presentmodels.jsondoes fail worker boot on a missing selection. - pr-agent loads
OPENAI_API_KEY,ANTHROPIC_API_KEY, andGOOGLE_GENERATIVE_AI_API_KEYinsrc/settings/slices/models.ts. If the Google alias is empty, pi-ai also readsGEMINI_API_KEYfrom the process environment. Other Pi providers use their usual env vars on the worker (for exampleDEEPSEEK_API_KEY,OPENROUTER_API_KEY,GROQ_API_KEY). Provider catalog: pi-ai. - Optional custom catalog: copy
models.json.example, placemodels.jsonat the repo root beforedocker build(copied to/app/models.jsonwhen present), add a runtime mount on both web and worker (the committed compose file does not), or setMODELS_JSON_PATH. Details: docs/operations.md. - Custom provider fields, a minimal proxy example, and verification: docs/configuration.md.
curl -sS http://127.0.0.1:7224/health # ok
curl -sS http://127.0.0.1:7224/ready # ready (web: Postgres up)Then open a small PR on an installed repo. Comment /help as an owner, member, or collaborator (SLASH_ALLOWED_ASSOCIATIONS, default OWNER,MEMBER,COLLABORATOR).
| Expect | Where |
|---|---|
| Eyes reaction when a review is admitted | PR or triggering comment |
| One notice and no eyes reaction | A fork still waiting for approval |
## PR Agent Review progress comment |
PR conversation (auto review or /review) |
| Inline findings on the Files tab | When the bot can anchor them |
| Final summary replaces the progress comment | Same conversation comment |
Default FEATURE_VERIFICATION=auto spends tokens on pushes that still have open findings, and on an authorized maintainer reply in an inline review thread. Switch it to manual or off if that bill is too high. What the probes miss, and what a quiet pull request usually means, is below.
What the probes do not prove
Those probes do not prove GitHub can reach /webhooks, that the worker has a provider key, or that App permissions match what publish code calls. An empty OPENAI_API_KEY still boots.
Worker readiness (consumers registered + Postgres/pg-boss) is checked inside the Compose healthcheck on the worker container (GET /ready). The image HEALTHCHECK hits /health, which is process liveness only. Compose overrides the worker check. From the host you only published the web port by default.
A contributor or outside commenter gets webhook 200 and no reply. That looks like a dead worker.
If webhooks return 200 but the PR stays quiet, check the worker logs, the provider key, App install (not just App create), slash allowlist, and the queue runbook: docs/agent-work-ops.md. docker compose logs -f pr-agent-worker.
Production hosting still ships one stack: Compose postgres, pr-agent-web, and pr-agent-worker. A panel or reverse proxy only terminates TLS and forwards to web. Do not add another production or panel compose file, publish Postgres, or expose the worker. Maintainer-local work uses docker-compose.dev.yml.
Start the VPS at about 2 vCPU and 4 GB RAM. Web, worker, Postgres, and a panel will not fit well on 1 GB.
| VPS | Why pick it |
|---|---|
| Hetzner Cloud | Usually the cheapest 4 GB plan. NVMe, 20 TB traffic, sites in EU and the US. |
| Hostinger VPS | Simple checkout. Their Docker Manager can start a Compose file if you do not want a separate panel. |
| DigitalOcean | Clear docs and a large marketplace. More regions. You pay more per GB of RAM. |
Hetzner is the default pick for this App. Hostinger is the default pick if you want a control panel from the VPS vendor. DigitalOcean is fine when you already have an account.
| Panel | What it gives you |
|---|---|
| Dokploy | Native Compose deploy. Built-in Traefik. Let's Encrypt. A domain you paste into the GitHub App. |
| Coolify | Same idea. Traefik by default. Caddy is an option. Set the domain on the web service. |
| Caddy, nginx, or a load balancer | Fine if you already run one. Point it at container port 7224. Example: docs/operations.md. |
CapRover can sit in front of HTTP, but its Compose import is a subset. Prefer Dokploy, Coolify, or a proxy you already know.
On the panel, route only pr-agent-web. The public URL is https://<your-domain>/webhooks. Leave Compose Postgres unpublished. Keep DATABASE_URL on hostname postgres inside the compose network. If the panel asks for an internal port, use 7224.
Pratham runs this App on all of his repositories, with every feature left on.
He runs it on a VPS with Dokploy. Dokploy's Traefik publishes the web service on a domain and issues the certificate. That HTTPS URL is what he puts on the GitHub App (https://<domain>/webhooks). The worker stays private. Postgres stays on the compose network.
Primary provider is OpenCode Go ($10 AI subscription). Model is Meta Muse Spark 1.3 Contributor.
That is his operator setup. The install path above still uses this repo's Compose file and the Pi provider env vars (PI_PROVIDER, PI_MODEL, and the matching API key). This repo does not add a Dokploy file or a second runtime.
Use this when you are changing the code. For production hosting, use Installation.
docker compose -f docker-compose.dev.yml up -d --build
node dev/print-public-webhook-url.cjsThat one file starts Postgres, Caddy, web, worker, and a Cloudflare quick tunnel to the web process. dev/mock.env has fake App id and webhook secret. The boot script generates a throwaway PEM at process start. Those values are not a real App.
The print script writes the public webhook URL (https://<id>.trycloudflare.com/webhooks). Paste that on the GitHub App. The hostname changes when you recreate cloudflared. Update the App field after a restart.
| URL | Role |
|---|---|
printed trycloudflare /webhooks |
GitHub App webhook (public HTTPS) |
printed trycloudflare /health |
Web liveness through the tunnel |
https://web.localhost/health |
Web liveness on the laptop |
https://web.localhost/ready |
Web Postgres ping on the laptop |
https://web.localhost/webhooks |
Durable intake on the laptop (not for GitHub) |
https://worker.localhost/health |
Worker liveness |
https://worker.localhost/ready |
Worker consumers plus Postgres |
curl -k https://web.localhost/health
curl -k https://web.localhost/ready
curl -k https://worker.localhost/health
curl -k https://worker.localhost/readyIf web.localhost does not resolve, add 127.0.0.1 web.localhost worker.localhost to /etc/hosts, or pass --resolve web.localhost:443:127.0.0.1 to curl.
Caddy uses an internal certificate. GitHub will not trust it. The Compose cloudflared service is the public path. Do not add a host smee or cloudflared process unless that service cannot reach Cloudflare.
Published ports bind 127.0.0.1. Binding 80 and 443 on all interfaces exposes the laptop on the LAN.
If you already run docker compose up -d postgres or a published docker run Postgres on 5432, stop that container first so host port 5432 is free. This file uses its own postgres-data-dev volume. compose down keeps that volume.
For live App deliveries, put real GitHub fields in .env and start with PR_AGENT_ENV_FILE=.env docker compose -f docker-compose.dev.yml up -d --build.
Do not start docker-compose.yml at the same time. That file is the self-host path. It has no Caddy, no tunnel, and does not publish Postgres.
Tests, Node and npm, and the landing site
docker-compose.dev.yml publishes Postgres at localhost:5432. Integration tests use that URL. Unit tests do not need the database, Caddy, or the tunnel.
npm run test
DATABASE_URL=postgres://pr_agent:pr_agent@localhost:5432/pr_agent npm run test:integration
npm run check:codeVitest does not load .env for you. Export DATABASE_URL in the shell for integration runs. Inventory-only suite that may skip DB cases and the Docker-dependent compose suite when those dependencies are absent: npm run test:integration:inventory.
For host development, install Node 24.22.1 LTS with npm 11.19.1 or a newer npm 11 release, then run npm ci. The supported Node range is ^24.22.1. npm run dev watches imported TypeScript and loads .env when present. Restart after environment or configuration changes. Give web and worker distinct PORT values.
One root package-lock.json covers the backend and landing workspace. Use npm ci --workspaces=false for backend build dependencies, npm ci --omit=dev --workspaces=false for backend production, or npm ci --workspace=pr-agent-landing --include-workspace-root=false for the site. .npmrc owns the seven-day release-age policy, disabled dependency lifecycle scripts, legacy peer resolution, and strict engines. The release-age exclusions are @tanstack/redact and @interfere/landmines.
More scripts and edge cases: docs/operations.md.
The marketing site under site/ is a separate workspace package (pr-agent-landing). It is not required to run the bot. Agents should read /llms.txt or /agents.md, query GET /llms?query= / GET /llms/json?query=, and can fetch the page as markdown from /index.md or by sending Accept: text/markdown to /. Every endpoint is described in /openapi.json.
Agent sessions keep computation in memory. Retries start fresh sessions; saved work and publication evidence still protect recovery. Unused encrypted session snapshots and phase checkpoints are removed by migration 036.
Review recovery stores redacted structured briefs, reports, publication plans, and summary inputs on your infrastructure. Finding details, fix directions, and suggested code can contain code excerpts. It does not retain raw checkout files, prompts, reasoning, or transcripts. Migration 037 adds this separate store. Work-item retention deletes its rows. Disabling scheduled retention leaves the rows.
| Topic | Rule |
|---|---|
| Self-hosted | Postgres, pg-boss, webhook bodies, and work-item state stay on your infrastructure. You own the GitHub App credentials. |
| LLM providers | Review text leaves your network only when the worker calls PI_PROVIDER / PI_MODEL. Read that provider's data policy. |
| Ask safety | /ask applies outbound redaction before posting. Questions aimed at bot internals can get a short refusal without an LLM call. |
| Retention | Agent event rows older than 30 days are deleted with the other cleanup. Set AGENT_EVENTS_RETENTION_SECONDS to 0 to keep them. |
Repository searches, including /triage, share a bounded output budget. A truncated search is incomplete, not proof that code is absent. Sensitive-path gates still apply. See workspace search diagnostics.
Duplicate deliveries retain local metadata only: incoming delivery ID, body fingerprint, and dedupe guard reason, not another body copy. WEBHOOK_EVENTS_RETENTION_SECONDS deletes this evidence by its own arrival age (30 days by default). RETENTION_ENABLED=false leaves it unpurged. These patterns do not prove malicious intent. See duplicate-delivery inspection.
Logging
Coalesced CI deliveries keep their identities on your retained projection job. Worker logs still name the original delivery. See the queue runbook to trace an absorbed delivery.
If a replacement review owns the progress comment, late specialist ticks from the earlier run are skipped or rejected with an ownership warning.
Structured logs use evlog on your hosts. LOG_REDACT defaults to true and strips secret-shaped substrings. AppError messages, contexts, raw values, causes, arrays, objects, and circular references are recursively sanitized at log and analytics boundaries; safe codes and identifiers remain available. See the telemetry redaction policy.
PostHog
PR Agent can send work and webhook events to PostHog. Set POSTHOG_PROJECT_TOKEN in .env. Leave it empty and nothing is sent, including AI traces. Use POSTHOG_HOST only if your project is not on the default host.
A configured project also receives one AI trace per worker execution. That trace includes credential-redacted prompts, reasoning, and tool arguments and results. Text is bounded, and a cut is marked. Tool spans include a hash of the redacted input, and execute includes a hash of the script. A cancelled or failed session also includes its last turns, the last tool input and output, partial findings, and why it stopped. Repository text can still be sensitive. Removing the token is the opt-out. Ordinary work and webhook events stay metadata. They do not include prompts or tool payloads. Work events can include how the pull request checkout was fetched, with Git exit codes but no Git output. Classified failures can include sanitized, bounded error messages. Raw error payloads are not sent.
The work item is the session. The execution is the trace. Query posthog.ai_events for content. PostHog keeps that content for 30 days. Model, tokens, latency, and ids remain after the content drop. AI events are billed. Set a billing limit. They do not update person profiles.
Env catalog: docs/configuration.md.
| Document | What it covers |
|---|---|
| DeepWiki | Ask questions against this repository |
| Features | FEATURE_* modes and slash commands |
| Configuration | Env vars, defaults, and code constants |
| Operations | What the app does on a pull request |
| Topology | Web, worker, and Postgres |
| Queue runbook | Inspect and recover a stuck run |
| Development | Where to change the code |
| Domain terms | Product vocabulary |




