11name : Claude Code Review
22
33on :
4- pull_request :
5- types : [opened, synchronize]
6- # Optional: Only run on specific file changes
7- # paths:
8- # - "src/**/*.ts"
9- # - "src/**/*.tsx"
10- # - "src/**/*.js"
11- # - "src/**/*.jsx"
4+ pull_request_review_comment :
5+ types : [created]
6+ pull_request_review :
7+ types : [submitted]
128
139jobs :
1410 test :
11+ # Only run if comment contains "claude" and is on a PR (not an issue)
12+ # Exclude bot comments to prevent infinite loops
13+ if : |
14+ github.event.issue.pull_request != null &&
15+ github.event.comment.author.type != 'Bot' &&
16+ contains(github.event.comment.body, 'claude-review')
1517 runs-on : ubuntu-latest
18+ permissions :
19+ contents : write
20+ pull-requests : read
1621 steps :
1722 - name : Checkout code
1823 uses : actions/checkout@v4
1924
25+ - name : Checkout PR branch
26+ run : |
27+ gh pr checkout ${{ github.event.issue.number }}
28+ env :
29+ GH_TOKEN : ${{ github.token }}
30+
2031 - name : Setup Node.js
2132 uses : actions/setup-node@v4
2233 with :
@@ -40,15 +51,16 @@ jobs:
4051
4152 claude-review :
4253 needs : test
43- # Optional: Filter by PR author
44- # if: |
45- # github.event.pull_request.user.login == 'external-contributor' ||
46- # github.event.pull_request.user.login == 'new-developer' ||
47- # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
54+ # Only run if comment contains "claude" and is on a PR (not an issue)
55+ # Exclude bot comments to prevent infinite loops
56+ if : |
57+ github.event.issue.pull_request != null &&
58+ github.event.comment.author.type != 'Bot' &&
59+ contains(github.event.comment.body, 'claude-review')
4860
4961 runs-on : ubuntu-latest
5062 permissions :
51- contents : read
63+ contents : write
5264 pull-requests : read
5365 issues : read
5466 id-token : write
@@ -59,14 +71,20 @@ jobs:
5971 with :
6072 fetch-depth : 1
6173
74+ - name : Checkout PR branch
75+ run : |
76+ gh pr checkout ${{ github.event.issue.number }}
77+ env :
78+ GH_TOKEN : ${{ github.token }}
79+
6280 - name : Run Claude Code Review
6381 id : claude-review
6482 uses : anthropics/claude-code-action@v1
6583 with :
6684 claude_code_oauth_token : ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
6785 prompt : |
6886 REPO: ${{ github.repository }}
69- PR NUMBER: ${{ github.event.pull_request .number }}
87+ PR NUMBER: ${{ github.event.issue .number }}
7088
7189 Please review this pull request and provide feedback on:
7290 - Code quality and best practices
0 commit comments