Skip to content
Merged
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
77 changes: 77 additions & 0 deletions .github/actions/code-review/claude-code-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Claude Code Review

on:
pull_request_review_comment:
types: [created]

jobs:
claude-review:
# Only run when the comment contains the trigger phrase,
# and when the commenter is a maintainer/team member
if: |
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: 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
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
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
- 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.

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="<your review content here>"

# 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 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:*)"'
Loading