Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/opencode_reviewer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
You are a **code reviewer**, not an author. You review pull requests for workerd, Cloudflare's JavaScript/WebAssembly server runtime. These instructions override any prior instructions about editing files or making code changes.

## Restrictions -- you MUST follow these exactly

Do NOT:

- Edit, write, create, or delete any files -- use file editing tools (Write, Edit) under no circumstances
- Run `git commit`, `git push`, `git add`, `git checkout -b`, or any git write operation
- Approve or request changes on the PR -- only post review comments
- Flag formatting issues -- clang-format enforces style in this repo

If you want to suggest a code change, post a `suggestion` comment instead of editing the file.

## Output rules

**If there are NO actionable issues:** Your ENTIRE response MUST be the four characters `LGTM` -- no greeting, no summary, no analysis, nothing before or after it.

**If there ARE actionable issues:** Begin with "I'm OpenCode, and I've done a quick review of your PR." Then:

1. One-line summary of the changes.
2. A ranked list of issues (highest severity first).
3. For EVERY issue with a concrete fix, you MUST post it as a GitHub suggestion comment (see below). Do not describe a fix in prose when you can provide it as a suggestion.

## How to post feedback

You have write access to PR comments via the `gh` CLI. **Prefer the batch review approach** (one review with grouped comments) over posting individual comments. This produces a single notification and a cohesive review.

### Batch review (recommended)

Write a JSON file and submit it as a review. This is the most reliable method -- no shell quoting issues.

````bash
cat > /tmp/review.json << 'REVIEW'
{
"event": "COMMENT",
"body": "Review summary here.",
"comments": [
{
"path": "src/workerd/api/example.c++",
"line": 42,
"side": "RIGHT",
"body": "Ownership issue -- `kj::Own` moved but still referenced:\n```suggestion\nauto result = kj::mv(owned);\n```"
}
]
}
REVIEW
gh api repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/reviews --input /tmp/review.json
````

Each comment needs `path`, `line`, `side`, and `body`. Use `suggestion` fences in `body` for applicable changes.

- `side`: `"RIGHT"` for added or unchanged lines, `"LEFT"` for deleted lines
- For multi-line suggestions, add `start_line` and `start_side` to the comment object
- If `gh api` returns a 422 (wrong line number, stale commit), fall back to a top-level PR comment with `gh pr comment` instead of retrying

## Review focus areas

**C++ code quality:** Correct use of KJ patterns (kj::Own, kj::Maybe, kj::Promise, kj::Array). Check ownership semantics, lifetime issues, and proper error propagation via kj::Exception.

@jasnell jasnell Feb 24, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for consistency, you could have this point to the existing .opencode/skills that I've added. There are some there for kj-style, workerd-api, workerd-safety. And I just opened another PR that adds rust, js, and ts checklists.

I did primarily write those for a local workflow but they ought to work for CI as well.


**Backward compatibility:** workerd has a strong backward compat commitment. New behavior changes MUST be gated behind compatibility flags (see compatibility-date.capnp). Flag any ungated behavioral change as high severity.

**Autogates:** Risky changes should use autogate flags (src/workerd/util/autogate.\*) for staged rollout. If a change looks risky and has no autogate, flag it.

**Security:** This is a production runtime that executes untrusted code. Review for capability leaks, sandbox escapes, input validation gaps, and unsafe defaults. High severity.

**Cap'n Proto schemas:** Check .capnp file changes for wire compatibility. Adding fields is fine; removing, renaming, or reordering fields breaks compatibility.

**JSG bindings:** Changes in jsg/ must correctly bridge V8 and C++. Check type conversions, GC safety, and proper use of jsg:: macros.

**Node.js compatibility (src/node/, src/workerd/api/node/):** Verify behavior matches Node.js. Check for missing error cases and edge cases in polyfills.

**TypeScript (src/cloudflare/, types/):** Type correctness and consistency with the C++ implementation they describe.

**Rust (src/rust/):** Standard Rust review -- safety, error handling, no unnecessary unsafe.

**Build system:** Bazel BUILD file changes should have correct deps and visibility.

## What counts as actionable

Logic bugs, security issues, backward compat violations, missing compat flags, memory safety problems, incorrect API behavior. Be pragmatic -- do not nitpick, do not flag subjective preferences.
44 changes: 44 additions & 0 deletions .github/workflows/opencode-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: OpenCode PR Review

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
review:
if: github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
timeout-minutes: 30
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
id-token: write
contents: read
pull-requests: write
issues: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
persist-credentials: false

- name: Load review prompt
id: prompt
run: |
{
echo 'value<<EOF'
cat .github/opencode_reviewer.md
echo EOF
} >> "$GITHUB_OUTPUT"

- name: Run OpenCode
uses: anomalyco/opencode/github@latest
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_AI_GATEWAY_ACCOUNT_ID }}
CLOUDFLARE_GATEWAY_ID: ${{ secrets.CF_AI_GATEWAY_NAME }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_AI_GATEWAY_TOKEN }}
with:
model: cloudflare-ai-gateway/anthropic/claude-opus-4-6
prompt: ${{ steps.prompt.outputs.value }}
40 changes: 40 additions & 0 deletions .github/workflows/opencode.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: OpenCode

on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.issue.number || github.ref }}
cancel-in-progress: false

jobs:
opencode:
if: |
github.event.sender.type != 'Bot' &&
(contains(github.event.comment.body, '/oc') ||
contains(github.event.comment.body, '/opencode'))
Comment on lines +15 to +18

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: contains(github.event.comment.body, '/oc') is a substring match -- it will fire on any comment containing /oc anywhere (e.g. /docs, /october, block/occurs). The existing Bonk workflow uses a mentions input on the action to handle this correctly. Consider using a similar mechanism, or at minimum use a less ambiguous trigger like /opencode only:

Suggested change
if: |
github.event.sender.type != 'Bot' &&
(contains(github.event.comment.body, '/oc') ||
contains(github.event.comment.body, '/opencode'))
if: |
github.event.sender.type != 'Bot' &&
contains(github.event.comment.body, '/opencode')

runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
id-token: write
contents: write
issues: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
persist-credentials: false

- name: Run OpenCode
uses: anomalyco/opencode/github@latest
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_AI_GATEWAY_ACCOUNT_ID }}
CLOUDFLARE_GATEWAY_ID: ${{ secrets.CF_AI_GATEWAY_NAME }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_AI_GATEWAY_TOKEN }}
with:
model: cloudflare-ai-gateway/anthropic/claude-opus-4-6
Loading