Skip to main content
Claude Code integrates with GitHub through a GitHub Actions workflow and the Claude GitHub App. Once installed, you can mention @claude in any pull request or issue comment to trigger Claude, and use /review from the CLI to review PRs locally.

Installing the GitHub App

The /install-github-app command walks you through the full setup interactively.
1

Prerequisites

Install and authenticate the GitHub CLI:
gh auth login
Your GitHub token needs the repo and workflow scopes. If they are missing, add them:
gh auth refresh -h github.com -s repo,workflow
2

Run the install command

From within your repository, run:
/install-github-app
Claude Code checks your GitHub CLI installation and authentication before proceeding.
3

Choose a repository

Select whether to use the current repository (detected automatically from your git remote) or enter a repository name in owner/repo format.
4

Install the Claude GitHub App

Claude Code opens https://github.com/apps/claude in your browser. Install the app on your account or organization and grant it access to the repository.
5

Select workflows

Choose which GitHub Actions workflows to add:
  • Claude PR Assistant (.github/workflows/claude.yml) — Triggered when @claude is mentioned in a PR or issue comment.
  • Claude Code Review (.github/workflows/claude-code-review.yml) — Automatically reviews every pull request when it is opened or updated.
You can install one or both workflows.
6

Configure your API key

Provide your Anthropic API key. Claude Code stores it as a GitHub Actions secret (ANTHROPIC_API_KEY by default). You can also use an OAuth token (CLAUDE_CODE_OAUTH_TOKEN) if you have a Claude.ai account.If an ANTHROPIC_API_KEY secret already exists in the repository, you can reuse it or replace it.
7

Merge the pull request

Claude Code creates a branch and opens a pre-filled pull request in your browser. Merge it to activate the workflow.
The @claude mention trigger and automatic code review will not work until the PR is merged to your default branch.

Tagging @claude in pull request comments

Once the workflow is merged, mention @claude anywhere in a pull request or issue to trigger it:
  • In a PR comment or issue comment
  • In a pull request review comment (inline on a diff)
  • In a pull request review body
  • In the issue body or title
Claude receives the full context of the PR or issue — files, diffs, and previous comments — and executes on the request.
@claude Can you refactor this function to reduce complexity?
@claude Please add test coverage for the edge cases in this diff.
Only users with write access to the repository can trigger the workflow. All Claude runs are stored in the GitHub Actions run history.

The Claude PR Assistant workflow

The installed workflow file (.github/workflows/claude.yml) is triggered by the following events:
on:
  issue_comment:
    types: [created]
  pull_request_review_comment:
    types: [created]
  issues:
    types: [opened, assigned]
  pull_request_review:
    types: [submitted]
The if condition checks that the event body contains @claude before running. Only matching events incur API usage.

Customizing allowed tools

By default, Claude can read and write files, create comments, branches, and commits. To allow additional tools, edit the workflow file:
- name: Run Claude Code
  uses: anthropics/claude-code-action@v1
  with:
    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
    # Allow specific shell commands
    # claude_args: '--allowed-tools Bash(npm install),Bash(npm run build),Bash(npm run test)'

Automated code review with /review

Local review from the CLI

The /review command runs a code review locally using Claude:
/review
Without arguments, Claude runs gh pr list to show open pull requests and lets you pick one. Pass a PR number to review it directly:
/review 42
Claude runs gh pr view and gh pr diff to fetch PR details and the diff, then provides a structured review covering:
  • Overview of what the PR does
  • Code quality and style
  • Specific improvement suggestions
  • Potential issues or risks
  • Performance, test coverage, and security considerations

Automated review on every PR

The Claude Code Review workflow (.github/workflows/claude-code-review.yml) runs automatically whenever a pull request is opened, synchronized, or marked ready for review:
on:
  pull_request:
    types: [opened, synchronize, ready_for_review, reopened]
To restrict automated review to specific contributors (for example, first-time contributors), uncomment and edit the if condition in the workflow file.

PR comment workflows

The /pr-comments command fetches and formats all comments on the current pull request:
/pr-comments
This includes both PR-level comments and inline review comments, with diff context and threading preserved.

Working with branches and pull requests from the CLI

Claude Code uses the GitHub CLI (gh) for all GitHub operations. Common workflows:
# List open pull requests
gh pr list

# View a specific PR
gh pr view 42

# Check out a PR branch locally
gh pr checkout 42

# Show the diff for a PR
gh pr diff 42

# Create a pull request from the current branch
gh pr create --title "My feature" --body "Description"

The commit, push, PR workflow

A typical development workflow with Claude Code and GitHub:
1

Make changes

Ask Claude to implement a feature, fix a bug, or refactor code.
2

Review and stage changes

git diff
git add -p
3

Commit

git commit -m "feat: add user authentication"
4

Push to a branch

git push origin feature/my-feature
5

Open a pull request

gh pr create --title "Add user authentication" --body "Closes #123"
6

Review the PR

Use /review locally or wait for the automated Claude Code Review workflow to post its feedback.

Security

  • The Anthropic API key is stored as an encrypted GitHub Actions secret, not in the repository.
  • The workflow only runs when @claude is mentioned; it does not process every comment.
  • Claude’s tool access is limited by default to reading/writing repository files and interacting with the GitHub API (comments, branches, commits).
  • All Claude runs are logged in the GitHub Actions run history for auditing.