Opencode Github
OpenCode can deeply integrate with the GitHub workflow, allowing AI to directly participate in Issue, Pull Request, and code review processes.
**Trigger AI to automatically execute tasks by entering /opencode or /oc in comments.**
**OpenCode GitHub = Turn AI into your automated development member, directly participating in Issue, PR, and code processes.**
* * *
## 1. Core Capabilities
* **Issue Analysis:** Automatically understand issues and provide explanations
* **Auto Fix:** Create branches and submit PRs
* **Code Review:** Analyze PRs and suggest improvements
* **Automated Execution:** Run based on GitHub Actions
**Features:**
* Runs in your own GitHub Runner
* Secure and controllable, no dependency on external servers to execute code
* * *
## 2. Quick Installation (Recommended)
Run in GitHub project root directory:
opencode github install
This command will automatically complete:
* Install GitHub App
* Create GitHub Actions workflow
* Guide API Key configuration
* * *
## 3. Manual Installation (Advanced)
### 1. Install GitHub App
Visit:
https://github.com/apps/opencode-agent
Install to your repository
* * *
### 2. Add Workflow File
Create file:
.github/workflows/opencode.yml
Example:
name: opencode on: issue_comment: types: pull_request_review_comment: types: 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
* * *
### 3. Configure Secrets
In GitHub repository:
* Go to Settings β Secrets β Actions
* Add API Key (e.g., ANTHROPIC_API_KEY)
* * *
## 4. Configuration Parameters
| Parameter | Description |
| --- | --- |
| model | Model to use (required) |
| agent | Specify agent |
| prompt | Custom prompt |
| share | Whether to share session |
| token | GitHub Token |
**Description:**
* Default uses OpenCode GitHub App's Token
* Can also use GITHUB_TOKEN or PAT
* * *
## 5. Supported Trigger Events
| Event | Description |
| --- | --- |
| issue_comment | Comment triggers /opencode |
| pull_request_review_comment | Code line comment triggers |
| issues | Issue created/updated |
| pull_request | PR auto review |
| schedule | Scheduled task |
| workflow_dispatch | Manual trigger |
* * *
## 6. Common Usage
### 1. Explain Issue
In Issue comment:
/opencode explain this issue
AI will summarize and explain the issue
* * *
### 2. Auto Fix Issue
/opencode fix this
Automatically:
* Create branch
* Modify code
* Submit Pull Request
* * *
### 3. Modify PR
Delete the attachment from S3 when the note is removed /oc
Execute modification directly on PR
* * *
### 4. Code Line-level Operation (Very Powerful)
Comment on PR's Files page:
/oc add error handling here
OpenCode will automatically get:
* File path
* Line number
* Context diff
No need to manually specify location
* * *
## 7. Scheduled Tasks (Automation)
Example: Weekly TODO scan
on: schedule: - cron: "0 9 * * 1"
Example prompt:
Review the codebase for TODO comments and summarize them
**Note:**
* Scheduled tasks must provide prompt
* Requires write permissions (contents / pull-requests)
* * *
## 8. PR Auto Review
Example:
on: pull_request: types: [opened, synchronize]
Default behavior:
* Analyze code quality
* Detect potential bugs
* Suggest improvements
* * *
## 9. Issue Auto Classification
Can automatically process new Issues, for example:
* Filter spam accounts
* Auto reply suggestions
* Supplement documentation
**Note:**
* issues event must provide prompt
* * *
## 10. Custom Prompts (Advanced Usage)
Can override default behavior:
prompt: | Review this pull request: - Check for bugs - Suggest improvements
Used for:
* Unify code standards
* Customize review standards
* Automate team processes
* * *
## 11. Security and Permissions
Recommended permission configuration:
permissions: id-token: write contents: write pull-requests: write issues: write
**Description:**
* Principle of least privilege
* Only open necessary capabilities
YouTip