ci: switch Claude Code Review to experimental-review mode#2355
Conversation
Use the dedicated review mode for inline PR comments and suggestions instead of the general tag mode with direct_prompt. Based on the official example from anthropics/claude-code-action@beta. Changes: - mode: experimental-review for inline review comments - custom_instructions instead of direct_prompt - fetch-depth: 0 for full diff analysis - Reference CLAUDE.md for project conventions - Add timeout_minutes to prevent hung reviews - Remove unnecessary allowed_tools (base GitHub tools always included) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| issues: read | ||
| actions: read | ||
| pull-requests: write | ||
| issues: write |
There was a problem hiding this comment.
The issues: write permission might be more than needed. Consider if issues: read would be sufficient for the experimental-review mode, unless you specifically need to create/modify issues.
| issues: write | |
| issues: read |
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
| uses: actions/checkout@v4 |
There was a problem hiding this comment.
Consider updating to checkout@v4 for consistency, as the previous version used v6 but v4 is more commonly used and stable.
| uses: actions/checkout@v4 | |
| uses: actions/checkout@v4 |
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 1 | ||
| fetch-depth: 0 |
There was a problem hiding this comment.
✅ Excellent improvement! Using fetch-depth: 0 instead of fetch-depth: 1 provides the full git history, which allows Claude to better understand the context of changes and provide more accurate reviews. This is particularly important for the experimental-review mode.
| id: claude-review | ||
| uses: anthropics/claude-code-action@beta | ||
| with: | ||
| mode: experimental-review |
There was a problem hiding this comment.
✅ Perfect choice! The experimental-review mode is exactly what you want for inline comments and code suggestions. This mode is specifically designed for PR reviews and will provide a much better experience than the default tag mode.
| direct_prompt: | | ||
| Please review this pull request and provide feedback on: | ||
| - Code quality and best practices | ||
| timeout_minutes: "30" |
There was a problem hiding this comment.
Good addition! The 30-minute timeout prevents workflows from hanging indefinitely. Consider adding a brief comment to explain this choice:
| timeout_minutes: "30" | |
| timeout_minutes: "30" # Prevent hung reviews |
| custom_instructions: | | ||
| Use the repository's CLAUDE.md for guidance on style, conventions, and architecture. | ||
| Focus on: | ||
| - Code quality and maintainability | ||
| - Potential bugs or issues | ||
| - Security vulnerabilities | ||
| - Performance considerations | ||
| - Security concerns | ||
| - Test coverage | ||
|
|
||
| Be constructive and helpful in your feedback. | ||
| - Test coverage gaps | ||
|
|
||
| # Optional: Use sticky comments to make Claude reuse the same comment on subsequent pushes to the same PR | ||
| # use_sticky_comment: true | ||
|
|
||
| # Optional: Customize review based on file types | ||
| # direct_prompt: | | ||
| # Review this PR focusing on: | ||
| # - For TypeScript files: Type safety and proper interface usage | ||
| # - For API endpoints: Security, input validation, and error handling | ||
| # - For React components: Performance, accessibility, and best practices | ||
| # - For tests: Coverage, edge cases, and test quality | ||
|
|
||
| # Optional: Different prompts for different authors | ||
| # direct_prompt: | | ||
| # ${{ github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' && | ||
| # 'Welcome! Please review this PR from a first-time contributor. Be encouraging and provide detailed explanations for any suggestions.' || | ||
| # 'Please provide a thorough code review focusing on our coding standards and best practices.' }} | ||
|
|
||
| # Optional: Add specific tools for running tests or linting | ||
| # allowed_tools: "Bash(npm run test),Bash(npm run lint),Bash(npm run typecheck)" | ||
|
|
||
| # Optional: Skip review for certain conditions | ||
| # if: | | ||
| # !contains(github.event.pull_request.title, '[skip-review]') && | ||
| # !contains(github.event.pull_request.title, '[WIP]') | ||
| Be constructive and provide specific suggestions for improvements. | ||
| Use GitHub's suggestion format when proposing code changes. |
There was a problem hiding this comment.
✅ Excellent configuration! Using custom_instructions instead of direct_prompt is the correct approach for experimental-review mode. The instructions are comprehensive and reference CLAUDE.md for project-specific conventions.
The focus areas are well-balanced and the suggestion to use GitHub's suggestion format is particularly valuable for actionable feedback.
Optional enhancement: Consider adding file path restrictions if you want to limit reviews to specific directories:
| custom_instructions: | | |
| Use the repository's CLAUDE.md for guidance on style, conventions, and architecture. | |
| Focus on: | |
| - Code quality and maintainability | |
| - Potential bugs or issues | |
| - Security vulnerabilities | |
| - Performance considerations | |
| - Security concerns | |
| - Test coverage | |
| Be constructive and helpful in your feedback. | |
| - Test coverage gaps | |
| # Optional: Use sticky comments to make Claude reuse the same comment on subsequent pushes to the same PR | |
| # use_sticky_comment: true | |
| # Optional: Customize review based on file types | |
| # direct_prompt: | | |
| # Review this PR focusing on: | |
| # - For TypeScript files: Type safety and proper interface usage | |
| # - For API endpoints: Security, input validation, and error handling | |
| # - For React components: Performance, accessibility, and best practices | |
| # - For tests: Coverage, edge cases, and test quality | |
| # Optional: Different prompts for different authors | |
| # direct_prompt: | | |
| # ${{ github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' && | |
| # 'Welcome! Please review this PR from a first-time contributor. Be encouraging and provide detailed explanations for any suggestions.' || | |
| # 'Please provide a thorough code review focusing on our coding standards and best practices.' }} | |
| # Optional: Add specific tools for running tests or linting | |
| # allowed_tools: "Bash(npm run test),Bash(npm run lint),Bash(npm run typecheck)" | |
| # Optional: Skip review for certain conditions | |
| # if: | | |
| # !contains(github.event.pull_request.title, '[skip-review]') && | |
| # !contains(github.event.pull_request.title, '[WIP]') | |
| Be constructive and provide specific suggestions for improvements. | |
| Use GitHub's suggestion format when proposing code changes. | |
| custom_instructions: | | |
| Use the repository's CLAUDE.md for guidance on style, conventions, and architecture. | |
| Focus your review on source code files in src/, excluding generated or vendor files. | |
| Focus on: | |
| - Code quality and maintainability | |
| - Potential bugs or issues | |
| - Security vulnerabilities | |
| - Performance considerations | |
| - Test coverage gaps | |
| Be constructive and provide specific suggestions for improvements. | |
| Use GitHub's suggestion format when proposing code changes. |
)" This reverts commit c50f0fb.
Summary
experimental-reviewmode for inline PR comments and code suggestionsanthropics/claude-code-action@betadocscustom_instructionsinstead ofdirect_prompt(review mode has its own built-in prompt)fetch-depth: 0) for better diff analysisallowed_tools(base GitHub tools are always included)Test plan
🤖 Generated with Claude Code