|
| 1 | +name: Claude Code |
| 2 | + |
| 3 | +on: |
| 4 | + issue_comment: |
| 5 | + types: [created] |
| 6 | + pull_request_review_comment: |
| 7 | + types: [created] |
| 8 | + issues: |
| 9 | + types: [opened, assigned] |
| 10 | + pull_request_review: |
| 11 | + types: [submitted] |
| 12 | + |
| 13 | +jobs: |
| 14 | + claude: |
| 15 | + if: | |
| 16 | + (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || |
| 17 | + (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || |
| 18 | + (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || |
| 19 | + (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) |
| 20 | + runs-on: ubuntu-latest |
| 21 | + permissions: |
| 22 | + contents: write |
| 23 | + pull-requests: write |
| 24 | + issues: write |
| 25 | + id-token: write |
| 26 | + actions: read # Required for Claude to read CI results on PRs |
| 27 | + steps: |
| 28 | + - name: Checkout repository |
| 29 | + uses: actions/checkout@v5 |
| 30 | + with: |
| 31 | + fetch-depth: 1 |
| 32 | + |
| 33 | + - name: PR Review with Progress Tracking |
| 34 | + uses: anthropics/claude-code-action@v1 |
| 35 | + with: |
| 36 | + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} |
| 37 | + |
| 38 | + # Enable progress tracking |
| 39 | + track_progress: true |
| 40 | + |
| 41 | + # Your custom review instructions |
| 42 | + prompt: | |
| 43 | + REPO: ${{ github.repository }} |
| 44 | + PR NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }} |
| 45 | + |
| 46 | + Review this pull request and provide inline feedback using the GitHub review system. Follow these steps: |
| 47 | + |
| 48 | + 1. Start a review: Use `mcp__github__create_pending_pull_request_review` to start a pending review. |
| 49 | + 2. Get diff information: Use `mcp__github__get_pull_request_diff` to see the code changes and line numbers. |
| 50 | + - If the pull request has many changes, paginate the diff using the `page` and `per_page` parameters. |
| 51 | + - Example: To get the first 100 lines, call `mcp__github__get_pull_request_diff` with `per_page=100` and `page=1`. For the next 100 lines, use `page=2`, and so on. |
| 52 | + - Continue fetching pages until all changes are retrieved. |
| 53 | + 3. Add inline comments: Use `mcp__github__add_comment_to_pending_review` to provide feedback on specific lines of code snippets. |
| 54 | + 4. Submit for review: Use `mcp__github__submit_pending_pull_request_review` with the event type set to "COMMENT" (not "REQUEST_CHANGES") to publish all comments for non-blocking review. |
| 55 | + |
| 56 | + Focus on the following focus areas: |
| 57 | + |
| 58 | + 1. **Code Quality** |
| 59 | + - Clean code principles and best practices |
| 60 | + - Proper error handling and edge cases |
| 61 | + - Code readability and maintainability |
| 62 | + |
| 63 | + 2. **Security** |
| 64 | + - Check for potential security vulnerabilities |
| 65 | + - Validate input sanitization |
| 66 | + - Review authentication/authorization logic |
| 67 | + |
| 68 | + 3. **Performance** |
| 69 | + - Identify potential performance bottlenecks |
| 70 | + - Review database queries for efficiency |
| 71 | + - Check for memory leaks or resource issues |
| 72 | + |
| 73 | + 4. **Testing** |
| 74 | + - Verify adequate test coverage |
| 75 | + - Review test quality and edge cases |
| 76 | + - Check for missing test scenarios |
| 77 | + |
| 78 | + 5. **Documentation** |
| 79 | + - Ensure code is properly documented |
| 80 | + - Verify README updates for new features |
| 81 | + - Check API documentation accuracy |
| 82 | + |
| 83 | + Provide detailed feedback using inline comments for specific issues. |
| 84 | + Use top-level comments for general observations or praise. |
| 85 | +
|
| 86 | + # Tools for comprehensive PR review |
| 87 | + claude_args: | |
| 88 | + --allowedTools "mcp__github__get_pull_request,mcp__github__create_pending_pull_request_review,mcp__github__add_comment_to_pending_review,mcp__github__submit_pending_pull_request_review,mcp__github__get_pull_request_diff" |
| 89 | +
|
| 90 | + # When track_progress is enabled: |
| 91 | + # - Creates a tracking comment with progress checkboxes |
| 92 | + # - Includes all PR context (comments, attachments, images) |
| 93 | + # - Updates progress as the review proceeds |
| 94 | + # - Marks as completed when done |
0 commit comments