/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:1
Install the GitHub app
Head over to github.com/apps/opencode-agent. Make sure it’s installed on the target repository.
2
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
3
Store the API keys in secrets
In your organization or project settings, expand Secrets and variables on the left and select Actions. Add the required API keys.
Configuration
The GitHub Action supports the following configuration options: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: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.