Claude Code GitHub Actions: Setup, @claude and Security
Only users with write access can trigger @claude. Set up the Claude GitHub App, a secret and a workflow, run it on a schedule, and fix it when it stays silent.
- Claude Code GitHub Actions runs Claude Code in your workflows: mention @claude in an issue or PR comment and Claude reads the code, answers, or commits changes.
- You need three pieces: the Claude GitHub App, a secret (ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN) and a workflow that calls anthropics/claude-code-action@v1. Either setup path needs repository admin access.
- On issue and PR events only users with write access can trigger it, and bots are rejected unless listed in allowed_bots.
Claude Code GitHub Actions is a GitHub Action that runs Claude Code inside your repository’s workflows. Mention @claude in an issue or pull request comment and Claude reads the code, answers, or makes changes and pushes commits. Give it a prompt instead and it runs on any event, including a schedule. This guide covers setup, the two run modes, who can trigger a run, keeping secrets safe, cost limits, and what to check when it stays silent. For a cost breakdown, see Running Claude Code in CI: Costs and Traps.
In our test environment (macOS, Claude Code 2.1.311, on 2026-10-27) we did not run anything on GitHub. We did not install the app, add secrets or trigger a workflow (not run). The only thing we ran locally was a YAML syntax check of the two workflows below.
The three pieces
| Piece | What it does |
|---|---|
| Claude GitHub App | Reads and writes the repository’s files, issues and pull requests |
| A repository secret | ANTHROPIC_API_KEY (a Claude Console API key) or CLAUDE_CODE_OAUTH_TOKEN (a token tied to your Claude subscription) |
| A workflow file | Lives in .github/workflows/ and calls anthropics/claude-code-action@v1 |
Whichever way you set it up, you need admin access to the repository.
Source: https://code.claude.com/docs/en/github-actions, checked 2026-10-27
Quick setup with /install-github-app
Open claude in the repository and run /install-github-app (not run). It installs the app, stores a secret and prepares a pull request with the workflow.
- It works only with github.com repositories. On a gitlab.com or bitbucket.org remote it prints a notice and exits
- Install the GitHub CLI and run
gh auth loginfirst. Claude Code warns you if it’s missing - If Claude Code already has an API key, it reuses it. Otherwise you choose between a long-lived subscription token and pasting an API key. The secret is named
ANTHROPIC_API_KEYorCLAUDE_CODE_OAUTH_TOKEN. How the subscription token works and how to revoke it is covered in CLAUDE_CODE_OAUTH_TOKEN: Setup, CI Use and Leak Response - It pushes a branch with the workflow files and opens a ready-to-create pull request in your browser. Merge it and
@claudeworks - Press Esc to stop partway. The step in progress finishes, no later step starts, and the closing message lists what already happened, such as a pushed branch or a saved secret
- After the app is installed you can choose Skip for now and run the command again later to finish
Quick setup covers the Claude API and Claude subscriptions. For Amazon Bedrock, Google Cloud’s Agent Platform or Microsoft Foundry, follow the cloud provider guide instead.
Source: https://code.claude.com/docs/en/github-actions, checked 2026-10-27
Manual setup
Skip the command if you don’t run Claude Code locally, the command fails, or you want full control of the workflow files (not run).
- Install the Claude GitHub App from https://github.com/apps/claude. The action relies on three of its permissions: Contents, Issues and Pull requests, all read and write.
- Add the secret. For a subscription token, run
claude setup-tokenlocally (Pro, Max, Team and Enterprise plans). - Copy
examples/claude.ymlfrom the action’s repository into.github/workflows/.
Pass the secret to the matching input: anthropic_api_key for an API key, claude_code_oauth_token for a subscription token.
Installing the app grants its full permission set, not just those three. The same app serves Code Review and web auto-fix, so the install also asks for Actions, Checks, Discussions, Workflows and Repository hooks (read and write), plus read access to Administration, Members, Merge queues, Metadata and Statuses. GitHub doesn’t let you accept a subset. If your organization wants only what the action uses, create a custom GitHub App with Contents, Issues and Pull requests; Code Review and web auto-fix still need the official app. The action’s own security page lists a shorter set, with Actions and Checks as read only and marked for future features. We followed the Claude Code docs here.
This is the official workflow that responds to @claude:
name: Claude Code
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
jobs:
claude:
if: contains(github.event.comment.body, '@claude')
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: write
id-token: write
actions: read
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 1
- uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
id-token: write is needed for the action’s default GitHub App authentication. actions: read lets Claude read CI results on pull requests. The if line keeps runners from starting on comments without @claude, and the action checks the trigger phrase again itself.
Sources: https://code.claude.com/docs/en/github-actions and https://github.com/anthropics/claude-code-action/blob/main/docs/security.md, checked 2026-10-27
Rolling it out across an organization
- Install the app once at the organization level, for all or selected repositories
- Store the secret as an organization-level Actions secret
- Add the workflow to each repository, or define it once as a reusable workflow
Use a Console API key for a shared secret. An OAuth token is tied to the subscription of whoever ran claude setup-token. To avoid a long-lived secret entirely, use workload identity federation: the action exchanges the workflow’s GitHub OIDC token for Claude API access through a Console service account. Set anthropic_federation_rule_id and anthropic_organization_id, and grant id-token: write.
Source: https://code.claude.com/docs/en/github-actions, checked 2026-10-27
Interactive mode: @claude
With no prompt input, the action waits for the trigger phrase, @claude by default. It looks in issue and PR comments, PR reviews, and the body or title of a newly opened issue. You can change the phrase with trigger_phrase. Claude replies in a comment on the same issue or PR and updates it as it works:
@claude fix the TypeError in the user dashboard component
In the default configuration Claude does not open pull requests itself. It commits to a new branch (prefixed claude/ by default) and replies with a link to the PR creation page. A person clicks the link and creates the PR.
Sources: https://code.claude.com/docs/en/github-actions, https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md and https://github.com/anthropics/claude-code-action/blob/main/docs/security.md, checked 2026-10-27
Automation mode: prompt and schedules
With a prompt input, the action runs without waiting for a mention, on any event, including cron. Results go to the workflow run log by default, not a comment. A plain-text prompt gets no shell or GitHub API access until you grant tools, either with --allowedTools in claude_args or a permissions.allow rule in the settings input. If the prompt invokes a skill instead, Claude can use the tools in the skill’s allowed-tools frontmatter.
GitHub runs scheduled workflows only from the default branch. In public repositories it disables the schedule after 60 days without repository activity.
Here is the official daily report, with one change: we dropped the --model line and added --max-turns 5. Without --model, the action uses the Claude Code default model.
name: Daily Report
on:
schedule:
- cron: "0 9 * * *"
jobs:
report:
runs-on: ubuntu-latest
permissions:
contents: read
issues: read
id-token: write
steps:
- uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
prompt: "Generate a summary of yesterday's commits and open issues"
claude_args: |
--max-turns 5
--allowedTools "mcp__github__list_commits,mcp__github__list_issues"
The cron runs at 09:00 UTC. There is no checkout step because Claude reads commits and issues through the GitHub MCP tools.
Source: https://code.claude.com/docs/en/github-actions, checked 2026-10-27
We saved both workflows under /tmp and parsed them with YAML.safe_load in Ruby 4.0.8. Both parsed. One thing surprised us. Ruby follows YAML 1.1, so the top-level on: key came back as the boolean true, not the string "on". If you lint workflows with a YAML 1.1 parser, look up true. With permissions: indented one space too little, the parse stopped with did not find expected key while parsing a block mapping at line 6 column 3. A syntax check proves nothing about how GitHub runs the file. For claude -p itself, see Claude Code Headless Mode: claude -p for Scripts and Cron.
Who can trigger a run
The action checks the triggering actor before Claude starts. If either check fails, the run fails.
- Write access. On issue and pull request events, the triggering user needs write access to the repository. Events no user authors, such as
schedule, skip this check. - Human actor. On every event, bots are rejected unless listed in
allowed_bots, which keeps bots from triggering Claude in a loop. GitHub attributes scheduled runs to a repository user, usually whoever last changed thecronline. If that’s a bot, list it.
allowed_bots: '*' is risky on a public repository. Listed bots aren’t checked for repository permissions, so any GitHub App that can open issues or comment could invoke the action with its own prompt. Prefer an explicit list.
allowed_non_write_users lifts the write-access check for named users or *. The action’s docs mark it as risky and say to use it only on workflows with very limited permissions, such as issue labeling with issues: write. It works only when you pass github_token. Pass ${{ secrets.GITHUB_TOKEN }}, which is scoped to the job and expires when it ends, and not a personal access token. Narrow the tools in claude_args as well.
Sources: https://code.claude.com/docs/en/github-actions and https://github.com/anthropics/claude-code-action/blob/main/docs/security.md, checked 2026-10-27
Secrets and untrusted input
- Never commit an API key or OAuth token. Store it as a GitHub secret and reference it, as in
${{ secrets.ANTHROPIC_API_KEY }} - Grant the workflow only the permissions it needs, and review Claude’s changes before merging
- Untrusted comments can hide instructions. The action strips HTML comments, invisible characters, image alt text, hidden HTML attributes and HTML entities, but its docs say new bypasses may appear. On public repositories,
include_comments_by_actorlimits whose comments reach Claude show_full_outputis off by default. Turning it on, or enabling GitHub Actions debug mode, logs every tool output, which can include secrets. On public repositories those logs are public- Deleting the repository secret doesn’t revoke the credential. To retire an API key, delete it in the Claude Console too
For more on keeping keys away from agents, see Keep Secrets Away from Claude Code.
Sources: https://code.claude.com/docs/en/github-actions and https://github.com/anthropics/claude-code-action/blob/main/docs/security.md, checked 2026-10-27
Keeping costs down
Each run uses GitHub Actions minutes on GitHub-hosted runners and API tokens. With an OAuth token, runs use your Claude subscription instead of API billing. The docs suggest:
- Write specific
@clauderequests so Claude needs fewer turns - Use issue templates to give context up front
- Keep
CLAUDE.mdshort, since Claude reads it on every run - Set
--max-turnsinclaude_args - Set workflow-level timeouts
- Use GitHub’s concurrency controls to limit parallel runs
Source: https://code.claude.com/docs/en/github-actions, checked 2026-10-27
When it doesn’t work
| Symptom | What to check |
|---|---|
No response to @claude | The app is installed, workflows are enabled, the secret exists, @claude is a complete word (not /claude or @claude-bot), and the commenter has write access |
| CI doesn’t run on Claude’s commits | GitHub doesn’t trigger workflows on commits made with the default GITHUB_TOKEN. Remove a github_token: ${{ secrets.GITHUB_TOKEN }} input so the action authenticates as the app, or pass a custom app token. Also check that your CI triggers include events like push or pull_request |
| Authentication errors | Test the key or token locally with claude before debugging the workflow |
Still on @beta | Switch to @v1, remove mode, rename direct_prompt to prompt, and move max_turns and model into claude_args |
Source: https://code.claude.com/docs/en/github-actions, checked 2026-10-27
For review on every pull request without writing a workflow, Anthropic also offers Code Review, documented at https://code.claude.com/docs/en/code-review.
Related articles
- Running Claude Code in CI: Costs and Traps
- Claude Code Headless Mode: claude -p for Scripts and Cron
- Keep Secrets Away from Claude Code
- Permission Design for AI Agents
- Claude Code in CI, Headless and Production: how to run Claude Code unattended, plus permissions and keys in CI.
- Claude Code on Bedrock, Vertex and Foundry: Setup Guide
Summary
- You need the Claude GitHub App, a secret and a workflow that calls
anthropics/claude-code-action@v1, plus admin access to set them up. /install-github-apphandles all three for github.com repositories. Installing the app grants its full permission set.- With no
prompt, Claude answers@claude. With aprompt, it runs on any event, and you grant tools with--allowedTools. - Only users with write access trigger issue and PR runs, and bots need
allowed_bots. Avoid'*'on public repositories. - By default Claude pushes a branch and links to the PR page. A person opens the PR.
- Keep keys in secrets, cap runs with
--max-turns, timeouts and concurrency, and remember that commits made with the defaultGITHUB_TOKENdon’t trigger CI.
FAQ
- How do I set up Claude Code GitHub Actions?
- Run /install-github-app in Claude Code for a github.com repository. It installs the Claude GitHub App, saves the secret and opens a pull request with the workflow. You can also install the app, add the secret and copy examples/claude.yml yourself. Both paths need admin access.
- Can I use my Claude subscription instead of an API key?
- Yes. Run claude setup-token locally (Pro, Max, Team or Enterprise), store the token as CLAUDE_CODE_OAUTH_TOKEN and pass it to the claude_code_oauth_token input. Runs then use your subscription instead of API billing.
- Why does Claude not respond to @claude?
- Check that the app is installed, workflows are enabled, the secret exists, the comment has @claude as a complete word, and the commenter has write access to the repository.
- Why does CI not run on commits Claude makes?
- GitHub does not trigger workflows on commits made with the default GITHUB_TOKEN. Remove a github_token input set to secrets.GITHUB_TOKEN so the action authenticates as the Claude GitHub App, or pass a custom app token.
- Does Claude open pull requests automatically?
- Not in the default configuration. Claude commits to a new branch and replies with a link to the PR creation page, and a person creates the pull request.