Issue 00 · Autumn 2026日本語 · RSS
AgentKoji

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.

TL;DR

  • 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

PieceWhat it does
Claude GitHub AppReads and writes the repository’s files, issues and pull requests
A repository secretANTHROPIC_API_KEY (a Claude Console API key) or CLAUDE_CODE_OAUTH_TOKEN (a token tied to your Claude subscription)
A workflow fileLives 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.

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).

  1. 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.
  2. Add the secret. For a subscription token, run claude setup-token locally (Pro, Max, Team and Enterprise plans).
  3. Copy examples/claude.yml from 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

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.

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

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:

Source: https://code.claude.com/docs/en/github-actions, checked 2026-10-27

When it doesn’t work

SymptomWhat to check
No response to @claudeThe 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 commitsGitHub 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 errorsTest the key or token locally with claude before debugging the workflow
Still on @betaSwitch 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.

Summary

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.