Skip to main content

OpenCode GitHub Integration

Use Zeldoc.ai inside GitHub issues and pull requests with OpenCode's GitHub integration. Mention /opencode or /oc in a comment and OpenCode will execute tasks on a GitHub Actions runner using the Zeldoc.ai model.

What you can do​

  • Triage issues — Ask OpenCode to read an issue and explain it.
  • Fix and implement — Ask OpenCode to fix a bug or implement a feature. It works in a new branch and opens a pull request with the changes.
  • Review PRs — Comment on a pull request or on specific lines of code and OpenCode will respond with context-aware suggestions.

Prerequisites​

  • A GitHub repository with admin access (to add secrets and workflows)
  • A Zeldoc.ai API key — see Generate an API key

Setup​

1. Add the workflow file​

Create .github/workflows/opencode.yml in your repository:

name: opencode
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]

jobs:
opencode:
if: |
contains(github.event.comment.body, '/oc') ||
contains(github.event.comment.body, '/opencode')
runs-on: ubuntu-24.04
permissions:
id-token: write
contents: write
pull-requests: write
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 20
persist-credentials: false

- name: Configure git identity
run: |
git config --global user.email "opencode@github.com"
git config --global user.name "opencode"

- name: Run OpenCode
uses: anomalyco/opencode/github@latest
env:
ZELDOC_API_KEY: ${{ secrets.ZELDOC_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
model: zeldoc/zdev
use_github_token: true
Why no opencode.json provider config?

Zeldoc.ai is a built-in OpenCode provider, so the GitHub Action recognizes zeldoc/zdev without any extra config. You only need to provide the ZELDOC_API_KEY environment variable — OpenCode picks it up automatically.

2. Add the API key as a secret​

  1. Go to your repository Settings → Secrets and variables → Actions.
  2. Click New repository secret.
  3. Name it ZELDOC_API_KEY and paste your Zeldoc.ai API key as the value.
  4. Click Add secret.
Keep your key safe

Your API key grants access to Zeldoc.ai. Never commit it to version control or share it. GitHub secrets are encrypted and never exposed in logs.

3. Try it out​

Leave a comment on any issue or pull request:

/opencode explain this issue

OpenCode will read the issue thread and reply with an explanation. For more examples, see Usage.

Configuration options​

The workflow with block supports several options:

OptionDescriptionRequired
modelThe model to use, in provider/model-id format.Yes
agentThe agent to use. Falls back to default_agent from config.No
promptCustom prompt to override the default behavior.No
shareWhether to share the session. Defaults to true for public repos.No
use_github_tokenUse GITHUB_TOKEN instead of the OpenCode App token exchange.No

For Zeldoc.ai, always set model: zeldoc/zdev and use_github_token: true.

Usage​

Explain an issue​

Comment on a GitHub issue:

/opencode explain this issue

OpenCode reads the entire thread and replies with a clear explanation.

Fix an issue​

/opencode fix this

OpenCode creates a new branch, implements the fix, and opens a pull request.

Review or change code in a PR​

Comment on a pull request:

Delete the attachment from S3 when the note is removed /oc

OpenCode implements the change and commits it to the same PR.

Review specific lines​

Leave a comment directly on code lines in the PR's Files tab:

/oc add error handling here

OpenCode receives the file path, line numbers, and diff context for a targeted response.

Supported events​

The workflow above triggers on issue and PR comments. You can also configure OpenCode for other GitHub events:

EventTriggerNotes
issue_commentComment on an issue or PRMention /opencode or /oc.
pull_request_review_commentComment on PR code linesOpenCode gets file, line, and diff context.
issuesIssue opened or editedRequires a prompt input.
pull_requestPR opened, synced, or reopenedUseful for automated reviews.
scheduleCron-based scheduleRequires a prompt input.
workflow_dispatchManual trigger from Actions tabRequires a prompt input.

Automated PR review with a separate CI config​

For an automated, review-only workflow, use a restricted OpenCode config that prevents the agent from editing files. This is especially useful when your normal project config allows implementation work.

This example assumes your repository already tracks an opencode.json file. Add a second tracked file named opencode-ci.json:

{
"$schema": "https://opencode.ai/config.json",
"permission": {
"*": "deny",
"read": {
"*": "allow",
"*.env": "deny",
"*.env.*": "deny"
},
"grep": "allow",
"edit": "deny",
"bash": {
"*": "deny",
"git status*": "allow",
"git diff*": "allow",
"git log*": "allow",
"git show*": "allow",
"git checkout -- *": "allow"
},
"glob": "allow"
}
}

Add the exact lint, test, or build commands for your project to the bash allowlist if you want OpenCode to run them. Keep the catch-all deny rule first; OpenCode uses the last matching permission rule.

If those commands create untracked files, also allow a project-specific cleanup command. git checkout -- . restores tracked files but does not remove untracked files.

Then use the CI config in the review workflow:

name: opencode-review

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
review:
runs-on: ubuntu-24.04
timeout-minutes: 30
concurrency:
group: opencode-review-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions:
id-token: write
contents: read
pull-requests: write
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
persist-credentials: false

- name: Use the review-only OpenCode config
run: |
git update-index --skip-worktree opencode.json
cp opencode-ci.json opencode.json

- name: Run OpenCode review
uses: anomalyco/opencode/github@latest
env:
ZELDOC_API_KEY: ${{ secrets.ZELDOC_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
model: zeldoc/zdev
use_github_token: true
prompt: |
Review this pull request:
- Check for code quality issues
- Look for potential bugs
- Suggest improvements

IMPORTANT: After running any build, test, or lint commands, restore
the working directory by running `git checkout -- .`. Before
finishing, run `git status --porcelain` and ensure it returns no
changes. Do not leave generated or modified files in the working tree.
Why overwrite opencode.json?

OpenCode merges its configuration sources instead of replacing them. A file set through OPENCODE_CONFIG is loaded before the project's opencode.json, so the project config can override it and non-conflicting settings from both files are preserved. OPENCODE_CONFIG_CONTENT has higher precedence, but it is also merged.

Temporarily copying the CI config over opencode.json replaces the project's primary config instead of layering another file on top. Other sources, such as the repository's .opencode directory, still apply. The skip-worktree flag prevents the temporary replacement from appearing as a change in the review checkout.

Keep review workflows clean

After OpenCode responds, the GitHub Action checks whether the working tree is dirty. If lint, test, or build commands changed files, the Action treats those changes as implementation work and tries to commit and push them. The cleanup instruction restores tracked changes before the Action performs that check.

Only use git checkout -- . in a review-only workflow where all changes should be discarded. Do not add this instruction to workflows that ask OpenCode to implement or fix code.

Scheduled task example​

name: Scheduled OpenCode Task
on:
schedule:
- cron: "0 9 * * 1" # Every Monday at 9am UTC
jobs:
opencode:
runs-on: ubuntu-24.04
permissions:
id-token: write
contents: write
pull-requests: write
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Configure git identity
run: |
git config --global user.email "opencode@github.com"
git config --global user.name "opencode"
- name: Run OpenCode
uses: anomalyco/opencode/github@latest
env:
ZELDOC_API_KEY: ${{ secrets.ZELDOC_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
model: zeldoc/zdev
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.
Custom prompts

For issues, schedule, and workflow_dispatch events, the prompt input is required because there is no comment to extract instructions from.