/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. It will work in a new branch and submit 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: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.yml in your repo. Make sure to set the appropriate model and required API keys in env..github/workflows/opencode.yml
Configuration
The GitHub Action supports the following configuration options:| Option | Required | Description |
|---|---|---|
model | Yes | The model to use with OpenCode. Takes the format of provider/model. |
agent | No | The agent to use. Must be a primary agent. Falls back to default_agent from config or "build" if not found. |
share | No | Whether to share the OpenCode session. Defaults to true for public repositories. |
prompt | No | Optional custom prompt to override the default behavior. Use this to customize how OpenCode processes requests. |
token | No | 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. Alternatively, you can use the runner’s built-in GITHUB_TOKEN or a personal access token (PAT) if preferred. |
Using GITHUB_TOKEN
You can use the GitHub Action runner’s built-inGITHUB_TOKEN without installing the OpenCode GitHub App. Just make sure to grant the required permissions in your workflow:
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:.github/workflows/opencode-scheduled.yml
prompt input is required since there’s no comment to extract instructions from.
Pull Request Review Example
Automatically review PRs when they are opened or updated:.github/workflows/opencode-review.yml
pull_request events, if no prompt is provided, OpenCode defaults to reviewing the pull request.
Issue Triage Example
Automatically triage new issues. This example filters to accounts older than 30 days to reduce spam:.github/workflows/opencode-triage.yml
issues events, the prompt input is required since there’s no comment to extract instructions from.
Custom Prompts
Override the default prompt to customize OpenCode’s behavior for your workflow:.github/workflows/opencode.yml
Usage Examples
Here are some examples of how you can use OpenCode in GitHub:Explain an Issue
Add this comment in a GitHub issue:Fix an Issue
In a GitHub issue, say:Review PRs and Make Changes
Leave the following comment on a GitHub PR:Review Specific Code Lines
Leave a comment directly on code lines in the PR’s “Files” tab. OpenCode automatically detects the file, line numbers, and diff context to provide precise responses.- The exact file being reviewed
- The specific lines of code
- The surrounding diff context
- Line number information
FAQ
Do I need to install the OpenCode GitHub App?
Do I need to install the OpenCode GitHub App?
No, you can use the built-in
GITHUB_TOKEN instead. However, the OpenCode GitHub App provides a better user experience as commits and comments appear as coming from the app rather than the GitHub Actions bot.Can OpenCode work with private repositories?
Can OpenCode work with private repositories?
Yes, OpenCode works with both public and private repositories. For private repositories, session sharing is disabled by default.
How do I customize OpenCode's behavior?
How do I customize OpenCode's behavior?
Use the
prompt configuration option to provide custom instructions for how OpenCode should process requests in your workflow.Can I run OpenCode on multiple events?
Can I run OpenCode on multiple events?
Yes, you can create multiple workflow files or use multiple event triggers in a single workflow to run OpenCode on different events with different configurations.
What permissions does OpenCode need?
What permissions does OpenCode need?
At minimum, OpenCode needs
id-token: write. For full functionality (creating PRs, commenting), it needs contents: write, pull-requests: write, and issues: write.