~/academy $ claude learn github-actions-and-ci
Claude Code in GitHub Actions and CI
Set up the Claude Code GitHub Action, respond to @claude in issues and pull requests, run it on a schedule, and keep secrets, permissions and costs under control. 9 min
$ Read
What the action does
The Claude Code GitHub Action (anthropics/claude-code-action@v1, checked 18 November 2026) runs Claude Code inside your repository's workflows. Mention @claude in an issue or pull request comment and it can answer a question, implement the change, push commits and open a pull request.
With no prompt input it waits for the @claude trigger phrase (interactive mode). Give it a prompt and it runs on any GitHub event, such as a schedule or a newly opened pull request (automation mode). A prompt can be plain text or a skill invocation, such as /skill-name for a skill in your repository's .claude/skills/.
Anthropic also offers Code Review, an automatic pull request review that needs no workflow file, and a separate GitLab CI/CD integration. This lesson covers the GitHub Action.
Lesson notes: Claude Code in GitHub Actions and CI
Everything in this lesson as text, for revision or to read without the interactive steps. By the end you will be able to: You install the Claude Code GitHub Action on a repository with tight permissions and a safe secret.
Step 1 of 7 · Read
What the action does
The Claude Code GitHub Action (
anthropics/claude-code-action@v1, checked 18 November 2026) runs Claude Code inside your repository's workflows. Mention@claudein an issue or pull request comment and it can answer a question, implement the change, push commits and open a pull request.With no
promptinput it waits for the@claudetrigger phrase (interactive mode). Give it apromptand it runs on any GitHub event, such as a schedule or a newly opened pull request (automation mode). A prompt can be plain text or a skill invocation, such as/skill-namefor a skill in your repository's.claude/skills/.Anthropic also offers Code Review, an automatic pull request review that needs no workflow file, and a separate GitLab CI/CD integration. This lesson covers the GitHub Action.
Step 2 of 7 · Read
Two ways to set it up
Quick setup: open
claudein the repository and run/install-github-app. It installs the Claude GitHub App, saves the secret, pushes a branch with the workflow and opens GitHub with the pull request ready to create. It needs admin access, a github.com repository and the GitHub CLI signed in withgh auth login.Manual setup: install the app from github.com/apps/claude, add a repository secret, and copy
examples/claude.ymlfrom the action's repository into.github/workflows/. The secret is eitherANTHROPIC_API_KEYfrom the Claude Console orCLAUDE_CODE_OAUTH_TOKEN, which you create by runningclaude setup-tokenon a Pro, Max, Ultra, Team or Enterprise plan (checked 18 November 2026).For a secret shared across an organisation, use a Console API key rather than an OAuth token, because the token is tied to the subscription of whoever created it.
Step 3 of 7 · Try it in the terminal
Run the quick setup
You are in a Claude Code session in a github.com repository where you are an admin. Start the guided GitHub setup.
Hint: A slash command that installs the GitHub app.
Show the command
$ /install-github-app Install GitHub App ✓ GitHub CLI found and signed in Repository: acme/booking-app Opening browser to install the Claude GitHub App... ✓ App installed Select workflows to add: [x] @claude mentions [ ] Code review ✓ Saved secret ANTHROPIC_API_KEY ✓ Pushed branch add-claude-github-actions Opening GitHub to create the pull request...
Step 4 of 7 · Read
A minimal workflow, and what it costs
This responds to
@claudein comments. Theifline stops runners starting on comments that do not mention Claude.claude_argspasses normal CLI flags, here a turn limit.Each run uses GitHub Actions minutes and Claude tokens (or your subscription, with an OAuth token). Keep costs down with specific requests, a short CLAUDE.md,
--max-turnsinclaude_args, atimeout-minuteson the job and GitHub's concurrency controls..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 timeout-minutes: 20 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 }} claude_args: "--max-turns 10"Step 5 of 7 · Read
Guard secrets and permissions
Secrets: never commit an API key or token. Store it as a GitHub secret and reference it as
${{ secrets.ANTHROPIC_API_KEY }}. Deleting the secret does not cancel the key, so also delete it in the Claude Console when you retire it.Who can trigger it: on issue and pull request events the person must have write access to the repository, and bot accounts are rejected unless you list them in
allowed_bots. That stops strangers and loops from spending your budget.What it can do: give the workflow only the
permissionsit needs; a review-only job can use read access. In automation mode a plain-text prompt has no shell or GitHub API access until you grant tools with--allowedTools. And review Claude's pull requests before you merge, like any other contributor's.The Claude GitHub App asks for a broad permission set because several Claude features share it. If your organisation needs less, the action's setup guide explains how to create your own app with only Contents, Issues and Pull requests.
Step 6 of 7 · Quiz
Check your understanding
A scheduled workflow gives Claude the plain-text prompt "summarise yesterday's commits", but it never reads any commits. Most likely cause?
- Scheduled workflows cannot run Claude Code
- The secret must be named CLAUDE_KEY
- With a plain-text prompt, Claude has no shell or GitHub API tools until you grant them in claude_args
Show the answer
With a plain-text prompt, Claude has no shell or GitHub API tools until you grant them in claude_args Add the tools it needs, such as --allowedTools for the GitHub MCP list_commits tool, or check out the code and allow git log.
Step 7 of 7 · Sort
Safe or risky CI setup?
Sort each choice.
- API key stored as a repository secret
- API key pasted into the workflow YAML
- contents: read for a job that only reviews
- Adding every bot to allowed_bots so automation runs smoothly
- --max-turns and a job timeout on every workflow
- Auto-merging every pull request Claude opens
Show the answers
- API key stored as a repository secret: Safe. Secrets are encrypted and masked in logs.
- API key pasted into the workflow YAML: Risky. Anyone who can read the repository can copy it, and it stays in git history.
- contents: read for a job that only reviews: Safe. Least privilege: it cannot push even if something goes wrong.
- Adding every bot to allowed_bots so automation runs smoothly: Risky. Bots can then trigger Claude in loops and burn through minutes and tokens.
- --max-turns and a job timeout on every workflow: Safe. Caps runaway jobs and their cost.
- Auto-merging every pull request Claude opens: Risky. Nobody reviews the change. Treat Claude like any contributor.