Skip to content

Commit 7a57b6f

Browse files
jagtejsodhiclaude
andauthored
feat: add Claude Code review GitHub Action (#34)
Adds automated PR review workflow that: - Triggers on all PRs (open/push) and manual @claude-review comments - Gates manual trigger to OWNER/MEMBER/COLLABORATOR only - Pins claude-code-action to immutable SHA for supply-chain safety - Posts inline comments, deduplicates, and resolves stale threads Committed-By-Agent: claude Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d3739f7 commit 7a57b6f

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

.github/workflows/claude.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Claude Code Review
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
pull_request_target:
7+
types: [opened, synchronize]
8+
9+
jobs:
10+
claude-review:
11+
if: |
12+
(github.event_name == 'issue_comment' &&
13+
github.event.issue.pull_request &&
14+
contains(github.event.comment.body, '@claude-review') &&
15+
contains(fromJson('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) ||
16+
(github.event_name == 'pull_request_target' &&
17+
github.event.pull_request.head.repo.full_name == github.repository &&
18+
!github.event.pull_request.draft &&
19+
!startsWith(github.event.pull_request.head.ref, 'release-please--') &&
20+
!contains(github.event.pull_request.body, 'no-claude-review'))
21+
22+
concurrency:
23+
group: claude-review-${{ github.event.pull_request.number || github.event.issue.number }}
24+
cancel-in-progress: true
25+
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: read
29+
pull-requests: write
30+
issues: read
31+
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 1
37+
38+
- name: Run Claude Code Review
39+
uses: anthropics/claude-code-action@787c5a0ce96a9a6cfb050ea0c8f4c05f2447c251 # v1.0.133
40+
with:
41+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
42+
github_token: ${{ github.token }}
43+
claude_args: "--allowedTools mcp__github_inline_comment__create_inline_comment,mcp__github_comment__update_claude_comment,Read,Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh api graphql:*)"
44+
prompt: |
45+
REPO: ${{ github.repository }}
46+
PR NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
47+
48+
Review this PR using the skill at .claude/skills/review-pr/SKILL.md.
49+
50+
Rules:
51+
- Post each finding as an inline comment on the exact line using `mcp__github_inline_comment__create_inline_comment` (confirmed: true)
52+
- Post one top-level summary comment via `mcp__github_comment__update_claude_comment`: a bulleted summary of findings only, max 3-5 bullets, nothing more.
53+
- Before posting inline comments, check if the same finding already exists as an inline comment from a previous run (filter by `author.login == "github-actions[bot]"` in review threads). Do NOT re-post duplicate findings. Only post net-new findings for changes since the last review.
54+
- Resolve stale inline comment threads whose findings have been fixed. To resolve a thread, first get the thread's node_id from the PR's review threads using `gh api graphql -f query='{ repository(owner:"OWNER", name:"REPO") { pullRequest(number:PR_NUM) { reviewThreads(first:100) { nodes { id isResolved comments(first:1) { nodes { body author { login } } } } } } }'`, then resolve it with `gh api graphql -f query='mutation { resolveReviewThread(input:{threadId:"THREAD_NODE_ID"}) { thread { isResolved } } }'`. Only resolve threads authored by github-actions[bot].
55+
- Only comment on lines with real issues — do not comment for the sake of it

0 commit comments

Comments
 (0)