|
| 1 | +name: Claude Code Review |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request_target: |
| 5 | + types: [opened, synchronize, ready_for_review, reopened] |
| 6 | + |
| 7 | +jobs: |
| 8 | + claude-review: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + permissions: |
| 11 | + contents: read |
| 12 | + pull-requests: write |
| 13 | + issues: write |
| 14 | + actions: read |
| 15 | + id-token: write |
| 16 | + |
| 17 | + steps: |
| 18 | + # IMPORTANT: checkout BASE repo only (safe on forks) |
| 19 | + - name: Checkout base repo (safe) |
| 20 | + uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + fetch-depth: 1 |
| 23 | + |
1 | 24 | - name: Run Claude Code Review |
2 | | - id: claude-review |
3 | 25 | uses: anthropics/claude-code-action@v1 |
4 | 26 | with: |
5 | 27 | claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} |
6 | 28 | github_token: ${{ github.token }} |
7 | 29 |
|
8 | | - plugin_marketplaces: 'https://github.com/anthropics/claude-code.git' |
9 | | - plugins: 'code-review@claude-code-plugins' |
| 30 | + plugin_marketplaces: "https://github.com/anthropics/claude-code.git" |
| 31 | + plugins: "code-review@claude-code-plugins" |
10 | 32 |
|
11 | 33 | claude_args: > |
12 | 34 | --dangerously-skip-permissions |
|
15 | 37 | "Bash(gh pr view:*)" |
16 | 38 | "Bash(gh pr diff:*)" |
17 | 39 | "Bash(gh pr comment:*)" |
18 | | - "Bash(gh api repos/*/pulls/*:*)" |
19 | | - "Bash(gh api repos/*/issues/*/comments:*)" |
| 40 | + "Bash(gh pr list:*)" |
| 41 | + "Bash(gh pr status:*)" |
| 42 | + "Bash(gh issue comment:*)" |
| 43 | + "Bash(gh api:*)" |
20 | 44 | "Bash(cat:*)" |
21 | 45 | "Bash(ls:*)" |
22 | 46 | "Bash(grep:*)" |
23 | 47 | "Bash(find:*)" |
| 48 | + "Bash(sed:*)" |
| 49 | + "Bash(awk:*)" |
| 50 | + "Bash(head:*)" |
| 51 | + "Bash(tail:*)" |
| 52 | + "Bash(wc:*)" |
| 53 | + "Bash(sort:*)" |
| 54 | + "Bash(uniq:*)" |
| 55 | + "Bash(cut:*)" |
| 56 | + "Bash(xargs:*)" |
| 57 | + "Bash(jq:*)" |
| 58 | + "Bash(python3:*)" |
24 | 59 |
|
25 | 60 | prompt: | |
26 | | - /code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }} |
| 61 | + You are running in pull_request_target. DO NOT execute or inspect the fork's checked-out code. |
| 62 | + Review ONLY via GitHub API/gh commands. |
| 63 | +
|
| 64 | + Always use numeric PR form with --repo: |
| 65 | + - gh pr view ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --json files,title,body |
| 66 | + - gh pr diff ${{ github.event.pull_request.number }} --repo ${{ github.repository }} |
27 | 67 |
|
28 | | - Always use the numeric PR form with --repo, e.g.: |
29 | | - - gh pr view ${{ github.event.pull_request.number }} --repo ${{ github.repository }} ... |
30 | | - - gh pr diff ${{ github.event.pull_request.number }} --repo ${{ github.repository }} ... |
31 | | - - gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} ... |
| 68 | + If CLAUDE.md exists in the base repo checkout, read it with: |
| 69 | + - cat CLAUDE.md |
| 70 | + Prefer jq/python3 for JSON parsing instead of shell loops. |
32 | 71 |
|
33 | 72 | Output requirements (even if no issues): |
34 | | - - Start with: files changed count + list up to 15 changed file paths |
35 | | - - Then: a short summary of what the PR changes (3–6 bullets) |
36 | | - - Then: findings: |
37 | | - - If issues: list them with file path + line numbers when possible |
38 | | - - If no issues: list at least 3 concrete "improvement opportunities" with file paths |
39 | | - Post the results as ONE top-level PR comment titled "Claude Code Review". |
| 73 | + - Files changed count + list up to 15 file paths |
| 74 | + - Summary (3–6 bullets) |
| 75 | + - Findings: |
| 76 | + - If issues: include file + line numbers when possible |
| 77 | + - If no issues: at least 3 concrete improvement opportunities with file paths |
| 78 | +
|
| 79 | + Post ONE top-level PR comment titled "Claude Code Review". |
| 80 | + If posting a PR comment is blocked, write the full review to the GitHub Actions job summary instead. |
| 81 | +
|
| 82 | + additional_permissions: | |
| 83 | + actions: read |
0 commit comments