Skip to main content
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. 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:
This will walk you through installing the GitHub app, creating the workflow, and setting up secrets.

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-in GITHUB_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
For scheduled events, the 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
For 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
For 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
This is useful for enforcing specific review criteria, coding standards, or focus areas relevant to your project.

Usage Examples

Here are some examples of how you can use OpenCode in GitHub:

Explain an Issue

Add this comment in a GitHub issue:
OpenCode will read the entire thread, including all comments, and reply with a clear explanation.

Fix an Issue

In a GitHub issue, say:
And OpenCode will create a new branch, implement the changes, and open a PR with the changes.

Review PRs and Make Changes

Leave the following comment on a GitHub PR:
OpenCode will implement the requested change and commit it to the same 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.
When commenting on specific lines, OpenCode receives:
  • The exact file being reviewed
  • The specific lines of code
  • The surrounding diff context
  • Line number information
This allows for more targeted requests without needing to specify file paths or line numbers manually.

FAQ

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.
Yes, OpenCode works with both public and private repositories. For private repositories, session sharing is disabled by default.
Use the prompt configuration option to provide custom instructions for how OpenCode should process requests in your workflow.
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.
At minimum, OpenCode needs id-token: write. For full functionality (creating PRs, commenting), it needs contents: write, pull-requests: write, and issues: write.