WORKFLOW · quality-cd

Claude PR review workflow

Automated review on every PR with claude-code-action@v1: correctness-calibrated prompt, cost controls, and both Anthropic API and AWS Bedrock variants in one workflow.

✓ verified 2026-06-12 · stack: github-actions, claude-code, bedrock, java · source

An automation-mode review on every PR open and push: the prompt input puts claude-code-action@v1 into automation mode (no @claude mention needed), and the prompt itself is calibrated to correctness-only with an evidence requirement, per the guidance in agent code review. The repository variable USE_BEDROCK switches between the direct Anthropic API and AWS Bedrock via OIDC.

.github/workflows/claude-pr-review.yml
name: Claude PR Review
on:
pull_request:
types: [opened, synchronize]
permissions:
contents: read
pull-requests: write
id-token: write # required for the Bedrock OIDC variant
jobs:
review:
runs-on: ubuntu-latest
timeout-minutes: 25
concurrency:
group: claude-review-${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
# ── Option A: direct Anthropic API ─────────────────────────────
- name: Claude PR Review (Anthropic)
if: ${{ !vars.USE_BEDROCK }}
uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
prompt: |
Review this pull request for correctness, security, and Java best practices.
Focus only on bugs that would break production behaviour, not style issues.
Do not report issues already caught by checkstyle or SpotBugs.
Require a file:line citation for any behavioural claim.
Cap nit comments at 5; mention additional nits as a count.
claude_args: |
--max-turns 10
--model claude-sonnet-4-6
# ── Option B: AWS Bedrock (recommended for Java teams on AWS) ──
- name: Configure AWS Credentials
if: ${{ vars.USE_BEDROCK }}
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Generate GitHub App token
if: ${{ vars.USE_BEDROCK }}
id: app-token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Claude PR Review (Bedrock)
if: ${{ vars.USE_BEDROCK }}
uses: anthropics/claude-code-action@v1
with:
github_token: ${{ steps.app-token.outputs.token }}
use_bedrock: "true"
prompt: |
Review this pull request for correctness, security, and Java best practices.
Focus only on bugs that would break production behaviour, not style issues.
Do not report issues already caught by checkstyle or SpotBugs.
Require a file:line citation for any behavioural claim.
Cap nit comments at 5; mention additional nits as a count.
claude_args: |
--max-turns 10
--model us.anthropic.claude-sonnet-4-6

For Bedrock, the assumed IAM role needs Bedrock invoke permissions for the chosen model, and the model ID carries the cross-region inference prefix (us.anthropic.…). The direct API takes the unprefixed ID. Set the USE_BEDROCK repository variable, the role secret, and a GitHub App (APP_ID/APP_PRIVATE_KEY) for the token the action posts comments with.

What it does

  • Reviews every PR on open and on each push, in automation mode: the prompt input is what selects this over @claude mention-handling, which is the v1 auto-detection behaviour.
  • Calibrates the review to correctness: production-breaking bugs only, no findings that Checkstyle/SpotBugs already enforce, mandatory file:line evidence, and a five-nit cap, the noise-control rules from the managed Code Review guidance.
  • Caps cost three ways: --max-turns 10 per review, timeout-minutes: 25 on the job, and a concurrency group that cancels a superseded review when the PR is pushed again.
  • Keeps long-lived Anthropic keys out of AWS-team repos: the Bedrock variant authenticates via GitHub OIDC into an IAM role.

For a self-hosted multi-lens alternative, see the fan-out review workflow.

Failure modes

  • Beta input names break silently. This is the v1 syntax. If you merge it into a repo that still has a beta-era workflow using direct_prompt, max_turns, or allowed_tools, that workflow no longer does what it says: direct_prompt is now prompt, and the others moved into claude_args. Migrate or delete the old file; do not run both.
  • Fork PRs get no review. pull_request from a fork runs without secrets, so the action cannot authenticate. Accept the gap for open-source repos rather than reaching for pull_request_target, which runs with secrets against untrusted head refs.
  • Model aliases drift. claude-sonnet-4-6 and its us.anthropic. Bedrock counterpart are current as of 2026-06; pin a dated model ID in claude_args if you need review behaviour to be reproducible across alias changes, and confirm the Bedrock ID against your region’s model catalogue.
  • The review is advice, not a gate. Nothing here blocks a merge. If you want a blocking signal, keep deterministic checks as the required gate (see the Java quality gate) and treat this review as triage for human attention. Making an LLM verdict a required check inverts the noise calibration this prompt exists to provide.
  • Cost scales with push frequency. Every synchronize event is a fresh review. The concurrency group prevents overlap, not volume; on a high-churn repo, consider types: [opened, ready_for_review] plus an on-demand @claude workflow instead.

Verified against the claude-code-action v1 README (input set, automation-mode trigger, Bedrock/OIDC requirements) and the Claude Code GitHub Actions docs, 2026-06-12.