Claude Code GitHub Actions: set it up, review pull requests, and run Claude Code in CI
Claude Code GitHub Actions runs Claude Code inside your repository's workflows: mention @claude in an issue or pull request and it analyzes, edits and pushes, or give it a prompt and it runs on any GitHub event, such as every new pull request. Set it up with /install-github-app from Claude Code. Anywhere else in CI, run Claude Code with the -p flag so it never waits for input.
What is Claude Code GitHub Actions?
Claude Code GitHub Actions is the anthropics/claude-code-action GitHub Action: it "runs Claude Code inside your repository's workflows". Mention @claude in a pull request or issue comment and Claude analyzes code, implements changes and pushes commits; give the action a prompt and it runs on any GitHub event. It is built on the Claude Agent SDK.
How to set up Claude Code GitHub Actions
Quick setup. Open claude in the repository and run /install-github-app. It installs the Claude GitHub App, stores your credential as a repository secret (ANTHROPIC_API_KEY for an API key, CLAUDE_CODE_OAUTH_TOKEN for a subscription token) and opens a pull request with the workflow files. Merge it and @claude works. You need admin access to the repository, and the GitHub CLI logged in.
Manual setup. Install the Claude GitHub App, add one of those secrets, and copy the example claude.yml into .github/workflows/.
The app needs read and write access to contents, issues and pull requests; the official app also requests permissions other Claude features use. Organizations that want only the three can create a custom app.
Interactive mode: respond to @claude
Without a prompt input, the action waits for the trigger phrase and answers in the same thread:
yaml
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 }}
Then comment, for example, "@claude fix the failing date check in the booking form". Only users with write access can trigger runs, and bots are rejected unless you allow them, which stops loops.
Automation mode: review every pull request
With a prompt input, the action runs on its own. The prompt can be plain text or a skill such as a code-review skill, triggered on pull_request events (opened, synchronize, ready_for_review, reopened). Pass extra CLI options through claude_args, for example --max-turns 5, --model, --allowedTools and --mcp-config. With a review skill and its --comment argument, Claude posts inline comments on the issues it finds, or one summary comment when it finds none.
Write your review criteria in the repository's CLAUDE.md: code style, what counts as a real issue, what to ignore. Claude reads it on every run.
Claude Code in any CI pipeline: claude -p
Outside GitHub, the same engine runs from the command line with -p (--print), which is non-interactive mode:
bash
claude -p "Review the diff on stdin for bugs and security issues only" \
--output-format json --allowedTools "Read" < <(git diff origin/main)
| Option | What it does in CI |
|---|---|
-p |
Runs once and exits: no prompts, so no hanging job |
--output-format json |
Returns result, session_id and cost; stream-json streams events |
--json-schema '<schema>' |
Adds a structured_output field that follows your schema |
--allowedTools / --permission-mode |
Pre-approves exactly the tools the job needs, or sets a baseline such as dontAsk |
--bare |
Skips local hooks, skills, plugins, MCP servers and CLAUDE.md discovery for repeatable runs |
--continue / --resume <id> |
Follows up in the same conversation |
Claude Code exits 0 on success and non-zero on failure, so the pipeline can branch on it.
Reviews people trust
A review bot that cries wolf gets ignored. Give it explicit criteria (what to report, what to skip) instead of "be thorough", ask for a fixed output format per finding (file, line, severity, fix), and switch off categories that produce noise while you improve them. These are the same techniques covered in our article on few-shot prompting.
Security and cost
- Store credentials only as GitHub secrets; never commit an API key. Organizations can use OIDC workload identity federation instead of a long-lived key.
- Give the workflow only the permissions it needs, and review Claude's changes before merging.
- Each run costs GitHub Actions minutes and API tokens: write specific requests, keep CLAUDE.md short, set
--max-turns, workflow timeouts and concurrency limits. - Bedrock, Google Cloud's Agent Platform and Microsoft Foundry are supported with
use_bedrock,use_vertexoruse_foundry.
Claude Code in CI on the Claude Certified Architect exam
Scenario 5 of the CCAR-F exam is Claude Code for continuous integration, and task statement 3.6 expects the -p flag to avoid interactive hangs, structured output for machine-readable results, CLAUDE.md to give CI runs project context, and review prompts that minimize false positives. The trap: building a custom agent for automatic PR reviews when Claude Code in CI already does it, a point our Agent SDK vs Claude Code comparison covers.
More in all articles.
Sources: Claude Code GitHub Actions; Run Claude Code programmatically; CLI reference; Claude Certified Architect Foundations exam guide v1.0, task statement 3.6 and scenario 5.
FAQ
How do I set up Claude Code GitHub Actions?
Run /install-github-app in Claude Code inside the repository. It installs the Claude GitHub App, saves your API key or subscription token as a repository secret, and opens a pull request with the workflow files. You need admin access to the repository.
What is the difference between interactive and automation mode?
Without a prompt input, the action waits for @claude in a comment and replies there. With a prompt input, it runs on its own on the workflow's trigger, such as a pull request or a schedule.
How do I run Claude Code in other CI systems?
Use claude -p with your prompt. It runs non-interactively, exits 0 on success, and with --output-format json returns the result, the session ID and the cost; --json-schema adds a structured_output field that follows your schema.
How do I keep Claude Code CI runs cheap?
Write specific requests, keep CLAUDE.md concise, cap work with --max-turns in claude_args, and set workflow timeouts and concurrency limits.