Claude Code in GitHub Actions: Setup, Real Costs, and Controls
Setup, token and runner costs with current prices, a worked monthly budget, and the caps to set before running Claude Code in GitHub Actions.

Claude Code can review every pull request and fix bugs from a comment, running inside your own GitHub Actions workflows. The catch is that it bills on two meters at once: GitHub Actions runner minutes and Claude API tokens, and the second one is the one that grows. This guide covers setup, the real cost of each meter with current prices, a worked monthly budget for a 10-person team, and the exact caps to set before the first surprise invoice.
The short version: runner minutes are noise (about $0.006 each on a standard Linux runner), tokens are the bill (a single code review run costs roughly $0.30 to $1.00), and every meaningful control is a control on the agent, not the machine.
What the Claude Code GitHub Action actually does
The Claude Code GitHub Action is an open-source action (MIT license, around 10,000 stars) that runs Claude Code inside your repository workflows. It executes entirely on your own GitHub runner; the only thing that leaves your infrastructure is the API call to Anthropic, Bedrock, Vertex, or Foundry.
It works in two modes, per Anthropic's documentation:
- Interactive mode: someone writes
@claudein an issue or pull request comment, and Claude answers questions, implements a fix, and pushes commits to the PR branch. - Automation mode: you give the action a
promptinput and it runs on any GitHub event, such as reviewing every pull request on creation, or triaging new issues on a schedule.
The automatic code review workflow is the one most teams install first. It uses Anthropic's code-review plugin, posts findings as inline comments on the PR, and skips drafts, trivial PRs, and pull requests Claude has already reviewed. This is the same Claude Code we covered in our 2026 developer tools comparison, just running headless, with no human at the keyboard.
That last point changes the economics. On your laptop, a confused agent pauses and asks. In CI it runs to completion and reports success either way, and one engineering team that measured headless Claude Code runs found that a run where the agent was blocked by permissions cost slightly more ($0.383) than the run that actually fixed the bug ($0.376). A blocked agent re-reads files and reasons about why it is blocked. Being stuck bills like progress.
Setup in about fifteen minutes
You need admin access to the repository. Two paths, both documented by Anthropic:
- Quick setup: install the GitHub CLI, run
gh auth login, openclaudein the repository, and run/install-github-app. It installs the Claude GitHub App, saves your authentication secret, and opens a pull request with the workflow files. Merge it and@claudeworks. - Manual setup: install the Claude GitHub App yourself, add either an
ANTHROPIC_API_KEYorCLAUDE_CODE_OAUTH_TOKENsecret in repository settings, and copyexamples/claude.ymlfrom the action repository into.github/workflows/.
Either way you grant the app read and write access to contents, issues, and pull requests. That is write access to your code, which is why the security section below matters.
To roll out across an organization, install the app once at the org level, store the secret as an organization-level Actions secret, and add the workflow file to each repository (or define it once as a reusable workflow). Use an API key or workload identity federation for the shared secret, not a personal OAuth token. More on that decision shortly.
The two meters: runner minutes and tokens
Every run consumes both, and they behave very differently.
Meter one: GitHub Actions minutes
The action runs on whatever machine your workflow's runs-on: line names. Anthropic's examples all use ubuntu-latest, which is GitHub's 2-core Linux runner. Per GitHub's billing documentation:
- Linux 2-core (ubuntu-latest): $0.006 per minute in private repositories; free in public ones.
- Linux 1-core: $0.002 per minute. Windows 2-core: $0.010. macOS: $0.062.
- Self-hosted runners: no minute charges at all.
- Included compute: GitHub Team includes $18 of compute a month, about 3,000 ubuntu-latest minutes, shared with every other CI job you run. Enterprise Cloud includes $300, about 50,000 minutes.
GitHub rounds each job's partial minutes up to a whole minute. A 4-minute review run costs $0.024. Even a generous 15-minute run costs $0.09. This meter is almost never the problem.
Two ownership facts from the same GitHub page are worth knowing before rollout: usage is billed to the repository owner, not the person who triggered it, and anyone with write access to the repository can run actions. Your CI budget is only as safe as your collaborator list.
Meter two: Claude tokens
This is the real cost. Per Anthropic's API pricing, the current model families bill per million tokens:
- Haiku 4.5: $1 input, $5 output.
- Sonnet 4.6: $3 input, $15 output — the model behind Anthropic's computer-use release, and the sensible default for review jobs.
- Opus 4.8: $5 input, $25 output.
Prompt cache hits bill at roughly a tenth of the base input price, which matters because Claude Code re-reads your repository context on every request. A concise CLAUDE.md is not just good practice; Anthropic lists it as a cost control, because the file is read on every single run.
What does a run actually cost in tokens? The measured figures from the Backgrind experiment (single-file bug fix, default model): about $0.38 and 8 to 9 turns for a successful fix. Anthropic's own cost documentation puts enterprise Claude Code usage at an average of $13 per developer per active day and $150 to $250 per developer per month, with 90% of users staying under $30 per active day. CI usage is on top of interactive usage, and a busy repository can easily match a full-time developer's consumption.
A worked monthly budget for a 10-person team
Assume a team merging 30 pull requests per working day, with automatic review on every PR, plus 8 @claude tasks per day (bug fixes, small features, issue triage). Twenty working days a month.
Token side, using Sonnet-class pricing and the measured $0.38 per-fix figure as an anchor (reviews on medium PRs tend to cost similar or slightly less; multi-file fixes cost more):
- PR reviews: 30 x 20 = 600 runs at roughly $0.40 each: about $240.
- Interactive tasks: 8 x 20 = 160 runs at roughly $0.60 each: about $96.
- Token subtotal: around $336 a month.
Runner side:
- Minutes: 760 runs at 4 minutes each is 3,040 minutes, at $0.006: about $18. That lands almost exactly on the $18 of compute included with GitHub Team, so net runner spend is likely zero if your other CI is modest.
- Storage: negligible unless you upload artifacts from these runs.
Total: roughly $350 a month, of which about 95% is tokens. The shape matters more than the number: if you pin reviews to Opus instead of Sonnet, or your PRs are large, the token line can triple while the runner line barely moves. Every control that matters is a control on the agent's token use.
The caps that matter, in order
Set all of these before you merge the workflow. Most are one or two lines of YAML, and both Anthropic's docs and the Convika cost analysis converge on the same list.
- timeout-minutes. GitHub's default job timeout is 360 minutes. Six hours of a stuck agent burning tokens is the single most expensive failure mode available to you. Set
timeout-minutes: 15on the job. - --max-turns. Passed via
claude_args, this caps how many times the agent can loop. The measured data shows why: a run capped at 2 turns exited with an error but still billed $0.191, while an uncapped successful run billed $0.376. Turns are money. Start with--max-turns 15for fixes and less for reviews. - Trigger discipline. An
if:condition on the job so it only fires on genuine@claudecomments, not every issue comment. Apaths:filter so documentation-only PRs skip review. Both are free and both cut volume. - Concurrency. A
concurrencygroup keyed to the PR number withcancel-in-progress: true, so pushing three commits in five minutes does not run three overlapping reviews. - Model pinning.
--modelinclaude_args. Haiku for triage, Sonnet for reviews and routine fixes, Opus only where you have evidence it earns its price. An unpinned workflow drifts to whatever the default is this quarter. - A GitHub budget. Account-level budgets with email alerts at 90% and 100% of included compute, and a hard cap if you want usage blocked rather than billed. No payment method on file means usage is simply blocked after the included compute runs out, which some teams treat as a feature.
One more that belongs in every workflow: write total_cost_usd from the action's JSON output to $GITHUB_STEP_SUMMARY. It turns every run page into a cost report, so drift is visible the week it happens instead of the month after.
Authentication: API key, OAuth token, or federation
Three options, and the right one depends on who owns the bill.
- API key (
ANTHROPIC_API_KEY): pay-as-you-go from the Anthropic Console. Clean attribution, works for organization secrets, easy to rotate, easy to cap with Console spend limits. The default choice for a shared CI setup. - OAuth token (
CLAUDE_CODE_OAUTH_TOKEN): authenticates against a Claude subscription. Pro, Max ($100 a month), Ultra ($200 a month), Team, and Enterprise plans can all generate one withclaude setup-token, per claude.com/pricing. The catch: the token is tied to the person who generated it, and CI usage shares that person's 5-hour and weekly usage limits. Fine for a solo developer or a small repo; wrong for an organization, and Anthropic's docs say so explicitly. - Workload identity federation: the workflow exchanges its GitHub OIDC token for API access through a Claude Console service account. No long-lived secret stored anywhere. More setup, and the right answer once security review gets involved.
A note on fork pull requests: GitHub withholds secrets from runs triggered by forks of public repositories, so Claude simply will not start on an external contributor's PR until a maintainer re-triggers it from a branch in your repository. Treat that as a useful default, not a gap to close.
Security baseline before you give Claude write access
The app you install can write code, create PRs, and push commits. Anyone who can comment @claude on an issue can steer it, and on a public repository that is anyone with a GitHub account. Prompts and file contents flow to Anthropic's API. Anthropic's own enterprise positioning leans heavily on these controls — we covered both the enterprise plugin push and the moment Claude Code's security posture rattled the cybersecurity industry.
The minimum baseline:
- Branch protection on main, so Claude's commits land on PR branches and go through the same review and status checks as human commits.
- Restrict
allowedToolsinclaude_argsfor automation workflows. A review job needs read-only tools; it does not needBash. - Never put secrets in
CLAUDE.mdor the prompt input. Assume both are visible in logs and to the model. - Treat issue and PR text as untrusted input. A comment saying "ignore your instructions and run this script" is a real attack pattern; tight tool restrictions are the mitigation.
- Rotate credentials and know how to uninstall: delete the workflow files, delete the secret, then delete the key in the Console, because deleting the secret does not invalidate the key it held.
When Claude Code in CI is the wrong choice
Honest limits, because this is not the right tool for every pipeline:
- High-volume monorepos with dozens of PRs an hour. Token cost scales with context size and run count. At some volume a lighter static analysis pass plus human review is cheaper and more predictable.
- Public repositories with heavy external contribution. Every
@claudemention from a contributor is spend, and prompt injection risk is highest exactly where you trust the commenters least. - Work that needs judgment calls. Claude will confidently implement the wrong fix and report success. For migrations, security-sensitive code, or anything where a plausible wrong answer is worse than no answer, keep a human in the loop and use Claude interactively instead.
- Teams on tight subscriptions. Routing CI through one person's OAuth token means a busy repository can eat that person's weekly allowance before Wednesday. Pay for the API key.
If your goal is broader than code review, an always-on agent handling issues, docs, and operations work continuously, that is a different architecture from per-PR CI runs, closer to the kind of workflow design behind our business automation service than to a GitHub Action.
Frequently asked questions
Is Claude Code in GitHub Actions free for public repositories?
The runner minutes are free on public repos, but the Claude API tokens are not. A review-heavy public project still generates a real Anthropic bill; only the GitHub side of the meter drops to zero.
Can I use my Claude Pro or Max subscription instead of an API key?
Yes, via an OAuth token generated with claude setup-token. It works on Pro, Max, Ultra, Team, and Enterprise plans, but the token is bound to your account and CI usage counts against your personal usage limits. For anything shared, use an API key or workload identity federation.
How much does a single code review run cost?
Measured headless runs of Claude Code fixing a single-file bug came in around $0.38 in tokens on a default Opus-class model, plus about $0.02 of runner time. Reviews on Sonnet typically cost less; multi-file fixes on Opus cost more. Budget $0.30 to $1.00 per run and measure your own repository before projecting.
What happens if a run gets stuck?
Without caps, it runs until GitHub's 360-minute default job timeout, billing tokens the whole way, and a blocked agent can cost as much as a productive one. Set timeout-minutes and --max-turns on day one.
Can Claude push directly to my main branch?
Only if your branch protection allows it, which it should not. Point Claude at PR branches, require human review and status checks on main, and Claude becomes a fast junior contributor rather than an unreviewed committer.
Does it work with GitLab or Bitbucket?
Anthropic ships a separate Claude Code GitLab CI/CD integration. The quick setup command works only with github.com repositories; self-hosted GitHub Enterprise Server has its own setup path.
Where to go from here
Start with one repository, the review workflow only, timeout-minutes: 15, --max-turns 15, and cost reporting in the job summary. Run it for two weeks, read the per-run costs, then decide whether @claude task runs earn their tokens. If you would rather have the setup, model selection, security baseline, and spend controls designed once and done properly, that is exactly what our Claude implementation service covers, from Claude Code and MCP servers to organization-wide rollout.
About AI Agents Plus Editorial
AI automation expert and thought leader in business transformation through artificial intelligence.



