|
| 1 | +name: Claude PR Comment Review |
| 2 | +# https://github.com/anthropics/claude-code-action/blob/main/docs/solutions.md#automatic-pr-code-review |
| 3 | +# https://skywork.ai/blog/how-to-use-claude-code-for-prs-code-reviews-guide/#step-3-add-a-comment-triggered-workflow-copy-pasteable |
| 4 | + |
| 5 | +on: |
| 6 | + pull_request_review_comment: |
| 7 | + types: [created] |
| 8 | + |
| 9 | +jobs: |
| 10 | + review: |
| 11 | + if: ${{ contains(github.event.comment.body, '@claude') }} |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + contents: read |
| 15 | + pull-requests: write |
| 16 | + id-token: write |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v5 |
| 19 | + with: |
| 20 | + fetch-depth: 1 |
| 21 | + |
| 22 | + - uses: anthropics/claude-code-action@v1 |
| 23 | + with: |
| 24 | + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} |
| 25 | + track_progress: true # ✨ Enables tracking comments |
| 26 | + prompt: | |
| 27 | + REPO: ${{ github.repository }} |
| 28 | + PR NUMBER: ${{ github.event.pull_request.number }} |
| 29 | +
|
| 30 | + Please review this pull request checked out in the current working directory with a focus on: |
| 31 | + - Code quality and best practices |
| 32 | + - Potential bugs or issues |
| 33 | + - Security implications |
| 34 | + - Performance considerations |
| 35 | +
|
| 36 | + Make sure to: |
| 37 | + - Use `gh pr comment` for top-level feedback |
| 38 | + - Use `mcp__github_inline_comment__create_inline_comment` to highlight specific code issues |
| 39 | + - Check structure is consist with existing code style |
| 40 | + - Skip style issues already handled by linters |
| 41 | + - Check for duplication of code already in the repository; aim for re-use where sensible |
| 42 | + - Favour composition over inheritence |
| 43 | + - Respond in concise bullet point form; avoid restating code |
| 44 | + |
| 45 | + claude_args: | |
| 46 | + --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)" |
0 commit comments