From 634c948eefb85b14b0ca46bd862a27085392e2e9 Mon Sep 17 00:00:00 2001 From: Sam Gutentag <1404219+samgutentag@users.noreply.github.com> Date: Thu, 28 May 2026 13:25:37 -0700 Subject: [PATCH 1/3] ci: migrate Claude auto-review workflow from old docs repo Ports .github/workflows/claude-review.yaml from trunk-io/docs. Runs claude-code-action on PRs to review docs for typos, grammar, formatting, and docs best practices, then auto-approves when the structured review passes. Skips trunk-merge/ branches. Requires the ANTHROPIC_API_KEY repo secret (not yet set on docs2). Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/claude-review.yaml | 54 ++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/claude-review.yaml diff --git a/.github/workflows/claude-review.yaml b/.github/workflows/claude-review.yaml new file mode 100644 index 0000000..9c6472e --- /dev/null +++ b/.github/workflows/claude-review.yaml @@ -0,0 +1,54 @@ +name: Claude Auto Review + +on: + pull_request: + types: [opened, synchronize, ready_for_review, reopened] + +concurrency: + group: ${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: {} + +jobs: + review: + if: ${{ !startsWith(github.head_ref, 'trunk-merge/') }} + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + pull-requests: write + id-token: write + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 1 + + - id: claude-review + uses: anthropics/claude-code-action@v1 + with: + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + track_progress: true + prompt: | + REPO: ${{ github.repository }} + PR NUMBER: ${{ github.event.pull_request.number }} + + Please review this pull request with a focus on: + - Typos, grammar, and formatting issues + - Documentation best practices + + Provide feedback using inline comments for specific issues. + + After your review, return your structured output: + - Set review_passed to true if the PR has no blocking issues + - Set review_passed to false if there are blocking issues + claude_args: | + --json-schema '{"type":"object","properties":{"review_passed":{"type":"boolean"}},"required":["review_passed"]}' + --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr review:*)" + + - name: Approve and merge if review passed + if: fromJSON(steps.claude-review.outputs.structured_output).review_passed == true + env: + GH_TOKEN: ${{ github.token }} + run: | + gh pr review ${{ github.event.pull_request.number }} --approve --body "Auto-approved: Claude code review passed." From 4c319481d13771eb6df480a95c7fe493830ff5fb Mon Sep 17 00:00:00 2001 From: Sam Gutentag <1404219+samgutentag@users.noreply.github.com> Date: Thu, 28 May 2026 13:28:06 -0700 Subject: [PATCH 2/3] ci: guard approve gate against empty review output The approve step ran fromJSON(structured_output), which throws "template is not valid" when the review step emits no output. That happens on the PR that introduces the workflow (claude-code-action self-skips until the file is on the default branch), and would also happen if the API key were missing or the action errored. Default the empty case to '{}' so the gate skips cleanly instead of failing the job. Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/claude-review.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/claude-review.yaml b/.github/workflows/claude-review.yaml index 9c6472e..7c8535a 100644 --- a/.github/workflows/claude-review.yaml +++ b/.github/workflows/claude-review.yaml @@ -47,7 +47,7 @@ jobs: --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr review:*)" - name: Approve and merge if review passed - if: fromJSON(steps.claude-review.outputs.structured_output).review_passed == true + if: fromJSON(steps.claude-review.outputs.structured_output || '{}').review_passed == true env: GH_TOKEN: ${{ github.token }} run: | From 213bd22e7fb96d137d72f5591b1690d669f62761 Mon Sep 17 00:00:00 2001 From: Sam Gutentag <1404219+samgutentag@users.noreply.github.com> Date: Thu, 28 May 2026 13:43:17 -0700 Subject: [PATCH 3/3] ci: make Claude review advisory-only Drop the auto-approve step so the workflow only leaves inline review comments. Removes gh pr review from allowed tools (Claude can no longer approve), drops the now-unused JSON schema and review_passed prompt, and renames the check to "Claude Docs Review" to shed the "Auto" connotation. Not a required status check; runs on every PR but never blocks merge. Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/claude-review.yaml | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/.github/workflows/claude-review.yaml b/.github/workflows/claude-review.yaml index 7c8535a..5ce394f 100644 --- a/.github/workflows/claude-review.yaml +++ b/.github/workflows/claude-review.yaml @@ -1,4 +1,4 @@ -name: Claude Auto Review +name: Claude Docs Review on: pull_request: @@ -14,6 +14,8 @@ jobs: review: if: ${{ !startsWith(github.head_ref, 'trunk-merge/') }} runs-on: ubuntu-latest + # Advisory only: Claude leaves inline review comments. It does not approve + # or merge, and this is not a required status check. permissions: actions: read contents: read @@ -38,17 +40,6 @@ jobs: - Documentation best practices Provide feedback using inline comments for specific issues. - - After your review, return your structured output: - - Set review_passed to true if the PR has no blocking issues - - Set review_passed to false if there are blocking issues + Do not approve the PR. This review is advisory only. claude_args: | - --json-schema '{"type":"object","properties":{"review_passed":{"type":"boolean"}},"required":["review_passed"]}' - --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr review:*)" - - - name: Approve and merge if review passed - if: fromJSON(steps.claude-review.outputs.structured_output || '{}').review_passed == true - env: - GH_TOKEN: ${{ github.token }} - run: | - gh pr review ${{ github.event.pull_request.number }} --approve --body "Auto-approved: Claude code review passed." + --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr diff:*),Bash(gh pr view:*)"