Warning
Deprecated. ai-review now lives in
acid-info/ai-tools and is
no longer maintained here. To migrate, change the uses: line of your workflow.
.github/ai-review.yml and the secrets stay the same.
- uses: acid-info/ai-review/.github/workflows/ai-review.yml@v1
+ uses: acid-info/ai-tools/.github/workflows/ai-review.yml@ai-review/v1Shared AI pull-request reviewer for logos-co, status-im and acid-info. Two models review
the same diff independently, a third merges their findings, and the result is posted as a single
PR review with inline comments.
Consumers call this repo as a reusable workflow pinned to @v1. Upgrading the tool or
swapping a model is one edit here, not three edits across three repos.
- Someone comments
/ai-reviewon a pull request. - The job checks out the caller's default branch -- never the PR head -- for config and
guideline files, and checks out this repo for
review.mjs. - The PR diff is fetched over the GitHub API by number. Lockfiles and generated paths are filtered out, and the rest is packed smallest-first into a token budget.
- Claude and Codex each review the diff. A cheap synthesis model (
synth_model, atsynth_effort) deduplicates, marks issues both models found, drops nits and sorts by severity. - Findings at or above the severity threshold are posted, anchored to diff lines where possible. The review body ends with an API usage table: tokens (in, cached, out) and estimated cost per call, plus the total.
If one provider is down the review degrades to a single model rather than failing. If that is
synth_model's provider, synthesis moves to the surviving reviewer's model. If synthesis
fails it falls back to a local merge. Partial reviews say so in the posted body.
review.mjs has zero npm dependencies and runs on Node 22's global fetch. Keep it that
way -- no build step, no package.json. That property is what makes this repo cheap to maintain.
Create .github/workflows/ai-review.yml on your default branch:
# AI PR review. The reviewer lives in acid-info/ai-review -- edit it there.
# Trigger: comment "/ai-review" on any PR. This file must be on the default branch.
name: AI PR Review
on:
issue_comment:
types: [created]
permissions:
contents: read
pull-requests: write
issues: write
jobs:
review:
uses: acid-info/ai-review/.github/workflows/ai-review.yml@v1
secrets:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}issue_comment workflows only run from the default branch. You cannot test this from a PR
branch: merge the file first, then comment /ai-review on a PR. Merging early is inert -- the
workflow does nothing until someone types the command.
@v1 is a moving tag. A consumer that wants immutability pins the commit SHA instead; the
reusable workflow checks itself out at job.workflow_sha either way, and refuses to run if
that is empty.
Pass the two secrets explicitly. Do not use secrets: inherit: the reviewer has no business
seeing an NPM_TOKEN or a database URL.
| Secret | Required |
|---|---|
ANTHROPIC_API_KEY |
At least one of the two |
OPENAI_API_KEY |
At least one of the two |
With only one key set, the run is a single-model review and says so in the posted comment. With
neither, it exits with Missing required env var(s).
GITHUB_TOKEN is supplied by Actions. The caller's permissions: block bounds the job -- a
reusable workflow cannot escalate beyond what the caller granted.
Only comments whose author_association is OWNER, MEMBER or COLLABORATOR. A drive-by
comment on a public repo cannot spend your API budget.
Optional, at .github/ai-review.yml on the caller's default branch. Three keys only:
| Key | Effect |
|---|---|
extra_ignore |
Appended to the built-in ignore list. Use this one. |
ignore |
Replaces the built-in ignore list wholesale. Escape hatch. |
guidelines_files |
Priority list of guideline files; the first that exists wins. |
# Generated artifacts specific to this repo, added to the shared defaults.
extra_ignore:
- 'flake.lock'
- 'packages/types/src/payload.ts'
guidelines_files:
- AGENTS.md
- CLAUDE.mdModels, synth_effort, min_severity_to_post and max_diff_tokens are owned centrally in DEFAULTS in
review.mjs. Setting one in a repo config logs a warning and is ignored -- a repo that could
pin its own model would put the tool back in three places.
Built-in ignores cover lockfiles, *.min.js, *.map, dist/, vendor/, __snapshots__/ and
*.generated.*.
AGENTS.md is special-cased in guidelines_files: the root file plus any AGENTS.md in a
directory the diff touches are all loaded, so a monorepo package can carry its own instructions.
Set SKIP_GUIDELINES=1 to review without any guideline files.
Edit DEFAULTS in review.mjs, then check two other places in the same file:
PRICES-- add the new model, or the cost line and the API usage table report it as unpriced and exclude it from the total. Cache reads cost a tenth of input by default; setcacheReadto override that fraction.EFFORT_MODELS/REASONING_MODELS-- model-family regexes gatingoutput_config.effort(Claude) andreasoning.effort(OpenAI). A model string that does not match silently loses the effort config rather than erroring. Newer Claude models need it; Haiku 4.5, Sonnet 4.5 and older reject it. Non-reasoning OpenAI models rejectreasoning.effort.
synth_model picks its provider from its name: claude-* goes to Anthropic, anything else to
OpenAI. synth_effort is sent in that provider's format. Keep it to a level both providers
accept (low, medium, high): if synth_model's provider is down, the same effort is sent to
the other provider's reviewer model.
Then tag: git tag -f v1 && git push -f origin v1. All three consumers pick it up on their next
run -- no consumer edit.
DRY_RUN=1 prints the review that would be posted instead of posting it. It suppresses only the
posting: both reviewers still run and make real, paid API calls.
DRY_RUN=1 REPO=logos-co/logos-web PR_NUMBER=153 \
ANTHROPIC_API_KEY=sk-ant-... OPENAI_API_KEY=sk-... \
GITHUB_TOKEN=$(gh auth token) node review.mjsTo check config handling for free, run with a junk key. loadConfig() and the diff fetch both
run before the first API call, so the config warnings and the Reviewing N files ... line print,
then the run dies at a 401 without spending anything:
ANTHROPIC_API_KEY=not-a-key REPO=logos-co/logos-web PR_NUMBER=153 \
GITHUB_TOKEN=$(gh auth token) node review.mjsThe reusable workflow itself has no runnable form without a caller -- workflow_call cannot be
dispatched directly. End-to-end changes have to be proved on a real PR in a consumer repo.
- The job checks out the caller's default branch, never the PR head. Config, guideline files and the reviewer program are all trusted code.
- The PR diff arrives over the GitHub API by number, as data. PR-authored code and config never execute in the job.
- Model output derives from untrusted diff content, so
@mentionsare defused with a zero-width space before posting -- a crafted diff cannot make the bot ping arbitrary users or teams. - Inline comments are anchored only to lines that exist on the right side of a reviewed hunk; GitHub rejects an entire review if any anchor is out of range.
Whoever can push the v1 tag executes code in every consumer repo, with that repo's
GITHUB_TOKEN and API keys. Restrict who can push tags here.
Each posted review ends with a hidden HTML comment carrying the findings as JSON:
<!-- ai-review:findings {"v":1,"pr":153,"issues":[...]} -->
MIT.