diff --git a/github/action.yml b/github/action.yml index 0b7367ded42..d22d19990ae 100644 --- a/github/action.yml +++ b/github/action.yml @@ -13,6 +13,10 @@ inputs: description: "Share the opencode session (defaults to true for public repos)" required: false + prompt: + description: "Custom prompt to override the default prompt" + required: false + runs: using: "composite" steps: @@ -27,3 +31,4 @@ runs: env: MODEL: ${{ inputs.model }} SHARE: ${{ inputs.share }} + PROMPT: ${{ inputs.prompt }} diff --git a/packages/opencode/src/cli/cmd/github.ts b/packages/opencode/src/cli/cmd/github.ts index b255e17d1b3..99bbb8cc49b 100644 --- a/packages/opencode/src/cli/cmd/github.ts +++ b/packages/opencode/src/cli/cmd/github.ts @@ -562,6 +562,11 @@ export const GithubRunCommand = cmd({ } async function getUserPrompt() { + const customPrompt = process.env["PROMPT"] + if (customPrompt) { + return { userPrompt: customPrompt, promptFiles: [] } + } + const reviewContext = getReviewCommentContext() let prompt = (() => { const body = payload.comment.body.trim() diff --git a/packages/web/src/content/docs/github.mdx b/packages/web/src/content/docs/github.mdx index 19c7782ef04..b0e0397e114 100644 --- a/packages/web/src/content/docs/github.mdx +++ b/packages/web/src/content/docs/github.mdx @@ -82,6 +82,7 @@ Or you can set it up manually. - `model`: The model to use with opencode. Takes the format of `provider/model`. This is **required**. - `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`](https://docs.github.com/en/actions/tutorials/authenticate-with-github_token) without installing the opencode GitHub App. Just make sure to grant the required permissions in your workflow: @@ -98,6 +99,25 @@ Or you can set it up manually. --- +## Custom prompts + +Override the default prompt to customize opencode's behavior for your workflow. + +```yaml title=".github/workflows/opencode.yml" +- uses: sst/opencode/github@latest + with: + model: anthropic/claude-sonnet-4-5 + prompt: | + Review this pull request: + - Check for code quality issues + - Look for potential bugs + - Suggest improvements +``` + +This is useful for enforcing specific review criteria, coding standards, or focus areas relevant to your project. + +--- + ## Examples Here are some examples of how you can use opencode in GitHub.