AI & Agents

How to Set Up Claude Code GitHub Action for Automated PRs and Code Reviews

Fewer than 20% of AI-generated code review comments lead to actual code changes, based on a study of 22,326 comments across 178 GitHub repositories. Claude Code GitHub Action goes beyond comments by implementing fixes, creating pull requests, and bringing collaborative AI coding to your CI/CD pipeline. This guide covers setup, three workflow patterns, enterprise cloud authentication, and the security hardening lessons from a real vulnerability patched in early 2026.

Fast.io Editorial Team 13 min read
AI agent working within a collaborative team workflow

What Claude Code GitHub Action Does That Comment Bots Cannot

Across 22,326 AI-generated code review comments in 178 GitHub repositories, fewer than one in five led to an actual code change, according to a 2025 study by researchers at Nanjing University. The best-performing AI review tool managed a 19.2% addressing rate. Most AI review bots generate suggestions that developers scroll past without acting on.

Claude Code GitHub Action works differently. Instead of posting review comments, it runs full Claude Code sessions on your GitHub Actions runner. It reads your codebase, understands the context of a pull request or issue, and responds with working code. When someone tags @claude in a PR comment asking for a bug fix, the action does not suggest the fix. It implements the change, pushes a commit to the branch, and updates the pull request.

The v1.0 GA release introduced automatic mode detection. You provide a prompt and optional arguments. The action reads the trigger event and decides how to respond without manual configuration.

Its scope goes well beyond review comments:

  • Implement features and bug fixes from issue descriptions
  • Post inline review comments on specific lines of a pull request
  • Answer architecture questions directly in PR threads
  • Create new pull requests with complete changesets
  • Run on scheduled cron triggers for maintenance and reporting
  • Produce structured JSON outputs for downstream automation
  • Show real-time progress with visual checkbox updates in comments

Four authentication providers cover environments from solo projects to regulated enterprises: Anthropic's direct API, Amazon Bedrock for AWS data residency, Google Vertex AI with Workload Identity Federation, and Microsoft Foundry for Azure environments.

All processing runs on your GitHub Actions runner. Code stays in your CI/CD environment. Only API calls to your chosen LLM provider cross the network boundary. The action supports MCP server integrations, custom tool configurations, and reusable skill definitions for shared automation patterns.

With over 18,100 downstream dependents and 8,200 GitHub stars, Claude Code GitHub Action is the most widely adopted AI coding action on the GitHub Marketplace.

Setting Up the Action in Three Steps

Getting Claude Code GitHub Action running requires admin access to your repository. The whole process takes about five minutes.

Install the Claude GitHub App

Claude Code includes an interactive installer that walks you through app installation, secret configuration, and workflow file creation in one pass. Running the installer from your terminal handles all three steps and lets you return to finish any skipped steps later.

For manual setup, install the official Claude GitHub App at github.com/apps/claude. The app requests three permissions: Contents (read and write), Issues (read and write), and Pull requests (read and write). These let Claude read your code, push commits, and respond in PR threads.

Add your API key as a repository secret

Navigate to your repository Settings, then Secrets and variables, then Actions. Create a new secret named ANTHROPIC_API_KEY with your key from the Anthropic console at console.anthropic.com.

Never hardcode API keys in workflow files. GitHub secrets are encrypted at rest and masked in workflow logs automatically.

Create the workflow file

Add .github/workflows/claude.yml to your repository:

name: Claude Code
on:
  issue_comment:
    types: [created]
  pull_request_review_comment:
    types: [created]

jobs:
  claude:
    runs-on: ubuntu-latest
    steps:
      - uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

This workflow listens for comments on issues and pull requests. When someone writes @claude followed by a request, the action triggers, analyzes the context, and responds.

Test it by opening a pull request and posting a comment like @claude explain the main function in this file. Claude reads the PR diff and the repository structure, then replies in the thread.

Once the workflow is committed, every @claude mention in your repository triggers a Claude Code session. The action automatically checks out the repository, reads the relevant context, and determines whether to respond with an explanation, a code review, or a working implementation.

Claude Cowork in Action: Three Workflow Patterns

The action supports three workflow patterns, and you can combine all of them in the same repository.

Interactive @claude mentions

The basic workflow above handles this pattern. Someone writes @claude in a PR or issue comment, and the action activates. Practical examples:

  • @claude implement the rate limiter described in this issue
  • @claude fix the failing test in checkout.spec.ts
  • @claude refactor the auth middleware to use the new token format
  • @claude how does the payment processing pipeline work?

For implementation requests, Claude pushes commits directly to the PR branch. For questions, it responds with an explanation in the comment thread. The action determines which approach fits based on the request content.

You can customize the trigger phrase using the trigger_phrase input if @claude conflicts with another bot in your repository.

Automatic code review on every push

Adding a prompt input switches the action to automation mode. It runs immediately on the triggering event without waiting for a mention:

name: Code Review
on:
  pull_request:
    types: [opened, synchronize]

permissions:
  contents: read
  pull-requests: write

