Claude Code setup guide
Set up Claude Code GitHub Actions
With admin access to a github.com repository, run claude in the repository and enter /install-github-app. For manual setup, install the Claude GitHub App, add an API key or subscription token as a repository secret, and save claude.yml in .github/workflows/. Once the workflow is merged, mention @claude in an issue or pull request comment and ask for a specific change.
Last updated
By CWYN · Published · Anthropic’s Claude Code GitHub Actions documentation (as of )
1. Install the GitHub App from Claude Code
Both setup paths require repository admin access. The quick installer supports github.com remotes only. With a gitlab.com or bitbucket.org remote, it prints a notice and exits.
- Sign in to the GitHub CLI with
gh auth login. From the repository directory, startclaudeand enter/install-github-app. - Install the Claude GitHub App for the repository in your browser. Back in the installer, choose Set up GitHub Actions workflows.
- Select the workflows you want. Keep @claude mentions to take requests in comments and PR review for automatic reviews. You can deselect either workflow.
- Choose a long-lived Claude subscription token or a Claude Console API key and confirm. Create the pull request when Claude Code prompts you, check the workflow files, and merge it.
To test the mentions workflow, comment on an open pull request from an account with write access. Try @claude Does the README still describe what this change does? Look for Claude’s reply in the thread. You can also ask it to edit the README and push a commit.
The installer supports the Claude API and Claude subscriptions. For Bedrock, Agent Platform or Foundry, follow the provider-specific setup in Anthropic’s documentation. The corresponding action inputs are use_bedrock, use_vertex and use_foundry.
2. Set up the mentions workflow manually
- Install the Claude GitHub App on the repository where Claude will work.
- Add a repository Actions secret. For an API key from the Claude Console, name it
ANTHROPIC_API_KEY. For a subscription, runclaude setup-tokenlocally and save the resulting token asCLAUDE_CODE_OAUTH_TOKEN. - Copy
examples/claude.ymlfromanthropics/claude-code-actionto.github/workflows/claude.ymlin your repository. The minimal workflow below uses an API key and listens for new issue, PR conversation and inline review comments.
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 }}
The if condition keeps a runner from starting for comments without @claude. For subscription billing, replace the final line under with with the following line.
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
Merge the workflow, then try the README question above in a pull request comment. A reply confirms the event, credential and app permissions work together.
3. Choose an API key or a subscription token
| Setting | Claude Console API key | Claude subscription token |
|---|---|---|
| Repository secret | ANTHROPIC_API_KEY | CLAUDE_CODE_OAUTH_TOKEN |
| Action input | anthropic_api_key | claude_code_oauth_token |
| Who pays for tokens? | Token usage is billed to the key’s Claude API account. | Runs use the token owner’s Claude subscription. |
| Organization use | Prefer a Console API key for a secret shared across the organization. | The OAuth token is tied to one person’s subscription. |
Pro, Max, Ultra, Team and Enterprise subscribers can generate a long-lived token with claude setup-token. Store the credential in GitHub secrets and commit only the reference to the secret.
4. Choose a mention or an automatic prompt
Interactive mode. Leave the prompt input unset. Claude waits for @claude, analyzes the code and replies with a comment. It can implement a requested change and push commits. The sample filters on the comment body. To take mentions in a submitted review or a new issue’s title or body, listen for that event and check the field that holds the text. If you change trigger_phrase, update the workflow’s comment filter to match.
Automation mode. Set prompt to a task you want to run on a GitHub event. Claude runs without a mention, and the result appears in the workflow run log by default. A plain-text prompt needs explicit tool access to run shell commands or use the GitHub API. Allow the tools it needs with --allowedTools in claude_args or permissions.allow in the settings input. To supply an MCP configuration, pass --mcp-config with its path in claude_args.
5. Post a review on a pull request
Select the PR review workflow during quick setup to get automatic feedback without typing @claude. For a workflow you maintain yourself, load code-review@claude-plugins-official through the plugins input. The plugin_marketplaces input lets a workflow specify its plugin sources.
In prompt, invoke /code-review:code-review --comment and identify the pull request to review. In claude_args, pass --allowedTools "mcp__github_inline_comment__create_inline_comment". Claude posts findings inline or leaves one summary comment if it finds nothing. Omitting --comment keeps the review out of the PR conversation.
Claude skips draft and closed pull requests. In a public repository, GitHub withholds secrets from fork PR runs, so automatic reviews run only on branches in the same repository.
6. Estimate cost and limit each run
Each run uses GitHub Actions minutes on a GitHub-hosted runner and Claude tokens. The API key bills those tokens to your Claude API account. An OAuth token uses your Claude subscription. Choose the credential first so you know where to check usage.
- Ask a specific question, such as whether the README’s installation steps still match the change.
- Use an issue template to collect the affected files and the result you expect.
- Keep
CLAUDE.mdconcise. Claude reads it on every run. Start with the project CLAUDE.md template. - Cap the work Claude can do per run with
--max-turns 5inclaude_args. Adjust the cap to fit the task. - Set a timeout on the Claude job in the workflow to bound how long the runner can stay busy.
- Use workflow concurrency controls to keep overlapping runs from reviewing the same change at the same time.
Check your account’s Claude Code usage limits or compare billing options in the cost-per-month guide. Estimate your own.
7. Set permissions and restrict who can trigger a run
The action relies on three GitHub App permissions. Grant Contents, Issues and Pull requests read and write access. The official Claude GitHub App also requests permissions for other features, including Actions, Checks and Workflows. GitHub requires accepting its full set. Organizations that need only the three action permissions can create a custom GitHub App. The separate Code Review product falls outside that custom app’s scope.
The workflow job also declares its permissions. In the example, id-token: write is required for default GitHub App authentication, and actions: read lets Claude read CI results. Grant only the permissions and tools the job needs. For tool-level rules, see how Claude Code permission allowlists work.
On issue and PR events, the person triggering the run needs write access. To make an exception, supply your own github_token and list the account in allowed_non_write_users. Bot actors must be listed in allowed_bots. Keep keys and tokens in GitHub secrets, and review Claude’s changes before merging them.
8. Troubleshoot a missing reply, CI run or review
Claude does not reply to a mention
Check that the app is installed on this repository, Actions workflows are enabled, and the mentions workflow has been merged. Verify the secret name against the workflow input. Comment from an account with write access and use @claude as a whole word. Neither /claude nor @claude-bot is the default trigger.
CI does not run on Claude’s commits
Commits made with the default GITHUB_TOKEN do not trigger workflows. Remove github_token: ${{ secrets.GITHUB_TOKEN }} from the action inputs so the action authenticates as the app. Check that your CI workflow listens for push or pull_request.
The action reports an authentication error
Test the key or token locally with claude first. Once it works there, check that the repository secret contains that credential and the action uses the matching input from the table.
A review ran but no comment appeared
Open the workflow run log. Check the review command for --comment and confirm that claude_args allows the inline comment tool. If the review never ran, check whether the PR is a draft, is closed or comes from a fork of a public repository.
9. Claude Code GitHub Actions FAQ
Does the GitHub Action work with a Claude Max plan?
Yes. Run claude setup-token locally and store the token as CLAUDE_CODE_OAUTH_TOKEN. Pass that secret to claude_code_oauth_token to use your Max subscription for the run.
Can a workflow run Claude Code on a schedule?
Yes. Use a cron entry under on: schedule and supply a prompt. GitHub runs scheduled workflows from the default branch. In public repositories it disables schedules after 60 days without activity.
Which model does the action use?
The action uses the Claude Code default model. To select one for a workflow, pass --model and the model name in claude_args.
What changes when I upgrade a beta workflow?
Change anthropics/claude-code-action@beta to @v1 on the same action and remove mode. Rename direct_prompt to prompt. Move max_turns and model into claude_args as --max-turns and --model. Pass former custom_instructions with --append-system-prompt.