Skip to content

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:

Terminal window
opencode github install

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
    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-latest
    permissions:
    id-token: write
    steps:
    - name: Checkout repository
    uses: actions/checkout@v6
    with:
    fetch-depth: 1
    persist-credentials: false
    - name: Run OpenCode
    uses: anomalyco/opencode/github@latest
    env:
    ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
    with:
    model: anthropic/claude-sonnet-4-20250514
    # share: true
    # github_token: xxxx
  3. 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 of provider/model. This is required.

  • agent: The agent to use. Must be a primary agent. Falls back to default_agent from 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_TOKEN without installing the OpenCode GitHub App. Just make sure to grant the required permissions in your workflow:

    permissions:
    id-token: write
    contents: write
    pull-requests: write
    issues: write

    You can also use a personal access token(PAT) if preferred.


Supported Events

OpenCode can be triggered by the following GitHub events:

Event TypeTriggered ByDetails
issue_commentComment on an issue or PRMention /opencode or /oc in your comment. OpenCode reads context and can create branches, open PRs, or reply.
pull_request_review_commentComment on specific code lines in a PRMention /opencode or /oc while reviewing code. OpenCode receives file path, line numbers, and diff context.
issuesIssue opened or editedAutomatically trigger OpenCode when issues are created or modified. Requires prompt input.
pull_requestPR opened or updatedAutomatically trigger OpenCode when PRs are opened, synchronized, or reopened. Useful for automated reviews.
scheduleCron-based scheduleRun OpenCode on a schedule. Requires prompt input. Output goes to logs and PRs (no issue to comment on).
workflow_dispatchManual trigger from GitHub UITrigger 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
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