jobs:
  review:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          prompt: >
            Review this pull request for correctness,
            security issues, and adherence to the project's
            coding standards. Post findings as inline
            review comments on the relevant lines.
          claude_args: "--max-turns 5"

Every PR open and push to an open PR triggers a review. The --max-turns 5 flag keeps review-only runs from iterating beyond what is needed. To restrict reviews to critical paths, add a filter:

on:
  pull_request:
    types: [opened, synchronize]
    paths:
      - 'src/**'
      - 'lib/**'

Scheduled automation Cron-triggered workflows handle recurring tasks without human prompting:

name: Weekly Dependency Audit
on:
  schedule:
    - cron: "0 9 * * 1"

permissions:
  contents: read
  issues: write

jobs:
  audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          prompt: >
            Audit dependencies for known vulnerabilities
            and deprecated API usage. Create a GitHub
            issue with findings and severity ratings.
          claude_args: "--max-turns 8"

The official solutions guide includes ready-to-use patterns for documentation sync, issue triage and labeling, and security-focused code reviews.

Skills and plugin integration

The v1.0 action supports skill invocations through the prompt input. Skills are reusable instruction sets that standardize how Claude handles specific tasks across repositories:

- uses: anthropics/claude-code-action@v1
  with:
    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
    plugin_marketplaces: "https://github.com/anthropics/claude-code.git"
    plugins: "code-review@claude-code-plugins"
    prompt: "/code-review:code-review"

This installs the official code-review plugin and invokes its skill on the PR. Skills provide a structured way to share review criteria across teams and repositories without duplicating CLAUDE.md content.

For teams that need file persistence beyond the ephemeral GitHub Actions runner, platforms like local NAS storage, S3 buckets, or Fast.io can store build artifacts, generated documentation, and audit reports. Fast.io's advantage for agent workflows is that files are automatically indexed for semantic search and available through a consolidated MCP toolset, so Claude can read and write to shared workspaces during CI runs and hand results off to stakeholders who do not monitor GitHub.

Task list showing workflow execution steps and status
Fastio features

Give your CI/CD artifacts a persistent, searchable home

Fast.io workspaces store, version, and index the files your agents create. Connect Claude Code to a shared workspace via MCP for builds, reports, and documentation that your whole team can search and access.

Enterprise Authentication with Bedrock and Vertex AI

Organizations running Claude through AWS or GCP skip the Anthropic API key and authenticate through their cloud provider's identity federation. This keeps billing consolidated, enforces data residency policies, and uses existing access controls.

Both Bedrock and Vertex AI require a custom GitHub App for write operations. The official Claude GitHub App at github.com/apps/claude only works with Anthropic's direct API. Creating your own app takes about ten minutes: go to github.com/settings/apps/new, grant Contents, Issues, and Pull Requests permissions (all read and write), generate a private key, and store the App ID and private key as repository secrets named APP_ID and APP_PRIVATE_KEY.

Amazon Bedrock Bedrock authentication uses GitHub's OIDC identity provider to issue temporary AWS credentials. No static access keys are stored in your repository.

Prerequisites: Amazon Bedrock access with Claude models enabled, GitHub configured as an OIDC identity provider in your AWS account, and an IAM role with AmazonBedrockFullAccess permissions.

The workflow adds credential configuration before the Claude action step:

- name: Configure AWS Credentials
  uses: aws-actions/configure-aws-credentials@v4
  with:
    role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
    aws-region: us-west-2

- uses: anthropics/claude-code-action@v1
  with:
    github_token: ${{ steps.app-token.outputs.token }}
    use_bedrock: "true"
    claude_args: "--model us.anthropic.claude-sonnet-4-6 --max-turns 10"

Note the Bedrock model ID format. Model names include a region prefix: us.anthropic.claude-sonnet-4-6 rather than claude-sonnet-4-6. For cross-region inference, request model access in all required regions through the AWS console.

Google Vertex AI

Vertex uses Workload Identity Federation, which eliminates downloadable service account keys. Enable three APIs in your GCP project first: IAM Credentials, Security Token Service, and Vertex AI.

- name: Authenticate to Google Cloud
  id: auth
  uses: google-github-actions/auth@v2
  with:
    workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
    service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}

- uses: anthropics/claude-code-action@v1
  with:
    github_token: ${{ steps.app-token.outputs.token }}
    use_vertex: "true"
  env:
    ANTHROPIC_VERTEX_PROJECT_ID: ${{ steps.auth.outputs.project_id }}
    CLOUD_ML_REGION: us-east5

The project ID is automatically extracted from the Google Cloud authentication step. You do not need to hardcode it.

Your workflow must include id-token: write in its permissions block for both providers. This allows the GitHub runner to request OIDC tokens for identity federation. For complete workflow files including token generation and checkout steps, see the cloud provider documentation in the official claude-code-action repository.

Security Hardening and Cost Control

In January 2026, security researcher RyotaK at GMO Flatt Security discovered a prompt injection vulnerability in Claude Code GitHub Action rated CVSS 7.8. The checkWritePermissions function unconditionally trusted any GitHub actor whose username ended in [bot], regardless of actual repository permissions. An attacker could register a custom GitHub App, open a crafted issue on a public repository running the action, and trick Claude into exfiltrating environment variables containing OIDC tokens. Those tokens could be traded for write access to the target repository.

