|
| 1 | +name: Claude Assistant |
| 2 | +on: |
| 3 | + issue_comment: |
| 4 | + types: [created] |
| 5 | + pull_request_review_comment: |
| 6 | + types: [created] |
| 7 | + pull_request: |
| 8 | + types: [opened, synchronize] # opened = new PR, synchronize = new commits pushed |
| 9 | + issues: |
| 10 | + types: [opened, assigned] |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + pull-requests: write |
| 15 | + issues: write |
| 16 | + id-token: write |
| 17 | + actions: read # Required for Claude to read CI results on PRs |
| 18 | + |
| 19 | +jobs: |
| 20 | + # Auto-review for same-repo PRs |
| 21 | + claude-review: |
| 22 | + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository |
| 23 | + runs-on: ubuntu-latest |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + with: |
| 27 | + fetch-depth: 1 |
| 28 | + - uses: anthropics/claude-code-action@v1 |
| 29 | + with: |
| 30 | + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} |
| 31 | + track_progress: true # ✨ Enables tracking comments |
| 32 | + claude_args: | |
| 33 | + --model opus \ |
| 34 | + --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)" |
| 35 | + prompt: | |
| 36 | + REPO: ${{ github.repository }} |
| 37 | + PR NUMBER: ${{ github.event.pull_request.number }} |
| 38 | +
|
| 39 | + Act as a code reviewer for this pull request. Focus your review on: |
| 40 | + - Overall code quality and adherence to best practices |
| 41 | + - Possible bugs, edge cases, or logical errors |
| 42 | + - Security concerns or unsafe patterns |
| 43 | + - Performance characteristics and potential optimizations |
| 44 | +
|
| 45 | + Provide thorough, actionable feedback, and use inline comments for any line-specific issues you identify. |
| 46 | +
|
| 47 | + Note: The PR branch is already checked out in the current working directory. |
| 48 | +
|
| 49 | + Use `gh pr comment` for summary or top-level feedback on the PR. |
| 50 | + Use `mcp__github_inline_comment__create_inline_comment` to annotate specific code issues inline. |
| 51 | + Only post GitHub comments - don't submit review text as messages. |
| 52 | + Use top-level comments for general observations or praise. |
| 53 | +
|
| 54 | + # Manual review triggered by "@claude review" comment (works for forks too) |
| 55 | + claude-manual-review: |
| 56 | + if: | |
| 57 | + github.event_name == 'issue_comment' && |
| 58 | + github.event.issue.pull_request && |
| 59 | + contains(github.event.comment.body, '@claude review') |
| 60 | + runs-on: ubuntu-latest |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v4 |
| 63 | + with: |
| 64 | + fetch-depth: 1 |
| 65 | + - name: Checkout PR branch |
| 66 | + run: gh pr checkout ${{ github.event.issue.number }} |
| 67 | + env: |
| 68 | + GH_TOKEN: ${{ github.token }} |
| 69 | + - uses: anthropics/claude-code-action@v1 |
| 70 | + with: |
| 71 | + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} |
| 72 | + track_progress: true # ✨ Enables tracking comments |
| 73 | + claude_args: | |
| 74 | + --model opus \ |
| 75 | + --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)" |
| 76 | + prompt: | |
| 77 | + REPO: ${{ github.repository }} |
| 78 | + PR NUMBER: ${{ github.event.issue.number }} |
| 79 | +
|
| 80 | + Act as a code reviewer for this pull request. Focus your review on: |
| 81 | + - Overall code quality and adherence to best practices |
| 82 | + - Possible bugs, edge cases, or logical errors |
| 83 | + - Security concerns or unsafe patterns |
| 84 | + - Performance characteristics and potential optimizations |
| 85 | +
|
| 86 | + Provide thorough, actionable feedback, and use inline comments for any line-specific issues you identify. |
| 87 | +
|
| 88 | + Note: The PR branch is already checked out in the current working directory. |
| 89 | +
|
| 90 | + Use `gh pr comment` for summary or top-level feedback on the PR. |
| 91 | + Use `mcp__github_inline_comment__create_inline_comment` to annotate specific code issues inline. |
| 92 | + Only post GitHub comments - don't submit review text as messages. |
| 93 | + Use top-level comments for general observations or praise. |
| 94 | +
|
| 95 | + # General interactive mode - responds to @claude mentions (but NOT review requests on PRs) |
| 96 | + claude-response: |
| 97 | + if: | |
| 98 | + (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude') && !contains(github.event.comment.body, '@claude review')) || |
| 99 | + (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude') && !contains(github.event.comment.body, '@claude review')) || |
| 100 | + (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude') && !contains(github.event.review.body, '@claude review')) || |
| 101 | + (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) |
| 102 | + runs-on: ubuntu-latest |
| 103 | + steps: |
| 104 | + - uses: actions/checkout@v4 |
| 105 | + with: |
| 106 | + fetch-depth: 1 |
| 107 | + - name: Checkout PR branch (if on a PR) |
| 108 | + if: github.event.issue.pull_request || github.event.pull_request |
| 109 | + run: gh pr checkout ${{ github.event.issue.number || github.event.pull_request.number }} |
| 110 | + env: |
| 111 | + GH_TOKEN: ${{ github.token }} |
| 112 | + - uses: anthropics/claude-code-action@v1 |
| 113 | + with: |
| 114 | + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} |
| 115 | + claude_args: | |
| 116 | + --model opus \ |
| 117 | + --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr create:*),Bash(git checkout:*),Bash(git add:*),Bash(git commit:*),Bash(git push:*),Bash(git branch:*),Edit,Write,MultiEdit" |
0 commit comments