Claude Code GitHub Actions: Set Up @claude on Issues and PRs
Install the app, add one secret, commit one workflow, then tag the agent where the work already is.
What Claude Code GitHub Actions does
Claude Code GitHub Actions is Anthropic's anthropics/claude-code-action: a GitHub Action that runs Claude Code inside your repository's own workflows. Someone with write access mentions @claude in an issue or pull request comment, a runner starts, and Claude reads the thread and the code, answers in a comment, and pushes commits to a branch when the request calls for a change.
It is the GitHub-native version of tagging an agent in chat: the request, the agent's progress comment and the resulting branch all live on the issue or PR the team is already looking at. OpenAI's agent has a hosted version of the same flow; see our guide to the Codex GitHub integration.
| What it means | |
|---|---|
| Runs on | GitHub Actions runners, using your Actions minutes |
| Triggered by | @claude in a comment, review or new issue (interactive mode), or any GitHub event when the workflow sets a prompt (automation mode) |
| Authenticates with | A Claude API key (ANTHROPIC_API_KEY), a Claude subscription token (CLAUDE_CODE_OAUTH_TOKEN), workload identity federation, or Amazon Bedrock, Google Cloud or Microsoft Foundry |
| Acts on GitHub as | The Claude GitHub App, with a short-lived token scoped to the one repository |
| Opens pull requests | Not by default: it pushes a branch and replies with a link to create the PR, so a person opens it |
Before you start
- Admin access to the repository. Both setup paths need it.
- A repository on github.com. The
/install-github-appcommand does not set up GitLab or Bitbucket repositories, and self-hosted GitHub Enterprise Server has its own setup in Anthropic's docs. - A way to pay for the model: a Claude API key from the Claude Console, or a Claude subscription that can generate a long-lived token with
claude setup-token. Which plans include that is listed in Anthropic's authentication docs. - GitHub Actions enabled for the repository, with minutes to spend.
- For quick setup only: Claude Code installed locally and the GitHub CLI signed in with
gh auth login.
Quick setup with /install-github-app
If you already use Claude Code in a terminal, this is the shortest path. It does the three manual steps below for you and ends with a pull request you merge.
- Open
claudein a local clone of the repository and run/install-github-app. - Approve the Claude GitHub App install when the browser opens. You can stop here with Skip for now and finish later by running the command again.
- Pick a credential. Claude Code reuses an API key it already has, or offers to create a subscription token, and saves it as the repository secret
ANTHROPIC_API_KEYorCLAUDE_CODE_OAUTH_TOKEN. - Choose the workflows you want: the
@clauderesponder (claude.yml) and, optionally, an automatic review workflow (claude-code-review.yml). - Claude Code pushes a branch with those files and opens GitHub with a pull request ready to create. Create it, merge it, and
@claudeworks in the repository.
Running /install-github-app again on a repository that already has claude.yml offers to update the workflow files to the latest version, through a new pull request.
Manual setup in three steps
Use this path when you don't run Claude Code locally, when the quick setup fails, or when you want to review every line that lands in .github/workflows/.
- Install the Claude GitHub App from github.com/apps/claude on the repository (or on the organization, for all or selected repositories).
- Add one Actions secret under Settings → Secrets and variables → Actions:
ANTHROPIC_API_KEYfor an API key, orCLAUDE_CODE_OAUTH_TOKENfor a subscription token. - Commit a workflow file such as
.github/workflows/claude.yml. The one below is the minimal responder from Anthropic's docs.
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 }}If you stored a subscription token instead, replace the last line with claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}. The id-token: write permission is what the action's default GitHub App authentication needs; actions: read lets Claude see CI results on a pull request. The fuller examples/claude.yml in the action's repository also listens for new issues and submitted reviews that mention @claude.
Tagging @claude: what to write and what comes back
Once the workflow is on the default branch, a mention in an issue or PR comment is the whole interface:
@claude implement this feature based on the issue description
@claude how should I implement user authentication for this endpoint?
@claude fix the TypeError in the user dashboard component- Claude replies in a comment on the same thread and keeps updating it as it works.
- For a change, it commits to a new branch (or to the pull request's own branch) and gives you a link to open the PR. It does not open the pull request itself in the default setup.
- The mention has to be
@claudeas a whole word./claudeor@claude-botwon't trigger it unless you changetrigger_phrase. - Specific requests finish in fewer turns. Put acceptance criteria in the issue, and keep project rules in a short
CLAUDE.mdat the repository root, which Claude reads on every run.
Interactive mode and automation mode
The action picks its mode from the workflow, with no mode setting:
- Interactive mode: no
promptinput. Claude waits for the trigger phrase in a comment, a review, or the title or body of a new issue, and answers on the thread. - Automation mode: the workflow sets
prompt, so Claude runs on whatever event starts the workflow (a pull request opening, a label, a cron schedule) with no mention needed. Results go to the workflow run log unless the prompt tells Claude to post and it has a tool that can.
In automation mode Claude has no shell or GitHub API access until you grant the tools a plain-text prompt needs with --allowedTools in claude_args. Scheduled workflows run only from the default branch.
Who can trigger a run
Two checks run on the triggering actor before Claude starts, and the run fails if either rejects it:
- Write access: on issue and pull request events, the person must have write access to the repository.
allowed_non_write_usersrelaxes this, and the action's own security docs call that risky and meant only for workflows with very limited permissions. - Human actor: bots and GitHub Apps can't trigger runs unless listed in
allowed_bots, which keeps two agents from setting each other off in a loop. Prefer named bots over'*', especially on public repositories.
On pull requests from authors without write access, the action also denies common commands that run repository code (package managers, test runners, shells) by default, and restores Claude's configuration files such as .claude/ and CLAUDE.md from the base branch.
Locking it down
- Know what the app can do. The official Claude GitHub App is shared by every Claude feature on GitHub and asks for one broad permission set, which GitHub doesn't let you accept in part. The action itself uses Contents, Issues and Pull requests. If your policy allows only those, create a custom GitHub App with just them, following the action's setup guide; Code Review and web auto-fix still need the official app. Our piece on GitHub App permission scopes for coding agents covers how to weigh each scope.
- Keep the job's
permissions:block to what the workflow needs. A review-only workflow can run withcontents: readandpull-requests: read. - Protect the default branch. Claude's push wrapper can't update other branches, but a workflow can allow other push commands. See least-privilege branch protection rules for agent commits.
- Treat outside contributors' text as untrusted. The action strips HTML comments, invisible characters and hidden attributes, but review raw content before tagging Claude on it, and use
include_comments_by_actoron public repositories. - Never put a key in the workflow file. Reference it as
${{ secrets.ANTHROPIC_API_KEY }}, and leaveshow_full_outputoff on public repositories, since full output can print secrets into public logs. - Cap each run:
--max-turnsinclaude_args, atimeout-minuteson the job, and aconcurrencygroup so a burst of mentions doesn't start a burst of runners. - Avoid checking out an untrusted pull request head before the action in
pull_request_targetorworkflow_runworkflows, which run with the base repository's secrets.
For a whole organization, install the app once at organization level, store the credential as an organization Actions secret (an API key rather than one person's subscription token), and add the workflow to each repository or call it as a reusable workflow. Workload identity federation removes the stored secret altogether.
When @claude doesn't respond
| Symptom | Check |
|---|---|
| No run starts | The workflow file is on the default branch, Actions are enabled, and the comment contains @claude as a whole word |
| Run starts, then fails at once | The commenter has write access, the actor isn't a bot missing from allowed_bots, and the secret name matches the input (anthropic_api_key or claude_code_oauth_token) |
| Authentication errors | Test the key or token locally with claude before debugging the workflow |
| CI doesn't run on Claude's commits | Remove github_token: ${{ secrets.GITHUB_TOKEN }} so the action pushes as the Claude GitHub App; GitHub doesn't trigger workflows on pushes made with the default GITHUB_TOKEN |
Still on @beta | Switch to @v1, drop mode, rename direct_prompt to prompt, and move max_turns and model into claude_args |
What it costs
Each run spends two things: GitHub Actions minutes on the runner, and model usage. Model usage is billed per token on an API key, or counts against your Claude subscription when you authenticate with an OAuth token. Prices change, so check GitHub's Actions billing documentation for minutes and Anthropic's pricing page for token rates rather than relying on a figure copied into a guide.


