Why This Matters
Traditional code review is a bottleneck. You push code, wait for reviewers, hope they’re available, and ping them when you’re stuck. What if you could have an AI reviewer available 24/7 that never gets tired, never says “I’ll review it later,” and actually understands your codebase?
That’s exactly what OpenCode brings to your GitHub organization. It’s an agentic coding CLI that integrates directly into your GitHub workflow — comment /oc on an issue or PR, and it gets to work.
My Actual Setup
Here’s how I run OpenCode in my GitHub organization:
graph TB
subgraph "GitHub Events"
I[Issue Comment]
PR[PR Review Comment]
end
subgraph "GitHub App"
APP[GitHub App<br/>your-github-app]
end
subgraph "OpenCode Action"
OC[anomalyco/opencode/github]
end
subgraph "GitHub Actions"
GT[Generate Token]
C[Create PRs]
end
I --> APP
PR --> APP
APP --> GT
GT --> OC
OC --> C
I use a GitHub App for authentication instead of API keys:
- GitHub App —
your-github-apphandles all authentication - Workflow — Reusable
_opencode.ymltemplate managed via Terraform - Model —
opencode/minimax-m2.5-freefor all tasks
The workflow file (.github/workflows/_opencode.yml) is managed as Terraform code:
# In modules/repository/opencode.tf
resource "github_repository_file" "opencode_ci" {
repository = github_repository.this.name
file = ".github/workflows/_opencode.yml"
content = file("${path.module}/templates/_opencode.yml")
commit_message = "chore: update _opencode.yml file"
overwrite_on_create = true
}The GitHub App is configured with environment variables:
| Variable | Value |
|---|---|
CI_AI_APP_CLIENT_ID |
<your-client-id> |
CI_AI_MODEL_NAME |
opencode/minimax-m2.5-free |
CI_AI_GIT_USER_NAME |
your-bot[bot] |
Required secrets are centrally stored in GitHub’s Secrets Manager (referenced via
bws_id) and made accessible to all repositories within the organization. Through the GitHub management plane, workflows across the entire organization are centrally controlled—so updates only need to be made once, rather than manually applied to each repository.
Architecture
The integration works through GitHub Actions triggered by various events:
graph TB
subgraph "GitHub Events"
I[Issue Comment]
PR[PR Review Comment]
P[Pull Request]
S[Schedule]
end
subgraph "OpenCode Action"
OC[anomalyco/opencode/github]
end
subgraph "Actions"
C[Create Comments]
B[Create Branches]
PRS[Open PRs]
R[Review PRs]
end
I --> OC
PR --> OC
P --> OC
S --> OC
OC --> C
OC --> B
OC --> PRS
OC --> R
Installation
The quickest way to set up OpenCode in your repository:
opencode github installThis walks you through:
- Installing the OpenCode GitHub App
- Creating the workflow file
- Setting up required secrets
Manual Setup
If you prefer manual configuration:
-
Install the GitHub App — Go to github.com/apps/opencode-agent and install it on your repository
-
Add the workflow — Create
.github/workflows/_opencode.yml:
# .github/workflows/_opencode.yml
name: OpenCode Private Agent
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
permissions: {}
jobs:
opencode:
if: |
contains(github.event.comment.body, '/oc') ||
contains(github.event.comment.body, '/opencode')
runs-on: ${{ vars.RUNNER || 'ubuntu-latest' }}
permissions:
contents: read
steps:
- name: Generate GitHub App Token
id: generate-token
uses: actions/create-github-app-token@v1.10c78c7865c340bc4f6099eb2f838309f1e8c3
with:
client-id: ${{ vars.CI_AI_APP_CLIENT_ID }}
private-key: ${{ secrets.CI_AI_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 1
persist-credentials: true
token: ${{ steps.generate-token.outputs.token }}
- name: Run OpenCode
uses: anomalyco/opencode/github@v1.14.25
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
with:
model: ${{ vars.CI_AI_MODEL_NAME || 'opencode/minimax-m2.5-free' }}
use_github_token: true
share: false-
Set up the GitHub App — Create a GitHub App with:
- Repository contents (read/write)
- Issues (read/write)
- Pull requests (read/write)
-
Add secrets — Store
CI_AI_APP_PRIVATE_KEYin repository secrets
What OpenCode Can Do
Explain Issues
Comment on any issue:
/opencode explain this issueOpenCode reads the entire issue thread and provides a clear explanation. This is invaluable for catching up on old issues or understanding complex bug reports.
Fix Issues
Want OpenCode to implement a fix? Just ask:
/opencode fix thisOpenCode will:
- Create a new branch
- Implement the changes
- Open a PR with the fix
Review Specific Code
Comment directly on lines in the PR’s “Files” tab:
/oc add error handling hereOpenCode receives the exact file, line numbers, and diff context to make precise changes.
Automated PR Reviews
Run OpenCode automatically on every PR:
# .github/workflows/opencode-review.yml
name: opencode-review
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
jobs:
review:
runs-on: ${{ vars.RUNNER || 'ubuntu-latest' }}
permissions:
contents: read
pull-requests: write
steps:
- name: Generate GitHub App Token
id: generate-token
uses: actions/create-github-app-token@v1.10.78
with:
client-id: ${{ vars.CI_AI_APP_CLIENT_ID }}
private-key: ${{ secrets.CI_AI_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- uses: actions/checkout@v6
with:
fetch-depth: 1
persist-credentials: true
token: ${{ steps.generate-token.outputs.token }}
- uses: anomalyco/opencode/github@v1.14.25
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
with:
model: ${{ vars.CI_AI_MODEL_NAME || 'opencode/minimax-m2.5-free' }}
use_github_token: true
prompt: |
Review this pull request:
- Check for code quality issues
- Look for potential bugs
- Suggest improvementsWithout a custom prompt, OpenCode defaults to reviewing the PR.
Issue Triage
Automatically triage new issues:
# .github/workflows/opencode-triage.yml
name: Issue Triage
on:
issues:
types: [opened]
jobs:
triage:
runs-on: ${{ vars.RUNNER || 'ubuntu-latest' }}
permissions:
contents: write
issues: write
steps:
- name: Generate GitHub App Token
id: generate-token
uses: actions/create-github-app-token@v1.10.78
with:
client-id: ${{ vars.CI_AI_APP_CLIENT_ID }}
private-key: ${{ secrets.CI_AI_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- uses: actions/checkout@v6
with:
fetch-depth: 1
persist-credentials: true
token: ${{ steps.generate-token.outputs.token }}
- name: Generate GitHub App Token
id: generate-token
uses: actions/create-github-app-token@v1.10.78
with:
client-id: ${{ vars.CI_AI_APP_CLIENT_ID }}
private-key: ${{ secrets.CI_AI_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 1
persist-credentials: true
token: ${{ steps.generate-token.outputs.token }}
- name: Run OpenCode
uses: anomalyco/opencode/github@v1.14.25
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
with:
model: ${{ vars.CI_AI_MODEL_NAME || 'opencode/minimax-m2.5-free' }}
use_github_token: true
prompt: |
Review this issue. If there's a clear fix or relevant docs:
- Provide documentation links
- Add error handling guidance for code examples
Otherwise, do not comment.Scheduled Automation
Run OpenCode on a schedule — perhaps weekly dependency updates or codebase housekeeping:
# .github/workflows/opencode-scheduled.yml
name: Scheduled OpenCode Task
on:
schedule:
- cron: "0 9 * * 1" # Every Monday at 9am UTC
jobs:
opencode:
runs-on: ${{ vars.RUNNER || 'ubuntu-latest' }}
permissions:
contents: write
issues: write
steps:
- name: Generate GitHub App Token
id: generate-token
uses: actions/create-github-app-token@v1.10.78
with:
client-id: ${{ vars.CI_AI_APP_CLIENT_ID }}
private-key: ${{ secrets.CI_AI_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 1
persist-credentials: true
token: ${{ steps.generate-token.outputs.token }}
- name: Run OpenCode
uses: anomalyco/opencode/github@v1.14.25
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
with:
model: ${{ vars.CI_AI_MODEL_NAME || 'opencode/minimax-m2.5-free' }}
use_github_token: true
prompt: |
Review the codebase for any TODO comments and create a summary.
If you find issues worth addressing, open an issue to track them.Configuration Options
| Option | Description | Example |
|---|---|---|
model |
AI model to use (required). Format: provider/model |
opencode/minimax-m2.5-free |
prompt |
Custom prompt to override default behavior | Review this PR for bugs |
use_github_token |
Use the generated app token (default: false) | true |
share |
Share the OpenCode session (default: true for public repos) | false |
Environment Variables
When using a GitHub App, configure these variables:
| Variable | Description |
|---|---|
CI_AI_APP_CLIENT_ID |
GitHub App client ID |
CI_AI_MODEL_NAME |
Model name (defaults to opencode/minimax-m2.5-free) |
CI_AI_APP_PRIVATE_KEY |
GitHub App private key (stored as secret) |
GitHub App Token Generation
Instead of API keys, use the actions/create-github-app-token action:
- name: Generate GitHub App Token
id: generate-token
uses: actions/create-github-app-token@v1.10.78
with:
client-id: ${{ vars.CI_AI_APP_CLIENT_ID }}
private-key: ${{ secrets.CI_AI_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}This gives the workflow a temporary token with the GitHub App’s permissions, so PRs appear to come from your bot user (your-bot[bot]).
Real-World Usage
Here’s how I use OpenCode in my organization:
- Issue triage — New issues get an initial response with relevant docs
- PR reviews — Every PR gets an automated review before human review
- Quick fixes —
/oc fix thisfor obvious bugs - Code explanations — Understanding complex code in PRs
The key insight: OpenCode isn’t replacing human review — it’s augmenting it. It catches obvious issues, provides initial feedback, and handles tedious tasks so humans can focus on architecture and design decisions.
What Most People Get Wrong
-
“You need API keys” — Use a GitHub App instead. No external API providers needed, and PRs appear from your bot user.
-
“It’s a replacement for human review” — No, it’s a force multiplier. Humans still review architecture and complex logic.
-
“It’s only for simple fixes” — It can handle complex multi-file changes. The limit is your prompt clarity.
When to Use / When NOT to Use
| Use OpenCode | Do it manually |
|---|---|
| Bug fixes with clear solutions | Architecture decisions |
| Documentation improvements | Security reviews |
| Code style fixes | Performance optimization |
| Triage and initial feedback | Complex refactoring |
| Quick experiments | API design reviews |
Getting Started
- Create a GitHub App — Go to your repository settings → Developer settings → GitHub Apps → New GitHub App
- Configure permissions — Give it contents, issues, and pull-requests read/write
- Install the app — Install it on your repository
- Add variables — Set
CI_AI_APP_CLIENT_IDandCI_AI_MODEL_NAMEin repository variables - Add secrets — Add
CI_AI_APP_PRIVATE_KEYfrom your GitHub App’s PEM file - Create the workflow — Add
.github/workflows/_opencode.ymlwith the workflow above - Try it — Comment
/oc explain this issueon any issue
That’s it. Your organization now has an AI coding assistant available 24/7.