Course/Automation for Power Users

8 min · +150 XP

Claude in GitHub Actions

Mention @claude in an issue or a pull request and the work happens in your repository.

By the end of this lesson

You will be able to connect a GitHub repository to Claude Code, trigger it with @claude and keep its runs safe and affordable.

The Claude Code GitHub Action runs Claude Code inside your repository's GitHub workflows. Someone writes @claude in an issue or a pull request comment, and Claude reads the code, makes the change and pushes commits or answers in the thread. It can also run on its own, on a schedule or when a pull request opens.

Quick setup

From your computer

  1. 1Ask Claude: "install the GitHub CLI and help me sign in to GitHub". You need admin access to the repository.
  2. 2Open the repository folder in the terminal and start claude.
  3. 3Type /install-github-app and follow the prompts. It works only with repositories on github.com.
  4. 4Claude Code installs the Claude GitHub App and saves a repository secret: your API key, or a long-lived token from your Claude subscription.
  5. 5It pushes a branch with the workflow files and opens a pull request in your browser. Create and merge it.
  6. 6Test it: in an issue, write @claude fix the TypeError in the user dashboard component.
💬 Or set it up by request

“Set up a GitHub Action in this repository that answers @claude mentions in issues and pull requests, using anthropics/claude-code-action@v1. Write the workflow file, tell me which secret to add on GitHub and where, never put a key into the files, and open a pull request with the change.”

Useful when you want to read every line first, or to change an existing workflow. Claude tells you which steps need you in the browser, such as installing the Claude GitHub App and adding the secret.

The workflow file

.github/workflows/claude.yml
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 }}

What matters in it

  1. 1on: the events that start it; here, new comments on issues and on pull request reviews.
  2. 2if: skips the job when the comment does not mention @claude, so no runner starts for nothing.
  3. 3permissions: what the job may do in the repository. id-token: write is needed for the action's GitHub App authentication; actions: read lets Claude read CI results.
  4. 4No prompt input: the action waits for @claude (interactive mode). With a prompt input it runs without a mention (automation mode).
  5. 5With a subscription token, replace the last line with claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}.
!Secrets and access

Never commit an API key or a token. Store it as a GitHub secret and reference it as in the example. On issues and pull requests only users with write access can trigger the action, and bot accounts are rejected unless listed in allowed_bots. Give the workflow only the permissions it needs, and review Claude's changes before merging.

Costs and limits

Keep runs small

  1. 1Each run uses GitHub Actions minutes and tokens: API billing with an API key, your subscription's limits with an OAuth token.
  2. 2Write specific @claude requests, so fewer turns are needed.
  3. 3Add --max-turns to claude_args and set a timeout on the job.
  4. 4Keep CLAUDE.md short: Claude reads it on every run.
  5. 5Use GitHub's concurrency controls to limit parallel runs.

/code-review in your own Claude Code session checks the current changes, or a pull request number you pass, on any plan. Code Review, a managed service for Team and Enterprise plans, reviews every pull request on GitHub and posts inline comments; an Owner of the organisation turns it on. For GitLab, a Claude Code GitLab CI/CD integration exists; it is in beta and maintained by GitLab.

✦Going further

claude setup-token creates the subscription token. It can only make model requests and is tied to the subscription of whoever created it, so for a secret shared across an organisation the docs recommend a Console API key, or workload identity federation with GitHub OIDC and no stored secret. The prompt input accepts a skill: /skill-name from .claude/skills/ after actions/checkout, or a plugin skill installed through the plugin_marketplaces and plugins inputs. With a plain-text prompt in automation mode, Claude has no shell or GitHub API tools until you allow them with --allowedTools in claude_args. To refresh an old generated workflow, run /install-github-app again and choose Update workflow file with latest version.

Quick check

Your workflow has a prompt input and runs on every new pull request. Does someone need to write @claude?

Quick check

Where should CLAUDE_CODE_OAUTH_TOKEN be kept?

Facts checked against the official Claude Code docs October 24, 2026 · source

EAEvgenii Arsentev

Author

Evgenii Arsentev

PhD · Chief Executive Officer, digital health