|
| 1 | +# Automated code review of pull requests using Claude |
| 2 | +# |
| 3 | +# A member/owner/collaborator requests a review by writing a PR comment |
| 4 | +# containing "@claude review". |
| 5 | +# |
| 6 | +# pull_request_target is not used because the Claude GitHub App token exchange |
| 7 | +# rejects OIDC tokens from that event (401 "Invalid OIDC token"). |
| 8 | +# |
| 9 | +# issue_comment runs the workflow file from the default branch with access to |
| 10 | +# secrets. The PR code is never checked out or executed. |
| 11 | +name: claude-review |
| 12 | + |
| 13 | +on: |
| 14 | + issue_comment: |
| 15 | + types: [created] |
| 16 | + |
| 17 | +jobs: |
| 18 | + review: |
| 19 | + if: | |
| 20 | + github.event.issue.pull_request && |
| 21 | + contains(github.event.comment.body, '@claude review') && |
| 22 | + contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association) |
| 23 | +
|
| 24 | + runs-on: ubuntu-24.04 |
| 25 | + |
| 26 | + permissions: |
| 27 | + contents: read |
| 28 | + pull-requests: write |
| 29 | + id-token: write |
| 30 | + |
| 31 | + steps: |
| 32 | + # checks out the base branch, not the PR head |
| 33 | + - uses: actions/checkout@v7 |
| 34 | + with: |
| 35 | + fetch-depth: 1 |
| 36 | + |
| 37 | + - name: Claude review |
| 38 | + uses: anthropics/claude-code-action@v1 |
| 39 | + with: |
| 40 | + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} |
| 41 | + prompt: | |
| 42 | + REPO: ${{ github.repository }} |
| 43 | + PR NUMBER: ${{ github.event.issue.number }} |
| 44 | +
|
| 45 | + Review this pull request. Focus on correctness bugs, potential |
| 46 | + false positives/false negatives in checkers, performance problems |
| 47 | + and missing tests. Be concise and only report real issues. |
| 48 | +
|
| 49 | + Use `gh pr diff` to see the changes. Post specific issues as inline |
| 50 | + comments with `mcp__github_inline_comment__create_inline_comment` |
| 51 | + and post a short overall summary with `gh pr comment`. |
| 52 | + claude_args: | |
| 53 | + --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)" |
0 commit comments