Getting Started
Reviewer Lib is AI code review powered by OpenAI. Give it a code snippet or a pull-request diff and get back structured, actionable findings — as a library, a CLI, or a GitHub Action. Works with code in any language (Node is only needed to run it).
Installation
Requires Node.js 20+ (the library depends on
openaiv6).
npm install -D reviewer-libYou'll also need an OpenAI API key (OPENAI_API_KEY).
Three ways to use it
review()— structured findings (severity, file, line, fix). Best for PR comments and CI gates. Recommended.- CLI — run a review from the terminal or CI, no code to write.
- GitHub Action — add a PR review check in a few lines.
By default the library uses the OpenAI Chat Completions API with o4-mini, a reasoning model chosen for the fewest false positives. Pass any chat model as the model argument.
Quick start — the library
import { Reviewer, formatFindings, toReviewComments, hasBlockingFindings } from 'reviewer-lib';
const reviewer = new Reviewer(process.env.OPENAI_API_KEY!); // default model: o4-mini
// Pass asDiff: true to review a unified diff — findings then carry file + line.
const findings = await reviewer.review(diff, { asDiff: true, language: 'typescript' });
console.log(formatFindings(findings)); // markdown summary for a PR comment
const comments = toReviewComments(findings); // [{ path, line, body }] for GitHub inline comments
if (hasBlockingFindings(findings, 'high')) process.exit(1); // fail CI on high+ severityEach Finding has: severity (critical | high | medium | low), category, file, line, message, and suggestion. See the API reference for the full surface.
Quick start — the CLI
# review your working changes locally
git diff origin/main | npx reviewer-lib review --fail-on high
# fetch a PR diff and post inline comments + a summary
npx reviewer-lib review --pr 54 --post --fail-on highMore in the CLI guide.
Quick start — the GitHub Action
- uses: JuliettKhar/reviewer-lib@v3
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
fail-on: highSee the GitHub Action guide for the recommended config.
Next steps
- Models & false positives — why
o4-miniis the default, and how to cut noise. - API reference — every method, option, and helper.