Anthropic patched the core bypass within four days. Additional hardening continued through spring 2026, with the fixes shipping in v1.0.94. Because Anthropic's own repository used the same workflow, a successful attack could have pushed malicious code into the action itself, affecting all downstream dependents.

Three practices every team should adopt

Scope permissions to the minimum.

A review-only workflow needs contents: read and pull-requests: write. Granting contents: write when Claude is not pushing commits expands the blast radius without adding value.

Set concurrency controls.

Without a concurrency block, parallel @claude mentions on the same PR spawn competing runs that race each other's commits:

concurrency:
  group: claude-${{ github.event.issue.number || github.event.pull_request.number }}
  cancel-in-progress: true

Cap turns, budget, and time.

Every production workflow should set hard limits:

jobs:
  claude:
    timeout-minutes: 15
    steps:
      - uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          claude_args: "--max-turns 10 --max-budget-usd 3"

The --max-budget-usd flag stops the session when API costs hit the threshold. Combined with timeout-minutes, this prevents both runaway token spend and hung runners.

Controlling costs

GitHub Actions minutes and API token usage are the two cost centers. Minimize both with targeted configuration:

  • Use --max-turns 5 for reviews and --max-turns 15 for implementations
  • Choose claude-sonnet-4-6 for routine reviews, claude-opus-4-6 for complex reasoning
  • Add path filters to avoid triggering on documentation-only changes
  • Set workflow-level timeout-minutes as a backstop for every job

CLAUDE.md for consistent behavior A CLAUDE.md file at your repository root acts as persistent instructions for every Claude Code session, including GitHub Actions runs. Define coding standards, banned patterns, testing requirements, and architecture decisions. Claude follows these guidelines automatically when reviewing or implementing code.

Keep the file focused. A concise CLAUDE.md that covers naming conventions, error handling expectations, and key architectural boundaries produces consistent results without inflating prompt token costs.

Migrating from beta to v1.0

If your workflows still reference @beta, the migration is straightforward. Remove the mode setting (now auto-detected), consolidate prompt and configuration inputs, and switch to the v1 tag:

### Before (beta)
- uses: anthropics/claude-code-action@beta
  with:
    mode: "tag"
    direct_prompt: "Review this PR"
    max_turns: "10"

### After (v1.0)
- uses: anthropics/claude-code-action@v1
  with:
    prompt: "Review this PR"
    claude_args: "--max-turns 10"

The old claude_env input is replaced by a settings JSON format. See the migration guide in the official repository for the complete reference.

Audit log showing tracked AI agent actions and changes

Frequently Asked Questions

How do I set up Claude Code GitHub Action?

Install the Claude GitHub App on your repository, add your ANTHROPIC_API_KEY as a repository secret, and create a workflow file in .github/workflows/. The fast method is running /install-github-app in your Claude Code terminal, which handles all three steps interactively. You need admin access to the repository.

How does @claude work in pull requests?

When you write @claude in a PR or issue comment, the GitHub Actions workflow triggers a Claude Code session on your runner. Claude reads the full PR diff, the issue context, and your repository structure, then responds in the comment thread. For implementation requests, it pushes commits to the PR branch. For questions, it posts an explanation.

Can I use Claude Code GitHub Action with AWS Bedrock?

Yes. Configure GitHub's OIDC identity provider in your AWS account, create an IAM role with Bedrock permissions, and set use_bedrock to true in the action inputs. You also need a custom GitHub App because the official Claude app only works with the direct Anthropic API. Bedrock model IDs use a region prefix format like us.anthropic.claude-sonnet-4-6.

What can Claude Code GitHub Action automate?

Code reviews, feature implementation, bug fixes, PR creation, dependency audits, documentation sync, issue triage, and scheduled repository health checks. The action runs full Claude Code sessions with access to your codebase, GitHub APIs, and any MCP servers you configure. It can push commits, create issues, and post review comments.

How much does running Claude Code GitHub Action cost?

Two cost centers apply: GitHub Actions runner minutes (billed by GitHub based on your plan) and API token usage (billed by your LLM provider based on prompt and response length). Control costs with --max-turns to limit iterations, --max-budget-usd to cap API spend per run, and timeout-minutes at the job level to prevent hung runners.

Is Claude Code GitHub Action secure for public repositories?

The action runs on your own GitHub runner, and code stays in your CI/CD environment. A prompt injection vulnerability (CVSS 7.8) was discovered in January 2026 and patched in v1.0.94 within four days. For public repositories, scope workflow permissions to the minimum needed, set concurrency controls to prevent racing runs, and be cautious with external contributor triggers since PR descriptions and issue bodies can contain adversarial prompts.

Related Resources

Fastio features

Give your CI/CD artifacts a persistent, searchable home

Fast.io workspaces store, version, and index the files your agents create. Connect Claude Code to a shared workspace via MCP for builds, reports, and documentation that your whole team can search and access.