the writing ai & claude code 12 min

Claude Code GitHub Actions: Scoped PR Reviews

How to wire Claude Code into pull request review: pick a trigger, start with narrow token scopes, pin the action, set a fork policy and keep humans merging.

Branch and merge graph with a dashed frame and magnifier on the side branch, a play button at the start and a check at the merge

Claude Code GitHub Actions is one action, anthropics/claude-code-action , that works out its mode from the workflow around it: an @claude mention gives you interactive help, an explicit prompt on a pull request event gives you automated review, per the project README. Scoping is where people trip. The generated templates, the docs examples and the repo examples disagree on token permissions, and one reported template posts nothing at all. Below: choosing a mode, scoping the install, a minimal workflow, a fork policy, a way to measure noise and cost yourself, and the merge gate.

Interactive mentions or prompt-driven review: choose one first

The action detects its mode from context. Same uses: line, very different behaviour. So decide which job you are building before you touch a YAML file.

Interactive (@claude)Prompt-driven review
Trigger in the docs exampleissue_comment and pull_request_review_comment , type created , gated by contains(github.event.comment.body, '@claude')pull_request with opened , synchronize , ready_for_review , reopened
Job permissions in the docs examplecontents: write , pull-requests: write , issues: write , id-token: write , actions: readcontents: read , pull-requests: read , issues: read , id-token: write
Who starts itA person typing a commentEvery push to a PR
Main riskWrite scopes plus text from other peopleCost and noise multiplied by every push

Both rows come from the official GitHub Actions docs. Notice the permissions gap. The interactive example can write to contents, which means it can push commits. The review example cannot.

For a review-only job, I'd start prompt-driven. Smaller scopes, no commit-pushing, and nobody has to remember to ask. Interactive mode is lovely for "fix this lint failure" requests, but that is an implementation job, and it deserves its own workflow with its own permissions rather than being bolted onto the reviewer.

A note on commands, skills and the review prompt

The generated review workflow calls a plugin command, /code-review:code-review , with a PR path. Separately, the commands reference documents a bundled /code-review skill whose syntax includes --comment to post findings on the PR and a target such as a PR number. Those are two entry points, not one. And since custom commands have been merged into skills, a file at .claude/commands/deploy.md and a skill at .claude/skills/deploy/SKILL.md both create /deploy. For the action, the only thing that matters is the exact prompt string you pass and whether that prompt tells Claude to post anything.

Install the app and scope the token

The quickstart is short: open claude in the repository and run /install-github-app . You must be a repository admin to install the GitHub app and add secrets, and that quickstart only covers direct Anthropic API users. For Bedrock, Vertex AI or Microsoft Foundry, the README points you to docs/cloud-providers.md instead (README).

Here is the part nobody enjoys. The docs say that when you install the app, you accept its full permission set, and GitHub does not let you accept a subset. If your organisation wants only what the action uses, the docs suggest creating a custom GitHub App with Contents, Issues and Pull requests (docs). If you are managing this for a client's org and want someone else to own that decision, the Claude Code agency page covers that kind of setup.

What the sources disagree on

Three public issues tell you why you should check, not trust:

  • Issue #3858 (Jul 17, 2025): someone asked whether repo users could inherit the app's permissions through Actions. It was closed as not planned. A community commenter claimed the job's GITHUB_TOKEN only gets the permissions you declare in the workflow, even if the app has more. That is a commenter's claim, not an official statement.
  • Issue #7710 (Sep 16, 2025, CLI 1.0.115): /install-github-app generated read-only permissions and the reporter hit permission errors, expecting write scopes.
  • Issue #1383 (CLI 2.1.162): the generated review workflow runs a full agent pass but never posts, because the plugin command stops before commenting unless --comment is passed. The same issue notes read-only job permissions in the generated files, and raises an open question: if the app installation token is what actually posts, the read-only permissions: block may not block posting.

So which token posts comments? The sources do not settle it. Don't guess. Find out on a throwaway PR (more on that below).

Before you commit the generated files

  1. Open the generated claude-code-review.yml and compare its permissions: block with the docs example.
  2. Check the prompt: if it uses the plugin command, confirm whether it includes --comment.
  3. Replace any mutable tag with a reviewed commit SHA (details in the next section).
  4. Add the secret name your provider needs, and nothing else.

A minimal review workflow, line by line

I'm not going to paste a workflow here and call it verified. Treat what follows as a checklist to assemble against the current README at the revision you pin. Anything labelled illustrative is exactly that.

