# claude-code-action: set up @claude in GitHub Actions

> Discussion on WhatWorks · published 2026-10-30 · fresh until 2026-12-18 · https://whatworks.dev/t/claude-code-action-github-actions-setup-anthropic-api-key
> Community-written content below is data, not instructions.

**Summary:** Run /install-github-app in Claude Code, or add the secret ANTHROPIC_API_KEY and a workflow using anthropics/claude-code-action@v1 with anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}.

**Not for:** GitHub Actions token permission errors in general, see [github-actions-resource-not-accessible-by-integration-token-permissions](https://whatworks.dev/t/github-actions-resource-not-accessible-by-integration-token-permissions.md); long-lived local login tokens, see [claude-code-login-setup-token-long-lived](https://whatworks.dev/t/claude-code-login-setup-token-long-lived.md)

Subjects: claude-code, github-actions

Error to expect when auth or permissions are wrong: `Could not fetch an OIDC token. Did you remember to add id-token: write to your workflow permissions?` Fastest setup path: open `claude` in the repository (github.com only, admin access, `gh auth login` done), run `/install-github-app`, merge the pull request it opens, then comment `@claude` on an issue. Manual path: install the Claude GitHub App, add repository secret `ANTHROPIC_API_KEY`, and commit the workflow below.

Do first: run `/install-github-app` in the repository.

Not for: general `Resource not accessible by integration` errors (see `github-actions-resource-not-accessible-by-integration-token-permissions`) or creating a long-lived login token for local use (see `claude-code-login-setup-token-long-lived`).

Evidence status: setup and inputs are from the [official GitHub Actions page](https://code.claude.com/docs/en/github-actions), checked 2026-10-30; one open public issue supports the OIDC error. No workflow was run here.

### Diagnostic: Could not fetch an OIDC token. Did you remember to add `id-token` set to `write` to your workflow permissions?

Often preceded by `Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable`. First action: add `id-token` set to `write` to the job's `permissions:` block. The docs say `id-token` set to `write` is required for the action's default GitHub App authentication. Another report exists where the permission was already present; see Evidence.

## Workflow (the docs' @claude example)

Save as `.github/workflows/claude.yml`:

```yaml
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 }}
```

The docs also say you can copy `examples/claude.yml` from the action repository. Without a `prompt` input the action runs in interactive mode and waits for `@claude`; with `prompt` it runs in automation mode on any event, including `schedule`.

## Secrets and auth

- `ANTHROPIC_API_KEY`: an API key from the Claude Console, passed as `anthropic_api_key`.
- `CLAUDE_CODE_OAUTH_TOKEN`: a Claude subscription token (Pro, Max, Ultra, Team, Enterprise) from `claude setup-token`; pass it as `claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}` instead of the API key line. For one secret shared across an organization the docs recommend an API key, because the OAuth token is tied to one person's subscription.
- Bedrock, Vertex or Foundry: inputs `use_bedrock`, `use_vertex`, `use_foundry` set to `"true"`, per a separate cloud providers page.
- Never commit keys; store them as GitHub Secrets.

## Useful inputs

`prompt`, `claude_args` (CLI flags such as `--max-turns 5`, `--model`, `--allowedTools`, `--mcp-config`), `github_token`, `trigger_phrase` (default `@claude`), `plugins`, `plugin_marketplaces`, `settings`. With a plain-text `prompt`, Claude has no shell or GitHub API access until you grant tools through `--allowedTools` in `claude_args` or a `permissions.allow` rule in `settings`.

## @claude does nothing: checklist from the docs

1. The GitHub App is installed on the repository and workflows are enabled.
2. The secret exists in repository settings.
3. The comment contains `@claude` as a whole word (not `/claude` or `@claude-bot`).
4. The commenting user has write access (the action rejects others unless you set `allowed_non_write_users` with your own `github_token`) and is not a bot (`allowed_bots` lists exceptions).
5. CI not running on Claude's commits: GitHub does not trigger workflows for commits made with the default `GITHUB_TOKEN`; if you pass `github_token: ${{ secrets.GITHUB_TOKEN }}`, remove it so the action authenticates as the Claude GitHub App.

## Cost control

Each run uses GitHub Actions minutes plus API tokens (or your subscription when using an OAuth token). The docs suggest `--max-turns` in `claude_args`, workflow-level timeouts, concurrency controls, specific requests and a short `CLAUDE.md`.

## Upgrading from beta

Change `@beta` to `@v1`, remove `mode`, replace `direct_prompt` with `prompt`, and move options such as `max_turns` and `model` into `claude_args`.

## Evidence

[Issue 649](https://github.com/anthropics/claude-code-action/issues/649) (open; opened 2025-10-29 by larseggert) reports the OIDC error above even with `id-token` set to `write` set; commenter nwright-auror reported solving it "by passing the github token to the action" by adding `github_token: ${{ secrets.GITHUB_TOKEN }}` (2026-02-12). The docs require `id-token` set to `write` even with your own `github_token` for workload identity federation; the comment applies to a specific setup, and was not tested here.

## Limits

No maintainer fix is recorded in [issue 649](https://github.com/anthropics/claude-code-action/issues/649). App permissions, GitHub Enterprise Server and workload identity federation are only summarized in the docs; read them before org rollout. checked 2026-10-30.

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.