Claude Code Learning Hub
中文 Mingyu's Library

Hub / Tips / F · End-to-end scenarios

Hooking Claude Code into GitHub Actions

Install Claude Code into your repo's CI: one @claude comment in an issue or PR, and it can analyze code, implement features, fix bugs, and open PRs.

The official GitHub Actions integration centers on a single action, anthropics/claude-code-action@v1: install the GitHub App, configure the API key secret, and it automatically decides whether to respond to an @claude mention or execute a prompt directly.

One-line answer

Answer Run /install-github-app in the Claude Code terminal; the interactive flow installs the GitHub App, the workflow file, and the ANTHROPIC_API_KEY secret, and you're wired in — from then on, @claude in any issue/PR comment triggers it. OfficialThis whole installation is the shortcut documented officially, provided you're a repo admin and connect to the Claude API directly.

Steps

  1. Check the prerequisites: OfficialInstalling the GitHub App and adding secrets requires repo admin permissions; the /install-github-app shortcut is only available to users connecting directly to the Claude API — enterprise environments on Amazon Bedrock / Google Cloud need to configure OIDC and IAM manually per the official docs.
  2. Quick install: run /install-github-app in the Claude Code terminal and follow the guided flow to install the Claude GitHub App (it asks for read/write on Contents, Issues, and Pull requests), pick a workflow, and write the API key secret. OfficialSince v2.1.187 you can install just the App and choose "Skip for now", then run the command again later to finish configuring the workflow.
  3. Manual install (fallback): install github.com/apps/claude → add the ANTHROPIC_API_KEY secret in the repo's Settings → copy the official examples/claude.yml into .github/workflows/. OfficialThe minimal workflow looks like this:
    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 }}
  4. Verify: comment @claude explain how this issue should be fixed on any issue or PR. OfficialNote it's @claude, not /claude; the action auto-detects its run mode from the configuration — with a prompt input it executes directly (automation mode), without one it responds to mentions (interactive mode).
  5. Typical workflows: OfficialThree official scenarios: (1) @claude mentions (the basic workflow above); (2) automatic PR review — trigger on pull_request: types: [opened, synchronize] with a prompt that calls the code-review plugin's skill (installed via the plugin_marketplaces + plugins inputs); it runs on every PR without any mention; (3) scheduled jobs — a schedule: cron trigger plus a prompt, e.g. summarizing yesterday's commits and open issues at 9 a.m. every day (for choosing between schedulers see Scheduled tasks). CLI flags all go through claude_args, e.g. --max-turns 10, --model, --allowedTools.
  6. Secrets and permissions: OfficialNever hardcode the API key into the workflow — always go through GitHub Secrets (${{ secrets.ANTHROPIC_API_KEY }}); scope the action's permissions down to the minimum; have a human review Claude's output before merging. Cost adds up on two fronts: GitHub Actions minutes plus API token consumption — put a floor under it with --max-turns, workflow timeouts, and concurrency controls.

Copy-paste prompt

Have Claude Code write the review workflow for you (paste into a local session):

Add a Claude Code GitHub Actions workflow to this repo at .github/workflows/claude.yml:
- Use anthropics/claude-code-action@v1.
- Triggers: the created events of issue_comment and pull_request_review_comment, responding to @claude mentions.
- Read the API key from secrets.ANTHROPIC_API_KEY; no plaintext secrets may appear anywhere in the workflow.
- Add --max-turns 10 in claude_args to prevent runaway usage.
When you're done, explain each section, list the steps I still need to complete manually on GitHub
(installing the Claude GitHub App, adding the secret), and finally show me how to post a test comment to verify.

Sources & last verified

  • OfficialClaude Code GitHub Actions (installation, workflow examples, claude_args, security and cost), fetched 2026-08-05.
  • Last verified: 2026-08-05 · volatility: high (the action version, input names, and install flow evolve with releases; the beta → v1 transition already included one breaking change).