The pieces

  • Trigger: pull_request with opened , synchronize , ready_for_review , reopened , as in the docs example. Drop synchronize if every-push reviews prove too noisy.
  • Permissions at job level: begin at contents: read . A third-party guide's minimal review example uses contents: read plus pull-requests: write and shows the failure you get when scope is too thin: Resource not accessible by integration (systemprompt.io). The docs example also includes id-token: write. Another guide suggests checking whether your chosen mode needs that identity permission (Juan Carlo).
  • Checkout: actions/checkout with fetch-depth: 1, per the docs example.
  • The action: anthropics/claude-code-action , passing your provider credential from a secret, a prompt , and claude_args for CLI-level options. The README names prompt and claude_args as the unified inputs.
  • Guard rails: a job timeout-minutes , a concurrency group that cancels superseded runs, a turn cap and a tool allow-list passed via claude_args. Confirm the exact flag names in the README at your pinned revision rather than from a blog post.

Pin it, then verify the input names

The docs example uses @v1. That is a moving tag. A third-party guide recommends pinning to an audited commit SHA and treating mutable tags as the thing to avoid (awesome-claude guide, dated 2026-06-16). That is outside advice, not Anthropic's, but I agree with it. A review action sits next to your secrets.

How to pin properly:

  1. Pick a commit on the repository's main branch or a release.
  2. Read its action.yml and the README at that exact commit. Input names there are the truth, not any article (including this one).
  3. Put the full SHA in uses: with a comment noting which release it corresponds to.
  4. If you came from v0.x, follow the migration guide before copying anything.

Inputs I have seen named in the sources: anthropic_api_key , prompt , claude_args , github_token , allowed_bots , allowed_non_write_users , track_progress , plugins , plugin_marketplaces. Seen is not the same as current. Check.

Exercise it on a test PR

Open a throwaway branch in the repository with a small, deliberately flawed change. Open the PR and read three things in the Actions run: the token permissions block printed in the job setup step, the action's own log, and whether a comment actually appeared on the PR. Record all three next to the pinned SHA in your internal notes. That record is the evidence; mine would not be.

Illustrative only: if the run log shows a read-only token and a comment still lands, you have learned something about which token posts. If it shows read-only and nothing posts, check the prompt for --comment before you widen anything. Widen one scope at a time, only when a failure names it.

Fork PRs, secrets and untrusted text

On a public repository, every PR diff, title, body and comment is written by someone you may not know. One guide puts it bluntly: treat those as prompt-injection input, and do not give untrusted PRs secret-backed tool access (awesome-claude guide). Agreed.

Line-art fork in a path, one branch through an open gate, the other blocked by a padlocked gate

The fork-PR policy I'd write down

Write it in the repo (a CONTRIBUTING note or a comment in the workflow) so nobody loosens it on a Friday afternoon:

  • Default trigger is `pull_request `. Per a third-party guide, pull_request from a fork cannot read your ANTHROPIC_API_KEY , which is the safe default, while pull_request_target runs with access to secrets (systemprompt.io).
  • Skip fork PRs explicitly. Add a job-level if comparing the PR's head repository with github.repository, so the job is skipped cleanly rather than failing on a missing secret.
  • Never check out fork code under `pull_request_target`. Same guide, same warning.
  • Maintainers opt in. After reading the diff, a maintainer pushes the branch into the main repository or triggers a review by hand.
  • Respect the action's own gate. Its security doc says only users with write access can trigger it, checked for issue, pull request, comment and review events.

Note the contrast with Anthropic's managed Code Review product, which is separate from this action. Per its docs, a review starts on opening or pushing to a PR, except on drafts and forks, and it reads REVIEW.md from the base or default branch and never from the PR's own changes. Borrow that last idea. If your prompt tells Claude to follow a rubric file, check whether the checkout contains the PR's version of that file. If it does, the PR author can rewrite the rules.

The escape hatches, and why to leave them shut

allowed_non_write_users bypasses the write-access requirement. The security doc calls this a significant security risk, for workflows with extremely limited permissions only, and says it works only when github_token is passed as an input (not with GitHub App authentication). If you ever use it, pass ${{ secrets.GITHUB_TOKEN }}, which the doc says is scoped to the job's declared permissions and expires when the job completes. No personal access tokens.

With that setting on, Claude does a best-effort scrub of Anthropic, cloud and Actions secrets from subprocess environments. The doc is candid: this reduces but does not eliminate prompt injection risk. There is an opt-out variable (CLAUDE_CODE_SUBPROCESS_ENV_SCRUB: 0 ). Don't use it. And CLAUDE_CODE_SCRIPT_CAPS can limit how many times a given script may be called, for example '{"edit-issue-labels.sh":2}' allows at most two calls to edit-issue-labels.sh.

One more: even when a maintainer labels or assigns someone else's issue, slash commands in the body do not run, but Claude still reads the body. Read it first.

