Any AI CLI
--run claude, codex, gemini, opencode, cursor or
ollama:<model>. Add your own runner in config.
diff2ai turns your Git diff into a focused, line-numbered review prompt, runs it through the AI CLI you already use, cross-checks the findings, and posts them as inline PR comments. diff2ai itself makes no network calls.
npm i -g diff2ai
diff2ai builds the prompt from your actual change — line-numbered diff, commit
messages, file summary — with a strict output schema, so what comes back has
severities, exact file:line references and concrete fixes.
git diff and a merged PR.Use one piece or the whole flow — prompt only, an AI run, a consensus review, or a CI gate.
--run claude, codex, gemini, opencode, cursor or
ollama:<model>. Add your own runner in config.
Personas review in parallel; a judge merges, dedupes and scores
Consensus: k/N.
Line-numbered diffs plus commit messages and a file summary give the model intent and exact locations.
Inline review comments on GitHub PRs via gh, or a formatted MR note on
GitLab via glab.
A GitHub Action, SARIF export for code scanning and
--fail-on HIGH severity gates.
Pure git. Nothing leaves your machine unless you run an AI or post a comment, with your own credentials.
Token-budgeted batches that split at file and hunk boundaries, with template overhead counted.
Diffs and commit messages are untrusted input: instructions hidden in a PR are reported, not followed.
One AI review can invent problems or miss real ones. Consensus mode runs independent persona passes, has a judge validate every finding against the diff, then re-checks the judge locally.
Line-numbered diff, commit messages and a file summary, wrapped in a strict review schema.
--templateSuggested from diff signals, or picked by one small AI call. You approve, and see the cost first.
--personas autoBug Hunter, Security Auditor, Performance, API, Test Engineer — each a full, independent pass.
--concurrency 3Gets the diff as ground truth plus all reviews; validates, deduplicates and scores agreement.
Consensus: 3/3Every finding's file and lines are verified against the hunks locally. Misses are demoted.
0 tokens
Cost, honestly: every reviewer is a full model invocation over your
whole diff, plus the judge. Use 2–3 targeted personas for risky PRs and plain
--run
for everyday changes.
Line numbers make findings verifiable even in a plain web chat. The packaged templates enforce numbered issue blocks: no preamble, no diff echo.
diff --git a/src/auth/session.ts b/src/auth/session.ts@@ -38,6 +38,9 @@ export async function getSession(req) { 38 const token = req.headers.authorization; - const user = await db.users.findByToken(token); 39 + const user = await db.query( 40 + `SELECT * FROM users WHERE token = '${token}'` 41 + ); 42 if (!user) return null;
New-file line numbers on every kept and added line; removed lines have none.
## 1) Severity: CRITICAL | Type: Security Title: Parameterize the session token query Affected: - src/auth/session.ts:39-41 Explanation: The Authorization header is interpolated into raw SQL, so any caller can inject queries. The helper it replaced was parameterized. Proposed fix: ~~~ts const user = await db.query( 'SELECT * FROM users WHERE token = $1', [token]); ~~~ Consensus: 3/3 reviewers
Severity, type, exact location, a fix and how many reviewers agreed.
In a terminal, --run opens the tool's chat seeded with the review. In
scripts and CI it runs headless, read-only where the tool supports it, and saves the
review as *.response.md. Large prompts never go through argv.
| Runner | CLI | Headless mode |
|---|---|---|
claude |
Claude Code |
claude -p --tools "" — no tools, no saved session
|
codex |
OpenAI Codex CLI | codex exec --sandbox read-only --ephemeral - |
gemini |
Gemini CLI | prompt on stdin, --output-format text |
opencode |
opencode | opencode run --agent plan — read-only agent |
cursor |
Cursor CLI | -p --mode ask — read-only, reads the prompt file |
ollama:<model> |
Ollama | ollama run <model> — fully local |
your-tool |
Anything with a CLI |
Define it under runners in .aidiff.json
|
Run any runner on each PR, post inline comments, write SARIF and fail the build on a verified severity.
Findings on changed lines become review comments; the rest go in the review body.
Upload to GitHub code scanning, or export findings as JSON.
fail-on: CRITICAL in the action,
--fail-on HIGH locally or in a pre-push hook.
The action never executes code from the PR.
name: AI review on: pull_request: permissions: contents: read pull-requests: write jobs: review: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: nurettincoban/diff2ai@v1 env: ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} with: runner: claude # codex, gemini, opencode, ... iterations: 3 # 1 = single pass min-severity: MEDIUM fail-on: CRITICAL # optional gate
| diff2ai | Hosted review bots | Pasting a diff into a chat | |
|---|---|---|---|
| Where your code goes | Only to the AI CLI you choose — or nowhere, in prompt-only mode | The vendor's service | The chat provider |
| Model | Claude, Codex, Gemini, OpenCode, Cursor, local Ollama, your own | The vendor's choice | Whatever you paste into |
| Cost | Your existing AI subscription or API key | Usually a per-seat subscription | Your chat subscription |
| Hallucination defense | Persona consensus + judge + mechanical diff check | Varies | None |
| Line references | Line-numbered diff, verified against the hunks | Yes | Often wrong |
| Setup | npm i -g diff2ai |
App install and org permissions | None |
Requires Node.js 22.13+ and git. Every command works from any subdirectory of the repo.
$ npm i -g diff2ai $ diff2ai doctor # repo state + installed AI CLIs $ diff2ai interactive # guided wizard
$ diff2ai review --run claude $ diff2ai review --run claude --iterations 3 $ diff2ai review --pr 128 --run codex
$ diff2ai review --copy # paste into any chat; findings come back # in the same structured format
$ diff2ai post latest --dry-run $ diff2ai post latest --pr 128 $ diff2ai export latest --format sarif --out r.sarif
Free and open source under the MIT license. Contributions welcome.