From 6151444186970d6293f671a173bc85e1ad1a2a50 Mon Sep 17 00:00:00 2001 From: Mohamad Jaara Date: Wed, 29 Oct 2025 12:49:27 +0100 Subject: [PATCH 1/4] ci: add Claude code review GitHub Action --- .../code-review/claude-code-review.yml | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/actions/code-review/claude-code-review.yml diff --git a/.github/actions/code-review/claude-code-review.yml b/.github/actions/code-review/claude-code-review.yml new file mode 100644 index 00000000000..8d92bda5025 --- /dev/null +++ b/.github/actions/code-review/claude-code-review.yml @@ -0,0 +1,56 @@ +name: Claude Code Review + +on: + issue_comment: + types: [created] + +jobs: + claude-review: + # Only run on PR comments (not issues), when the comment contains the trigger phrase, + # and when the commenter is a maintainer/team member + if: | + github.event.issue.pull_request && + github.actor != 'dependabot[bot]' && + contains(github.event.comment.body, '@claude review') && + ( + github.event.comment.author_association == 'OWNER' || + github.event.comment.author_association == 'MEMBER' || + github.event.comment.author_association == 'COLLABORATOR' + ) + + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + issues: write + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Run Claude Code Review + id: claude-review + uses: anthropics/claude-code-action@v1 + with: + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + prompt: | + REPO: ${{ github.repository }} + PR NUMBER: ${{ github.event.issue.number }} + + Please review this pull request and provide feedback on: + - Code quality and best practices + - Potential bugs or issues + - Performance considerations + - Security concerns + - Test coverage + + Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback. + + Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR. + + # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md + # or https://docs.claude.com/en/docs/claude-code/sdk#command-line for available options + claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"' From 278db5f93260d1fb4b8bb0f91aa72303aed00909 Mon Sep 17 00:00:00 2001 From: Mohamad Jaara Date: Wed, 29 Oct 2025 13:22:58 +0100 Subject: [PATCH 2/4] ci: update Claude code review action to trigger on pull request review comments --- .github/actions/code-review/claude-code-review.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/actions/code-review/claude-code-review.yml b/.github/actions/code-review/claude-code-review.yml index 8d92bda5025..949e252d212 100644 --- a/.github/actions/code-review/claude-code-review.yml +++ b/.github/actions/code-review/claude-code-review.yml @@ -1,15 +1,14 @@ name: Claude Code Review on: - issue_comment: + pull_request_review_comment: types: [created] jobs: claude-review: - # Only run on PR comments (not issues), when the comment contains the trigger phrase, + # Only run when the comment contains the trigger phrase, # and when the commenter is a maintainer/team member if: | - github.event.issue.pull_request && github.actor != 'dependabot[bot]' && contains(github.event.comment.body, '@claude review') && ( @@ -38,7 +37,7 @@ jobs: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} prompt: | REPO: ${{ github.repository }} - PR NUMBER: ${{ github.event.issue.number }} + PR NUMBER: ${{ github.event.pull_request.number }} Please review this pull request and provide feedback on: - Code quality and best practices From 03313a44f22ebf8c456dd2e593f2af2811242a54 Mon Sep 17 00:00:00 2001 From: Mohamad Jaara Date: Wed, 29 Oct 2025 13:48:55 +0100 Subject: [PATCH 3/4] ci: update Claude code review action to use read permissions and post initial comment --- .../code-review/claude-code-review.yml | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/.github/actions/code-review/claude-code-review.yml b/.github/actions/code-review/claude-code-review.yml index 949e252d212..9d0bb7130b8 100644 --- a/.github/actions/code-review/claude-code-review.yml +++ b/.github/actions/code-review/claude-code-review.yml @@ -20,8 +20,8 @@ jobs: runs-on: ubuntu-latest permissions: contents: read - pull-requests: write - issues: write + pull-requests: read + issues: read id-token: write steps: @@ -30,6 +30,20 @@ jobs: with: fetch-depth: 1 + - name: Post initial comment + id: initial-comment + env: + GH_TOKEN: ${{ github.token }} + run: | + COMMENT_ID=$(gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \ + -f body="🤖 Beep boop! Claude is putting on their reading glasses and diving into your code... + + ⏳ This comment will be updated with the review results once I'm done pondering the mysteries of your implementation. + + _In the meantime, feel free to grab a coffee ☕ - reviewing code is serious business!_" \ + --jq '.id') + echo "comment_id=$COMMENT_ID" >> $GITHUB_OUTPUT + - name: Run Claude Code Review id: claude-review uses: anthropics/claude-code-action@v1 @@ -38,6 +52,9 @@ jobs: prompt: | REPO: ${{ github.repository }} PR NUMBER: ${{ github.event.pull_request.number }} + INITIAL COMMENT ID: ${{ steps.initial-comment.outputs.comment_id }} + + I've already posted a comment (ID: ${{ steps.initial-comment.outputs.comment_id }}) letting everyone know the review is in progress. Please review this pull request and provide feedback on: - Code quality and best practices @@ -45,11 +62,16 @@ jobs: - Performance considerations - Security concerns - Test coverage - + Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback. - Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR. + IMPORTANT: Instead of creating a NEW comment, UPDATE the existing comment (ID: ${{ steps.initial-comment.outputs.comment_id }}) with your review results. + + Use this command to update the comment: + gh api repos/${{ github.repository }}/issues/comments/${{ steps.initial-comment.outputs.comment_id }} \ + -X PATCH \ + -f body="" # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md # or https://docs.claude.com/en/docs/claude-code/sdk#command-line for available options - claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"' + claude_args: '--allowed-tools "Bash(gh api:*),Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"' From 1ae8844a278fbf8ae8675b1a318d87e80d76e3c8 Mon Sep 17 00:00:00 2001 From: Mohamad Jaara Date: Wed, 29 Oct 2025 13:51:37 +0100 Subject: [PATCH 4/4] ci: update Claude code review action permissions to allow write access for pull requests and issues --- .github/actions/code-review/claude-code-review.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/code-review/claude-code-review.yml b/.github/actions/code-review/claude-code-review.yml index 9d0bb7130b8..e6324e7afd9 100644 --- a/.github/actions/code-review/claude-code-review.yml +++ b/.github/actions/code-review/claude-code-review.yml @@ -20,8 +20,8 @@ jobs: runs-on: ubuntu-latest permissions: contents: read - pull-requests: read - issues: read + pull-requests: write + issues: write id-token: write steps: