← All guides

Guide

Claude Code GitHub Actions: put a coding agent to work in your repository

Claude Code GitHub Actions is Anthropic's GitHub Action (anthropics/claude-code-action) that runs Claude Code inside your repository's workflows. Mention @claude in an issue or pull request and it reads the code, makes changes and pushes commits; give it a prompt instead and it runs on any GitHub event you choose, from a new pull request to a nightly schedule.

That second mode is what makes it interesting here. A workflow that starts the agent when something happens, rather than when someone asks, is a simple way to give a coding agent a standing job. This guide covers setup, the two modes, working example workflows, and what to watch for before you let it run unattended.

What it is, and what it isn't

The action runs on a GitHub Actions runner, with a checkout of your repository, and posts its progress and results back to the issue or pull request (or to the workflow run log). It's built on the Claude Agent SDK, and it reads the same CLAUDE.md project instructions that Claude Code reads on your machine.

Several products share the Claude Code name. This guide is about the workflow integration you configure with files in .github/workflows/. Anthropic also offers Code Review, which reviews every pull request without a workflow file, and Claude Code in the cloud, which runs sessions on Anthropic's infrastructure instead of your runners.

Setting it up

You need admin access to the repository either way. The quick path is to run claude in the repository and type /install-github-app at the Claude Code prompt. It installs the Claude GitHub App, saves your credential as a repository secret and opens a pull request with the workflow files; merging that pull request turns them on. It only works for repositories hosted on github.com and needs the GitHub CLI signed in.

The manual path, for when you don't run Claude Code locally or want full control:

  • Install the Claude GitHub App on the repository. The action relies on its Contents, Issues and Pull requests permissions (read and write); the app asks for more, because other Claude features share it.
  • Add a secret: ANTHROPIC_API_KEY for a Claude API key from the Claude Console, or CLAUDE_CODE_OAUTH_TOKEN for a token tied to a Claude subscription, generated by running claude setup-token locally.
  • Copy examples/claude.yml from the anthropics/claude-code-action repository into .github/workflows/. It's a working workflow, not just a sample.
  • Test it by mentioning @claude in an issue comment.

Two modes: mentions and automation

  • Interactive mode is what you get when the workflow has no prompt input. Claude waits for the trigger phrase (@claude unless you change trigger_phrase) in an issue or pull request comment, a pull request review, or the title or body of a new issue, then answers in a comment it keeps updating as it works.
  • Automation mode is what you get when the workflow has a prompt input. Claude runs on whatever event triggered the workflow without waiting to be mentioned. By default its output goes to the workflow run log; it posts to an issue or pull request only when the prompt tells it to and it has a tool that can post.

Example: answer @claude mentions

This is the interactive workflow from Anthropic's documentation. The if line stops a runner from starting on comments that don't mention @claude; actions: read lets Claude read CI results on pull requests; id-token: write is needed for the action's default GitHub App authentication. Once it's merged, a comment like “@claude fix the TypeError in the user dashboard component” gets a reply and, where it makes sense, commits.

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

Example: run on a schedule

With a prompt, the same action becomes a job that runs on its own. This one, also from Anthropic's documentation, writes a summary of yesterday's commits and open issues to the run log every morning at 09:00 UTC. A plain-text prompt gets no shell or GitHub API access until you grant it, so claude_args allows exactly the two GitHub tools the job needs.

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: |
            --allowedTools "mcp__github__list_commits,mcp__github__list_issues"

Jobs worth giving it

  • Turning a well-written issue into a pull request: mention @claude in the issue, or have the workflow also listen for new issues (issues: opened) and put the mention in your issue template, so filing the issue starts the work.
  • Fixing a bug from a comment on the pull request where someone found it.
  • Reviewing pull requests as they're opened or updated, with Anthropic's code-review plugin run as a skill from the prompt input.
  • Recurring chores on a schedule: summaries of what changed, checks that docs still match the code, lists of stale issues.
  • Answering questions about the codebase in an issue, without anyone opening an editor.

Who can start a run

Before Claude starts, the action checks the actor that triggered the workflow. On issue and pull request events, that person needs write access to the repository; you can allow specific others with allowed_non_write_users and your own github_token. Bot actors are rejected unless you list them in allowed_bots, which stops two automations from triggering each other in a loop. Scheduled runs skip the write-access check but not the bot check: GitHub attributes them to whoever last changed the cron line.

Gotchas before you rely on it

  • CI doesn't run on its commits? GitHub doesn't trigger workflows for commits pushed with the default GITHUB_TOKEN. Don't pass github_token: ${{ secrets.GITHUB_TOKEN }}; let the action authenticate as the Claude GitHub App, or pass a token from your own app.
  • Scheduled workflows run only from the default branch, and in public repositories GitHub turns a schedule off after 60 days without repository activity.
  • On public repositories, GitHub withholds secrets from runs triggered by pull requests from forks, so a review workflow only runs on pull requests from branches in the same repository.
  • No reply to @claude? Check that the app is installed, workflows are enabled, the secret is set, the commenter has write access, and the comment says @claude as a whole word.
  • Older workflows that use @beta need updating to @v1: the mode input is gone, direct_prompt became prompt, and options such as max_turns and model moved into claude_args.

Keeping it safe and affordable

  • Store the API key or OAuth token as a GitHub secret, never in the workflow file. For several repositories, an organization-level secret holding a Claude Console API key works better than one person's subscription token.
  • Give each workflow only the permissions block it needs. The review and schedule examples above only read; the mention workflow writes.
  • Keep a person on the merge button: let Claude push branches and open pull requests, and review them like any other contributor's.
  • Each run uses GitHub Actions minutes and Claude usage (API tokens, or your subscription with an OAuth token). Cap a run with --max-turns in claude_args, set a timeout on the job, and use GitHub's concurrency controls to limit parallel runs. Check GitHub's and Anthropic's pricing pages for current rates.
  • Keep CLAUDE.md short and current: Claude reads it on every run, so it costs tokens each time and shapes every change.

Where this sits: from mentions to a proactive agent

A mention workflow is a background agent: someone asks, it works on its own runner, it reports back. An automation-mode workflow on an event or a schedule goes a step further, because nobody has to ask. That's the core of a proactive coding agent: a standing job, started by something happening, with the result handed to a person to review.

What a workflow file doesn't give you is judgment about what to start on. You choose the events, write the prompt and decide what it may touch, and that's worth doing carefully, since the agent will run exactly as configured whether or not anyone is watching.

Official documentation

Inputs, examples and permissions change between releases, so check these pages for what's current.

Questions people ask

Is Claude Code GitHub Actions free?

The action itself is open source under the MIT license, but each run uses GitHub Actions minutes and Claude usage: API tokens billed to your Claude Console account, or your Claude subscription if you authenticate with an OAuth token. Check GitHub's and Anthropic's pricing pages for current rates.

Can it run without anyone mentioning @claude?

Yes. Give the workflow a prompt input and the action runs in automation mode on whatever event triggers the workflow, including pull request events and cron schedules.

Will it merge its own pull requests?

Not in the setups Anthropic documents: Claude pushes commits to a branch or pull request, and a person reviews and merges. Keep branch protection on your main branch so that stays true however the workflow is configured.

Does it read CLAUDE.md or AGENTS.md?

It reads CLAUDE.md, the same project instructions Claude Code uses locally. If your instructions live in AGENTS.md, put an @AGENTS.md import at the top of CLAUDE.md so both stay in one place.

Does it work with Bedrock, Google Cloud or Microsoft Foundry?

Yes. Set use_bedrock, use_vertex or use_foundry to "true" and authenticate through OIDC identity federation, following Anthropic's page on using Claude Code GitHub Actions with cloud providers.


Want a coding agent that starts the work itself? Proactive Coding is your proactive coding agent. Get in touch and tell us what you're building.

More guides