Installation

Learn how to install and set up Claude Code Action in your repository.

Prerequisites

Before installing Claude Code Action, ensure you have:

  • A GitHub repository
  • Repository admin permissions
  • Access to Claude Code CLI
  • An Anthropic API key or Claude Code OAuth token

Quick Installation (Recommended)

The fastest way to install Claude Code Action is using the Claude Code CLI:

1. Open Claude Code

claude

2. Run Install Command

/install-github-app

This command will guide you through:

  • Installing the Claude GitHub App
  • Setting up required secrets
  • Configuring your workflow file

Manual Installation

If you prefer to set up manually or need more control:

1. Install the Claude GitHub App

Visit https://github.com/apps/claude and install the app on your repository.

2. Set Up Authentication

Add one of the following secrets to your repository:

Option A: Anthropic API Key (Recommended)

  1. Go to your repository Settings
  2. Navigate to Secrets and variablesActions
  3. Click New repository secret
  4. Name: ANTHROPIC_API_KEY
  5. Value: Your Anthropic API key

Option B: Claude Code OAuth Token

  1. Go to your repository Settings
  2. Navigate to Secrets and variablesActions
  3. Click New repository secret
  4. Name: CLAUDE_CODE_OAUTH_TOKEN
  5. Value: Your OAuth token

3. Create Workflow File

Create .github/workflows/claude.yml in your repository:

name: Claude Code Action

on:
  issues:
    types: [opened, labeled]
  pull_request:
    types: [opened, labeled, synchronize]
  issue_comment:
    types: [created]

permissions:
  contents: write
  issues: write
  pull-requests: write

jobs:
  claude:
    runs-on: ubuntu-latest
    steps:
      - uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          # Or use OAuth token:
          # claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}

4. Commit and Push

git add .github/workflows/claude.yml
git commit -m "Add Claude Code Action workflow"
git push

Alternative Authentication Methods

Amazon Bedrock

- uses: anthropics/claude-code-action@v1
  with:
    aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
    aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
    aws_region: us-east-1

Google Vertex AI

- uses: anthropics/claude-code-action@v1
  with:
    gcp_project_id: ${{ secrets.GCP_PROJECT_ID }}
    gcp_service_account_key: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
    gcp_region: us-central1

Custom GitHub App Setup (Advanced)

For organizations requiring a custom GitHub App:

1. Create GitHub App

  1. Go to GitHub Settings → Developer settings → GitHub Apps
  2. Click New GitHub App
  3. Configure minimum permissions:
    • Contents: Read & Write
    • Issues: Read & Write
    • Pull requests: Read & Write

2. Generate Private Key

  1. In your GitHub App settings
  2. Scroll to Private keys
  3. Click Generate a private key
  4. Download and secure the .pem file

3. Install App on Repository

  1. Go to your GitHub App settings
  2. Click Install App
  3. Select target repositories

4. Add Secrets

Add these secrets to your repository:

  • APP_ID: Your GitHub App ID
  • APP_PRIVATE_KEY: Contents of the .pem file

5. Update Workflow

- uses: anthropics/claude-code-action@v1
  with:
    github_app_id: ${{ secrets.APP_ID }}
    github_app_private_key: ${{ secrets.APP_PRIVATE_KEY }}
    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

Verification

After installation, test the action by:

  1. Creating a new issue or pull request
  2. Adding the label claude (if using label-based triggers)
  3. Checking the Actions tab for workflow runs

Security Best Practices

  • Never commit API keys directly to your repository
  • Use GitHub Actions secrets for all sensitive values
  • Regularly rotate API keys and tokens
  • Avoid logging sensitive variables in workflow outputs
  • Review GitHub App permissions regularly

Troubleshooting

Action Not Triggering

  • Verify the workflow file is in .github/workflows/
  • Check that required secrets are set
  • Ensure the GitHub App is installed on the repository
  • Review workflow trigger conditions

Authentication Errors

  • Confirm API key is valid and active
  • Check secret names match workflow configuration
  • Verify GitHub App has necessary permissions

Permission Errors

  • Ensure workflow has contents: write permission
  • Verify GitHub App has required repository access
  • Check organization-level restrictions

Next Steps