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+ issue_comment :
5+ types : [created]
6+ pull_request_review_comment :
7+ types : [created]
8+ pull_request_review :
9+ types : [submitted]
1210
1311jobs :
1412 claude-review :
15- # Optional: Filter by PR author
16- # if: |
17- # github.event.pull_request.user.login == 'external-contributor' ||
18- # github.event.pull_request.user.login == 'new-developer' ||
19- # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
20-
13+ # Only run when @claude is mentioned in comments/reviews AND it's on a pull request
14+ if : |
15+ (github.event_name == 'issue_comment' &&
16+ github.event.issue.pull_request &&
17+ contains(github.event.comment.body, '@claude')) ||
18+ (github.event_name == 'pull_request_review_comment' &&
19+ contains(github.event.comment.body, '@claude')) ||
20+ (github.event_name == 'pull_request_review' &&
21+ contains(github.event.review.body, '@claude'))
22+
2123 runs-on : ubuntu-latest
2224 permissions :
2325 contents : read
2426 pull-requests : read
2527 issues : read
2628 id-token : write
27-
29+
2830 steps :
2931 - name : Checkout repository
3032 uses : actions/checkout@v4
@@ -36,40 +38,28 @@ jobs:
3638 uses : anthropics/claude-code-action@beta
3739 with :
3840 anthropic_api_key : ${{ secrets.ANTHROPIC_API_KEY }}
39-
41+
4042 # Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4)
4143 # model: "claude-opus-4-20250514"
42-
43- # Direct prompt for automated review (no @claude mention needed)
44+
45+ # Direct prompt for on-demand review
4446 direct_prompt : |
4547 Please review this pull request and provide feedback on:
4648 - Code quality and best practices
4749 - Potential bugs or issues
4850 - Performance considerations
4951 - Security concerns
5052 - Test coverage
51-
53+
5254 Be constructive and helpful in your feedback.
53-
55+
5456 # Optional: Customize review based on file types
5557 # direct_prompt: |
5658 # Review this PR focusing on:
5759 # - For TypeScript files: Type safety and proper interface usage
5860 # - For API endpoints: Security, input validation, and error handling
5961 # - For React components: Performance, accessibility, and best practices
6062 # - For tests: Coverage, edge cases, and test quality
61-
62- # Optional: Different prompts for different authors
63- # direct_prompt: |
64- # ${{ github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' &&
65- # 'Welcome! Please review this PR from a first-time contributor. Be encouraging and provide detailed explanations for any suggestions.' ||
66- # 'Please provide a thorough code review focusing on our coding standards and best practices.' }}
67-
63+
6864 # Optional: Add specific tools for running tests or linting
6965 # allowed_tools: "Bash(npm run test),Bash(npm run lint),Bash(npm run typecheck)"
70-
71- # Optional: Skip review for certain conditions
72- # if: |
73- # !contains(github.event.pull_request.title, '[skip-review]') &&
74- # !contains(github.event.pull_request.title, '[WIP]')
75-
0 commit comments