Set up PR Code Review with GitHub Actions
mainAutomate pull request reviews by using the anthropics/claude-code-action@beta GitHub Action. The workflow can be triggered on PR events or when a user mentions @claude in an issue comment.
Required Setup:
You must add ANTHROPIC_API_KEY to your repository secrets:
Settings → Secrets and variables → Actions → New repository secret.
name: PR - Claude Code Review
on:
pull_request:
types: [opened, synchronize, reopened]
issue_comment:
types: [created]
jobs:
review:
if: |
github.event_name == 'pull_request' ||
(github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
contains(github.event.comment.body, '@claude'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
model: claude-opus-4-5-20251101
prompt: |
Review this PR using .claude/agents/code-reviewer.md standards.
Run `git diff origin/main...HEAD` to see changes.