Claude Code GitHub Actions: set up @claude in your repo without handing a PR author your secrets
The install is one command, and the action's defaults do more than the workflow file shows. Three of its controls still stop less than their names suggest: the write-access check, the permissions block and the command restriction on outside pull requests.
Contents
Claude Code GitHub Actions puts Claude Code on a GitHub runner. Someone writes @claude in an issue or a pull request, or a workflow fires on a PR or a schedule, and Claude can read the context, edit files, push to a branch and answer in a comment. Setup is one command, or a secret plus a workflow file.
The job that does this holds your Anthropic credential and a GitHub token with write access, and its input is text, often from people you don’t know. The action ships real guards for that. Three of them stop less than their names suggest: the write-access check decides who can start a run, not whose words Claude reads; the job’s permissions: block scopes one of the two GitHub tokens in play; and the command restriction on outside pull requests is a list. What follows comes from Anthropic’s docs, the action’s own security docs and GitHub’s guidance, read on November 22, 2026. I resolved the v1 tag through the GitHub API and ran claude setup-token --help; I did not run the action itself.
What does Claude Code GitHub Actions need before you start?
Admin access to the repository and one credential. Per the docs, both setup paths need admin access, and /install-github-app works only for github.com remotes; it prints a notice and exits on gitlab.com or bitbucket.org. On an organization, installing the app may also need an owner’s approval.
For the Claude API there are three ways to authenticate:
ANTHROPIC_API_KEY, a key from the Claude Console, passed to theanthropic_api_keyinput.CLAUDE_CODE_OAUTH_TOKEN, made locally withclaude setup-token, passed toclaude_code_oauth_token. The docs list it for Pro, Max, Ultra, Team and Enterprise plans. On Claude Code 2.1.330 the help line reads “Set up a long-lived authentication token (requires Claude subscription).”- Workload identity federation, which swaps the static secret for an OIDC exchange (
anthropic_federation_rule_id,anthropic_organization_id, andid-token: writeon the job).
For a secret shared across repositories, the docs prefer the API key, “since an OAuth token is tied to the subscription of the person who ran claude setup-token.” My read: the OAuth token is a convenience for a personal repository, and anything a team depends on should run on a key or on federation. Bedrock, Google Cloud and Microsoft Foundry have their own inputs (use_bedrock, use_vertex, use_foundry).
Each Claude run spends API tokens or subscription usage, and the runner bills Actions minutes where your repository and runner type are billed at all.
How does /install-github-app set up Claude Code GitHub Actions?
It installs the Claude GitHub App, stores your credential as a repository secret and pushes a branch with the workflow files. According to the docs, you sign in with gh auth login, start claude in the repository, run /install-github-app, install the app in the browser, choose Set up GitHub Actions workflows, pick a subscription token or an API key and confirm. Then you create the pull request from the pushed branch and merge it; the workflows go live on merge.
Read what the app asks for before you click. The docs list read and write on Actions, Checks, Contents, Discussions, Issues, Pull requests, Repository creation, Repository hooks and Workflows, plus read on Administration, Dependabot alerts, Members, Merge queues, Metadata and Statuses. The action “relies on three of the app’s permissions”: Contents, Issues and Pull requests. The rest serve Code Review, web auto-fix and planned features, and “GitHub doesn’t let you accept a subset.” The manual path installs the same app, so it doesn’t shrink this list. Only your own app or your own token changes it.
How do you set up the Claude Code action manually?
Install the app, add the secret, and copy examples/claude.yml from the action repository into .github/workflows/. The docs suggest this when you don’t run Claude Code locally, when the command fails, or when you want full control. The example as committed, without its commented options:
name: Claude Code
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]
jobs:
claude:
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: write
id-token: write
actions: read # Required for Claude to read CI results on PRs
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Run Claude Code
id: claude
uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}With a subscription token, the last line becomes:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}With no prompt, the action answers the trigger phrase. The docs call this tag mode; set a prompt and it runs that instead, which is how they build automated PR review and a cron report. Two edits leave a silent job if you make only half of them. Changing trigger_phrase doesn’t touch the @claude strings in the job’s if:, so update both. Adding a prompt for automatic review also needs a new on: (for example pull_request) and the mention guard removed. claude_args passes CLI flags through: --max-turns, --model, --allowedTools, --mcp-config. Workflows still on @beta need the migration guide; the common edits are @v1, dropping mode, direct_prompt to prompt, and moving max_turns and model into claude_args.
Who can trigger the Claude Code action, and whose text still gets in?
Only people with write access can start a run, but anyone’s text can end up in it. Per the security docs, the action checks repository access on issue, pull request, comment and review events, and for a comment it checks “the commenter’s write access.” Bots are refused unless listed in allowed_bots, and the docs warn that '*' on a public repository lets “GitHub Apps created by anyone” invoke the action “with a prompt it controls.” Scheduled and dispatched runs skip the check; GitHub already requires write access to dispatch.
The check gates who presses the button, not what Claude reads. A maintainer who writes @claude fix this under a stranger’s issue starts a run whose context includes the stranger’s text. The docs: “Claude still reads the body to understand the task, so review it first.” The action strips HTML comments, invisible characters, image alt text and hidden attributes from that content and warns that “new bypass techniques may emerge.” So read the raw markdown of an outside issue, not the rendered page, which hides HTML comments. On a public repository, include_comments_by_actor narrows which users’ comments in the thread are passed along as context. It filters the discussion, not the request that started the run.
What happens when the Claude Code action runs on a fork pull request?
A maintainer’s @claude in the PR conversation runs Claude on the contributor’s code, in a job that holds your tokens. allow_fork_prs defaults to "true", and the docs say tag mode “checks out the pull request’s head, so on a pull request from an outside contributor that code is theirs, even when a maintainer triggered the run.” The action restores its own config first (below), but the rest of the checkout is the fork’s.
When the PR author lacks write access, the action applies three protections:
restrict_untrusted_prs(default"true") denies “package managers, test runners, interpreters and shells,” even ifclaude_argsallows them. Claude can still read, edit, commit and push.- Claude’s config comes from your default branch, not the PR:
.claude/,.mcp.json,.claude.json,.gitmodules,.ripgreprc,CLAUDE.md,CLAUDE.local.md,AGENTS.mdand.husky/, with the PR’s versions kept under.claude-pr/for reading..npmrc,bunfig.tomland trackednode_modules/files are replaced too; the PR’snode_modules/is not kept. - Bots count as authors without write access, even when listed in
allowed_bots.
The docs then say plainly where this stops:
This is a list of common commands, not a sandbox.
A rule such as Bash(./scripts/test.sh) stays allowed, and scripts/ is not on the restored list, so my reading is that the rule would run the contributor’s version of that file. “Trust follows the pull request’s author”: if a maintainer opens a PR from a stranger’s branch, the code counts as the maintainer’s.
The push is the easiest part to miss. On an open fork PR, Claude pushes to a pr-N branch in your repository, and that branch “holds the fork’s commits as well as Claude’s, and GitHub’s limits on runs from forks don’t apply to it.” Any push-triggered CI that builds it runs the contributor’s code with your secrets. The docs’ fix: keep pr-* out of secret-holding CI (branches-ignore on push triggers), never deploy from it, and delete it when you’re done.
If you don’t need Claude on forks, set allow_fork_prs: "false". The action then skips any PR whose branch lives in another repository, for every event, before it checks anything out. The skip is a successful step with no Claude output, so a required check that only runs the action goes green. It doesn’t cover your own steps that check out fork code first, issues, or text: “Issues and comments from outside contributors still reach Claude.”
Does the GitHub Actions permissions block limit the Claude GitHub App token?
As far as the docs say, no. It scopes GITHUB_TOKEN. With no github_token input, “the Claude Code GitHub Action authenticates as the Claude GitHub App,” exchanging an OIDC token for an app token; that is what id-token: write in the block is for. The security docs describe the app token as short-lived and “scoped specifically to the repository it’s operating in,” and what it can do inside that repository follows the app’s grant. Neither the docs nor the FAQ says the job’s block narrows it, while the workflow’s own token “is scoped to the job’s declared permissions and expires when the job completes.”
So trimming the block in the example trims GITHUB_TOKEN. Still write it explicitly, and keep id-token: write while you use the app, or the exchange fails. Dropping actions: read limits the workflow token’s access to CI results; it doesn’t stop Claude reaching logs by another route you allow. A cron report with contents: read and issues: read is read-only for the workflow token, not for the app token next to it.
To bound what Claude can do through GitHub, change the token:
- Your own GitHub App.
docs/setup.mdgives the minimum as read and write on Contents, Issues and Pull requests: “your app’s token will have the exact permissions you configured, nothing more.” Mint it withactions/and pass it ascreate-github-app-token github_token. - The workflow’s own token, the built-in
GITHUB_TOKENpassed asgithub_token. Then the job’s block is the bound. Comments appear under a different user, the FAQ notes thatuse_sticky_commentstops updating properly, and GitHub doesn’t start ordinary workflows from pushes made with that token.
Is auto mode a security boundary in the Claude Code action?
No. The security docs title the section “Auto mode is a review, not a boundary.” The action now runs Claude in auto mode by default: reads and workspace edits run without asking, and “a safety review decides any other tool call that your allow rules don’t cover.” Narrow rules like Bash(npm test) skip the review; broad ones like Bash(*) are ignored. “It catches many unsafe actions, but a call can still run if the review passes it.”
That matters if your workflow treats --allowedTools as the ceiling on what Claude may run. Under auto mode the review can approve more. The docs give the earlier defaults as the opt-out:
# @claude mentions: workspace edits allowed, anything no rule covers denied
claude_args: --permission-mode acceptEdits
# workflows with a prompt: anything no rule covers denied
# claude_args: --permission-mode defaultThat removes the reviewer’s power to approve extra calls. It doesn’t make your list the only tools in play: acceptEdits still allows edits, and tag mode adds its own git tools. Setting allowed_non_write_users or allowed_bots also changes the default back to the earlier modes, “because other people’s text reaches these runs without a write-access check,” unless you pass a mode yourself. I haven’t checked which classifier path a runner session takes; checking the auto mode classifier and its model covers local Claude Code.
Where does pull_request_target break a Claude Code GitHub Actions setup?
Where a privileged trigger meets a checkout of untrusted code. GitHub Security Lab’s pwn-request writeup puts it in one line: “Combining pull_request_target workflow trigger with an explicit checkout of an untrusted PR is a dangerous practice that may lead to repository compromise.” Workflows on that trigger “have write permission to the target repository” and “access to target repository secrets”; a plain pull_request from a fork gets neither. Anthropic’s page states the same from its side: on public repositories, “GitHub withholds secrets from runs triggered by fork pull requests,” which is why its review example only covers same-repository branches.
The action’s docs bold the rule: “Do not check out an untrusted ref into the workspace root before this action.” Their preferred pattern is a plain actions/checkout with no ref:, which on pull_request_target gives you the base. They also show checking the PR head out into a subdirectory and passing it with --add-dir. That gives Claude the files to read. It isolates nothing if anything in the job runs them. Code from a fork that has to execute belongs in a secretless pull_request job, with any privileged follow-up on workflow_run, the split Security Lab recommends.
Why is allowed_non_write_users the riskiest Claude Code action input?
Because it switches off the check that everything above leans on. The docs mark it “RISKY”: it “bypasses the primary security mechanism of this action” and belongs only on workflows with very limited permissions, such as issue labeling. It works only with your own github_token, and the docs say to pass GITHUB_TOKEN, never a personal access token, because a static token “could be partially or fully recovered over time via prompt injection.” Scope the job’s block and the allowed tools to the one task.
This is the configuration behind Clinejection, one of the real prompt injection cases against coding agents I collected: an issue triage workflow ran the action on the issues event with allowed_non_write_users: "*" and Bash among its tools, and an issue title told Claude to install a package.
Should you pin the Claude Code action to a commit SHA?
Yes. GitHub’s secure-use reference says to pin third-party actions to a full commit SHA, and now ranks its workflow dependency lockfile above that: “This is the strongest protection available, and supersedes SHA pinning for repositories that adopt it.” If your repository uses that lockfile, cover this workflow with it; otherwise pin. On November 22, 2026, @v1 pointed at the same commit as v1.0.286:
- uses: anthropics/claude-code-action@acfe7992852970efb4fee683d63d628e3e52df67 # v1.0.286v1 is at patch 286, and the auto mode default arrived inside it with no major bump. Pin it, pin actions/checkout too, and read the changelog each time you move the pin.
Claude Code GitHub Actions: the short checklist
Before you paste the example workflow:
- Use an API key or federation for anything shared; keep the OAuth token for personal repositories.
- Write the
permissions:block yourself, and remember it boundsGITHUB_TOKEN. To bound Claude’s GitHub access, pass your own app’s token orGITHUB_TOKENasgithub_token. - Decide on forks:
allow_fork_prs: "false"unless you want Claude on outside PRs. If you keep it, leaverestrict_untrusted_prson and keeppr-*out of CI that holds secrets. - Pick the permission mode on purpose. If
--allowedToolsis meant as the ceiling, add--permission-mode acceptEditsordefault. - Never check out a PR head at the workspace root under
pull_request_target. Giveallowed_non_write_usersonly to a job with minimal permissions andGITHUB_TOKEN. - Pin the action.
- Read the raw markdown of an outside issue before you write
@claudeunder it.
The write-access check tells you who asked. It tells you nothing about who wrote what Claude read, or whose code sits on the branch it pushes. If you want a second automated layer after the fact, Claude Code Review and the layers around it covers what the managed reviewer adds and what you can rebuild on any plan.
01 / Discussion
No comment section here — all discussions happen on X.
02 / More articles
Codex sandbox permission profiles vs the Claude Code sandbox: what each one walls off
On Ubuntu, a Codex profile with a one-host allowlist refused an unlisted site with a 403. Delete two lines that look like an unrelated feature switch and the same site answers 200, with no warning. Claude Code's network filter cannot go inert that way; it is off until you turn it on, and one permission mode walks through it.
Windows 11 coding agent telemetry: what the optional diagnostic data switch stops in MissionControlAggregator, and the developer flag Microsoft lists as required
The per-agent bitmap is tagged optional, so the usual switch should keep it home. A coarser IsDeveloper cohort from the same DLL sits in Microsoft's required event list, which Home and Pro cannot opt out of, and nobody has yet published a run with the switch off.
Claude Code "Don't ask again" and settings.local.json: how to find the passwords in your allow rules, and what to change
On the current Claude Code release the prompt turns most of a command into a wildcard before it saves the rule, and a password written in front of the program still survives. The session transcript keeps the whole command, and the cleanest fix is a command line that never holds the secret.