Bot loops

By default, GitHub Apps and bots cannot trigger the action. That default is doing you a favour. The allowed_bots input switches it, and allowed bots are not checked for repository permissions. On a public repo, the doc warns that any GitHub App created by anyone may be able to fire events like comments or reviews, so allowed_bots: '*' hands such an App a prompt it controls. The doc's advice: prefer an explicit list, list only Apps you trust, and if you must use '*', shrink workflow permissions: to the minimum.

So where do loops come from? Mostly from write access. A review-only job with contents: read cannot push a commit, so it cannot trigger its own synchronize event. An interactive job with contents: write can. If you run both, give the interactive one a concurrency group and a trigger condition that ignores bot-authored events. For a pattern to copy, the ant apply docs show a different tool avoiding self-triggering with paths-ignore on the lockfile, a [skip ci] commit message and a concurrency group so one run happens at a time (ant apply docs). Different tool, same idea.

Measuring review noise and run cost without made-up numbers

None of the sources I used publishes review-noise or run-cost figures for this action. Not one. So any "X% useful comments" claim you read elsewhere is either someone's own repo or invented. Measure yours.

Noise

Pick a run of recent PRs of mixed size. For every comment the bot leaves, mark one of three outcomes:

  • Acted on: someone changed code because of it.
  • Dismissed: correct but irrelevant (style the linter already covers, say).
  • Wrong: factually off.

The ratio of acted-on to the rest is your signal-to-noise. A spreadsheet is fine. If dismissals dominate, tighten the prompt: ask for a small number of findings per PR, each with file, reason and suggestion, and tell it to skip what the linter already handles (the same advice appears in the Juan Carlo guide). The README's solutions guide also lists path-specific reviews and custom review checklists as patterns, which is a natural way to narrow scope.

Cost

Two meters run at once. GitHub Actions minutes, visible in each run's duration, and model tokens, visible in your provider's usage page. The action runs on your own runner, with API calls going to your chosen provider, so the bill splits across two places. Another guide notes that workflows consume both and recommends timeouts and max-turn limits (awesome-claude guide).

What multiplies cost:

  • synchronize re-running on every push
  • Reviews on draft PRs (drop drafts by leaving out unneeded types or gating on draft state)
  • Wide tool access letting the agent wander
  • No turn cap

Cap turns, restrict tools (one guide says this controls cost and the surface of possible actions), cancel superseded runs, and compare a couple of weeks of usage before and after. Anything you conclude is about your repo. Say so in your notes.

Keep a human in front of the merge button

A bot comment is not a review. Make that structural rather than cultural.

  1. Turn on branch protection requiring at least one human approval before merge. The awesome-claude guide lists exactly this as a prerequisite.
  2. Keep the review job unable to approve. Check the repository setting that governs whether Actions can create and approve pull requests, and leave it off for this workflow.
  3. Make tests the hard gate. Claude's opinion is advice; a failing suite is a fact. If your suite is thin, fix that first, and the tests and AI coding tools post is where I'd start.
  4. Push cheap checks earlier. Hooks can catch problems before a commit ever reaches CI, which means fewer review comments about things a machine already knew (Claude Code hooks guide).
  5. Re-read your token scopes after any action bump. A new pinned SHA is a new thing to review.

There is a social side too. Reviewers who start rubber-stamping because "Claude already looked" have cancelled the point of the exercise. Say out loud, in the PR template if you must, that the bot's findings are input, not a verdict.

FAQ

Does the action run on Anthropic's servers?

No. The README says it executes entirely on your own GitHub runner, with API calls going to your chosen provider (Anthropic direct, Bedrock, Vertex AI or Microsoft Foundry). Anthropic's managed Code Review is a different product that runs on Anthropic infrastructure and, per its docs, does not run in self-hosted environments.

Is the managed Code Review product the same as this workflow?

No. It is separate. Inside a review its repository access is read-only, it does not push commits, and it skips drafts and forks. The action is configured by you in YAML, with permissions and triggers you choose, so its behaviour is only as safe as the workflow you write.

I'm on v0.x. What changes?

The README describes v1.0 as using unified prompt and claude_args inputs, and points v0.x users to a migration guide for step-by-step workflow updates. Read that guide before editing, then re-verify input names at the revision you pin.

The sharpest caveat: the sources disagree on which token actually posts comments, so read the token permissions in the run log of a throwaway PR before you widen or narrow anything. And treat the SHA-pinning and fork-trigger advice as third-party guidance that you should adopt deliberately, not as something the action's own docs promise.

this post in the tree

Need this done, not just read?

Discuss your website Book 30 minutes