How to Set Up the Claude Code GitHub Action
Install the Claude GitHub App, add one secret, and drop in a workflow so @claude answers in your issues and PRs. Copy-paste.
Step 6 of 6 · Try the other coding agents
On this page5 sections
The Claude Code GitHub Action runs Claude Code inside your repository’s workflows. Mention
@claude in an issue or PR comment and it analyses code, makes changes, and pushes commits.
You need admin access to the repo.
1. The quick way
Install the GitHub CLI and run gh auth login first. Then, from
inside the repo:
claude
/install-github-app
It installs the Claude GitHub App, saves your authentication secret, pushes a branch with the
workflow files, and opens a pull request for you. Merge that PR and @claude works.
2. The manual way
Three steps, if you’d rather not run the command:
- Install the Claude GitHub App on the repository (github.com/apps/claude). The action needs its Contents, Issues, and Pull requests permissions.
- Add one repository secret:
ANTHROPIC_API_KEY(a Claude API key) orCLAUDE_CODE_OAUTH_TOKEN(a subscription token — generate it locally withclaude setup-token). - Commit a workflow file.
3. Minimal workflow
.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
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 non-boilerplate lines: id-token: write is required for the action’s default GitHub App
authentication, actions: read lets Claude read CI results, and the if: keeps runners from
starting on comments that don’t mention @claude. If you stored a subscription token instead,
replace the anthropic_api_key line with
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}.
4. Use it
Comment on any issue or PR:
@claude implement this feature based on the issue description
@claude fix the TypeError in the user dashboard component
Claude replies in a comment on the same thread and updates it as it works. Only users with
write access to the repo can trigger a run, and bot actors are rejected unless you list them in
allowed_bots.
5. Keep runs cheap
Pass CLI arguments through claude_args:
claude_args: "--max-turns 5 --model claude-sonnet-5"
Add a workflow-level timeout and GitHub’s concurrency controls so a runaway job can’t burn an afternoon of Actions minutes.
Next: run Claude Code headless in a script or review a PR with Claude Code.