OpenCode code review

AI code review for your pull requests, run by OpenCode in your own GitHub Actions.

Set it up Source on GitHub GitHub Marketplace

What it does

Every time someone opens or updates a pull request, OpenCode reads the change, follows it through your repo, and leaves one short comment with the defects the change introduces. A second pass tries to prove each finding wrong before you see it. The comment is edited on every push, never duplicated.

Here is a real one:

Changes needed: 1 thing. :/

1. add() subtracts instead of adds (app/calc.py:2). Restore return a + b

OpenCode review of 48d310a98, advisory. Reply if a finding is wrong.

Set it up in two steps NEW!

1. Add your model key as a secret. In your repo: Settings, Secrets and variables, Actions, New repository secret. Name it OPENROUTER_API_KEY. Get a key at openrouter.ai/keys.

2. Add this file as .github/workflows/opencode-review.yml:

name: OpenCode review

on:
  pull_request:
    types: [opened, synchronize, reopened, ready_for_review]
  issue_comment:
    types: [created]
  pull_request_review_comment:
    types: [created]

permissions: {}

concurrency:
  group: >-
    opencode-review-${{ github.event_name == 'pull_request'
    && format('pr-{0}', github.event.pull_request.number)
    || format('comment-{0}', github.event.comment.id) }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
  opencode:
    if: github.event_name == 'pull_request' || startsWith(github.event.comment.body, '/oc')
    runs-on: ubuntu-latest
    timeout-minutes: 10
    permissions:
      contents: read
      pull-requests: write
      issues: write
    steps:
      - uses: aloki-alok/opencode-review@v0
        with:
          model: openrouter/deepseek/deepseek-v4.1-flash
          api-key: ${{ secrets.OPENROUTER_API_KEY }}

That's it. Open a pull request and a review appears in a few minutes. :D

Two things to know:

Want it smarter about your repo? Copy templates/guide.md to .github/opencode-review/guide.md and write a few lines about what the project is and the rules that matter. The reviewer reads it first. It also reads your AGENTS.md, both from the base branch, so a pull request can't rewrite the rules for its own review.

Ask questions with /oc

Comment on any issue or pull request:

CommentDoes
/oc why does this retry twice?Answers in the thread with file:line references. On a pull request it reads the PR's code and diff.
/oc reviewRuns the review again and updates the review comment.

Only repo owners, members and collaborators can use commands. Bots and pull requests from forks are ignored.

How it works

  1. The action fetches the pull request's head, its base and their merge base, and builds the diff. Lockfiles, translations and minified files are left out.
  2. Find pass: OpenCode reads the diff, follows callers and types through the repo, and lists the defects it can back with a concrete scenario.
  3. Refute pass: a second OpenCode run tries to prove each finding wrong. Only the ones that survive are posted.
  4. The comment is written and edited in place. The job summary shows times, turns and the model.

Time is sized to the change: 90 seconds up to 20 changed code lines, and 240 for anything bigger. If a pass runs out of time, OpenCode is stopped and asked for what it found so far, so work is not thrown away. A new push cancels the review of the old commit.

Reading the comment

Starts withMeans
Changes needed: 2 things. :/Defects found and double-checked. Each names the file, the line and a fix.
Nothing blocking found. :)The review finished and found nothing worth blocking on.
... Stopped at the time limitIt ran out of time but kept what it found.
Review did not finish ... -_-Out of time with nothing to show. Comment /oc review to retry.
Review failed for ... :(Something is set up wrong, like a dead API key. The reason says what.

Security

Full details in SECURITY.md.

Settings

All optional except model and api-key.

InputDefaultWhat it does
modelrequiredOpenCode model as provider/model.
api-keyrequiredKey for the model's provider.
guide-path.github/opencode-review/guide.mdRepo guide, read from the base branch.
max-findings5Most findings in one comment.
review-budgetautoSized to the change, or turns:seconds.
ask-budget16:240turns:seconds for an answer.
allowed-associationsOWNER,MEMBER,COLLABORATORWho may use commands.
opencode-pathUse an opencode already on the runner.

Every input is in the README. To use another provider, change two lines:

with:
  model: anthropic/claude-sonnet-5-5
  api-key: ${{ secrets.ANTHROPIC_API_KEY }}

FAQ

Does it cost anything?

The action is free and MIT licensed. You pay your model provider for the tokens each review uses, and GitHub for runner minutes if your plan charges for them.

Can the AI change my code or approve my pull request?

No. The model can only read files. It has no edit, shell or web tools, and the action only posts comments. It never approves or blocks a merge.

Which models does it support?

Any model OpenCode supports, set as provider/model. OpenRouter is the default, and Anthropic, OpenAI, Google and others work with their own key.

Does it work on pull requests from forks?

No. Fork pull requests are skipped so your model key never reaches code from outside your team.

Can I run it on a self-hosted runner?

Yes, for private repos. The runner needs python3 3.11 or later, git and npm. Give reviews their own label so they don't wait behind builds. On a public repo the action refuses to run on a self-hosted runner unless you opt in.

How do I know a prompt or model change made it better?

The repo ships a bench that replays real bug-introducing pull requests several times each and reports the catch rate, false alarms, timing and the spread between runs. 17 public cases from httpx, click and flask are included.


GitHub stars Latest release

Found a wrong finding or a bug? Sign the guestbook (open an issue). ;)