GitHub
Use OpenCode in GitHub issues and pull-requests.
OpenCode integrates with your GitHub workflow. Mention /opencode or /oc in your comment, and OpenCode will execute tasks within your GitHub Actions runner.
Features
- Triage issues: Ask OpenCode to look into an issue and explain it to you.
- Fix and implement: Ask OpenCode to fix an issue or implement a feature. And it will work in a new branch and submits a PR with all the changes.
- Secure: OpenCode runs inside your GitHub’s runners.
Installation
Run the following command in a project that is in a GitHub repo:
opencode github installThis will walk you through installing the GitHub app, creating the workflow, and setting up secrets.
Manual Setup
Or you can set it up manually.
-
Install the GitHub app
Head over to github.com/apps/opencode-agent. Make sure it’s installed on the target repository.
-
Add the workflow
Add the following workflow file to
.github/workflows/opencode.ymlin your repo. Make sure to set the appropriatemodeland required API keys inenv..github/workflows/opencode.yml name: opencodeon: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-latestpermissions:id-token: writesteps:- name: Checkout repositoryuses: actions/checkout@v6with:fetch-depth: 1persist-credentials: false- name: Run OpenCodeuses: anomalyco/opencode/github@latestenv:ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}with:model: anthropic/claude-sonnet-4-20250514# share: true# github_token: xxxx -
Store the API keys in secrets
In your organization or project settings, expand Secrets and variables on the left and select Actions. And add the required API keys.
Configuration
-
model: The model to use with OpenCode. Takes the format ofprovider/model. This is required. -
agent: The agent to use. Must be a primary agent. Falls back todefault_agentfrom config or"build"if not found. -
share: Whether to share the OpenCode session. Defaults to true for public repositories. -
prompt: Optional custom prompt to override the default behavior. Use this to customize how OpenCode processes requests. -
token: Optional GitHub access token for performing operations such as creating comments, committing changes, and opening pull requests. By default, OpenCode uses the installation access token from the OpenCode GitHub App, so commits, comments, and pull requests appear as coming from the app.Alternatively, you can use the GitHub Action runner’s built-in
GITHUB_TOKENwithout installing the OpenCode GitHub App. Just make sure to grant the required permissions in your workflow:permissions:id-token: writecontents: writepull-requests: writeissues: writeYou can also use a personal access token(PAT) if preferred.
Supported Events
OpenCode can be triggered by the following GitHub events:
| Event Type | Triggered By | Details |
|---|---|---|
issue_comment | Comment on an issue or PR | Mention /opencode or /oc in your comment. OpenCode reads context and can create branches, open PRs, or reply. |
pull_request_review_comment | Comment on specific code lines in a PR | Mention /opencode or /oc while reviewing code. OpenCode receives file path, line numbers, and diff context. |
issues | Issue opened or edited | Automatically trigger OpenCode when issues are created or modified. Requires prompt input. |
pull_request | PR opened or updated | Automatically trigger OpenCode when PRs are opened, synchronized, or reopened. Useful for automated reviews. |
schedule | Cron-based schedule | Run OpenCode on a schedule. Requires prompt input. Output goes to logs and PRs (no issue to comment on). |
workflow_dispatch | Manual trigger from GitHub UI | Trigger OpenCode on demand via Actions tab. Requires prompt input. Output goes to logs and PRs. |
Schedule Example
Run OpenCode on a schedule to perform automated tasks:
name: Scheduled OpenCode Task
on: schedule: - cron: "0 9 * * 1" # Every Monday at 9am UTC
jobs: opencode: runs-on: ubuntu-latest permissions: id-token: write contents: write pull-requests: write issues: write steps: - name: Checkout repository uses: actions/checkout@v6 with: persist-credentials: false
- name: Run OpenCode uses: anomalyco/opencode/github@latest env