GitHub Actions Integration for Claude Code
Transform your GitHub workflow with AI-powered automation. Claude Code GitHub Actions enables intelligent code reviews, automated feature implementation, and CI/CD debugging directly in your repositories.
🎯 Overview
Claude Code GitHub Actions (currently in beta) acts as an AI assistant for your GitHub repositories, capable of:
- Automated Code Reviews: Analyze PRs for bugs, style, and best practices
- Feature Implementation: Build features from issue descriptions
- Bug Fixing: Locate and fix bugs automatically
- CI/CD Debugging: Analyze test failures and workflow issues
- Interactive Assistance: Answer questions about code and architecture
🚀 Quick Start
Option 1: Terminal Setup (Recommended)
# Install GitHub App via Claude Code
claude /install-github-app
# Follow the prompts to:
# 1. Create GitHub App
# 2. Install on repositories
# 3. Configure secretsOption 2: Manual Setup
1. Create Workflow File
# .github/workflows/claude-assistant.yml
name: Claude Code Assistant
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, labeled]
pull_request_review:
types: [submitted]
permissions:
contents: write
pull-requests: write
issues: write
actions: read # For CI/CD debugging
jobs:
claude-response:
runs-on: ubuntu-latest
steps:
- uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}2. Configure Secrets
# Add to repository secrets:
# Settings → Secrets → Actions → New repository secret
# Name: ANTHROPIC_API_KEY
# Value: Your Anthropic API key⚙️ Configuration Options
Basic Configuration
- uses: anthropics/claude-code-action@beta
with:
# Required
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
# Optional
trigger_phrase: "@claude" # Default: "@claude"
max_conversation_turns: 25 # Default: 25
timeout_minutes: 30 # Default: 30
model: "claude-4-opus" # Default: latest modelAdvanced Configuration
- uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
# Custom environment variables for Claude
claude_env: |
ENVIRONMENT: production
API_BASE_URL: ${{ vars.API_BASE_URL }}
DEBUG_MODE: false
# Additional permissions for CI/CD access
additional_permissions: |
actions: read
checks: write
# Direct prompt for automated workflows
direct_prompt: |
Review this PR for:
1. Security vulnerabilities
2. Performance issues
3. Code style violations📋 Common Use Cases
1. Automated PR Reviews
name: Auto Review External PRs
on:
pull_request:
types: [opened, synchronize]
jobs:
auto-review:
# Only for external contributors
if: github.event.pull_request.head.repo.fork == true
runs-on: ubuntu-latest
steps:
- uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
direct_prompt: |
Please review this PR for:
- Security vulnerabilities
- Breaking changes
- Test coverage
- Documentation updates2. Feature Implementation from Issues
name: Implement Features
on:
issues:
types: [labeled]
jobs:
implement-feature:
if: contains(github.event.label.name, 'implement-with-claude')
runs-on: ubuntu-latest
steps:
- uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
direct_prompt: |
Implement the feature described in this issue.
Create a new branch and submit a PR with:
- Implementation
- Tests
- Documentation3. CI/CD Failure Analysis
name: Debug Test Failures
on:
workflow_run:
workflows: ["Tests"]
types: [completed]
jobs:
analyze-failure:
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
runs-on: ubuntu-latest
permissions:
actions: read
issues: write
steps:
- uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
additional_permissions: |
actions: read
direct_prompt: |
Analyze the test failure and:
1. Identify the root cause
2. Suggest a fix
3. Create an issue with findings4. Documentation Generation
name: Generate Documentation
on:
push:
paths:
- 'src/**/*.ts'
- 'src/**/*.js'
jobs:
update-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
direct_prompt: |
Update the documentation for changed files:
- Generate/update API docs
- Update README if needed
- Add usage examples📝 CLAUDE.md Configuration
The
CLAUDE.mdfile is a powerful feature that allows you to customize and guide the behavior of the Claude Code GitHub Action. By defining project-specific standards and guidelines in this file, you provide a “meta-prompt” that Claude uses for every interaction. This ensures that its contributions are consistent with your project’s architecture, coding style, and conventions.You can see the project’s
CLAUDE.mdfile here: CLAUDE.md
Create a CLAUDE.md file in your repository root to define project-specific guidelines:
# CLAUDE.md - Project Guidelines for Claude Code
## Code Style
- Use TypeScript for all new code
- Follow ESLint configuration
- Prefer functional programming patterns
- Use async/await over promises
## Testing Requirements
- Minimum 80% code coverage
- Write unit tests for all functions
- Include integration tests for APIs
- Use Jest for testing framework
## Documentation Standards
- JSDoc comments for all public functions
- Update README for new features
- Include usage examples
- Document breaking changes
## Security Practices
- Never log sensitive data
- Validate all user inputs
- Use parameterized queries
- Follow OWASP guidelines
## Git Workflow
- Branch naming: feature/*, bugfix/*, hotfix/*
- Commit format: "type: description"
- Squash commits before merging
- Require PR reviews
## Performance Guidelines
- Optimize for readability first
- Profile before optimizing
- Avoid premature optimization
- Document performance decisions🔧 Advanced Patterns
Pattern 1: Multi-Stage Review
name: Progressive Code Review
on:
pull_request:
types: [opened, synchronize]
jobs:
initial-review:
runs-on: ubuntu-latest
steps:
- uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
direct_prompt: |
Quick review for obvious issues:
- Syntax errors
- Security vulnerabilities
- Missing tests
detailed-review:
needs: initial-review
if: success()
runs-on: ubuntu-latest
steps:
- uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
direct_prompt: |
Detailed review:
- Architecture decisions
- Performance implications
- Code maintainabilityPattern 2: Conditional Automation
name: Smart Automation
on:
issues:
types: [labeled]
jobs:
route-task:
runs-on: ubuntu-latest
steps:
- name: Bug Fix
if: contains(github.event.label.name, 'bug')
uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
direct_prompt: |
Investigate and fix this bug:
1. Reproduce the issue
2. Identify root cause
3. Implement fix with tests
- name: Feature Request
if: contains(github.event.label.name, 'enhancement')
uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
direct_prompt: |
Analyze feasibility and create design doc
- name: Documentation
if: contains(github.event.label.name, 'documentation')
uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
direct_prompt: |
Update or create documentationPattern 3: Cross-Repository Operations
name: Update Dependencies
on:
repository_dispatch:
types: [update-deps]
jobs:
update-across-repos:
strategy:
matrix:
repo: [repo1, repo2, repo3]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: myorg/${{ matrix.repo }}
token: ${{ secrets.CROSS_REPO_TOKEN }}
- uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
direct_prompt: |
Update dependencies and ensure compatibility:
1. Update package versions
2. Fix any breaking changes
3. Run tests
4. Create PR if changes needed🔐 Security Best Practices
1. Secrets Management
# ❌ Never do this
anthropic_api_key: "sk-ant-..."
# ✅ Always use secrets
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}2. Permissions Scoping
# Minimal permissions principle
permissions:
contents: read # Only if needed
pull-requests: write # For PR comments
issues: write # For issue comments
actions: read # Only for CI debugging3. Environment Isolation
# Separate keys for different environments
- uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{
github.ref == 'refs/heads/main'
&& secrets.ANTHROPIC_API_KEY_PROD
|| secrets.ANTHROPIC_API_KEY_DEV
}}📊 Monitoring and Optimization
Track Usage
- name: Log Claude Usage
if: always()
run: |
echo "Workflow: ${{ github.workflow }}"
echo "Trigger: ${{ github.event_name }}"
echo "Time: $(date)"
# Send to monitoring servicePerformance Optimization
# Use Depot for 2x faster runs at half the cost
jobs:
claude-fast:
runs-on: depot-ubuntu-latest # Instead of ubuntu-latest
steps:
- uses: anthropics/claude-code-action@beta🚨 Troubleshooting
Common Issues
-
Claude not responding
- Check trigger phrase matches configuration
- Verify API key is valid
- Ensure proper permissions are set
-
Workflow timeouts
- Increase
timeout_minutessetting - Break complex tasks into smaller steps
- Use more specific prompts
- Increase
-
Permission errors
- Review repository settings
- Check workflow permissions block
- Verify GitHub token scopes
💡 Pro Tips
- Detailed Prompts: Specific prompts reduce response time by 50%
- Start Small: Test with simple tasks first (e.g., “@claude add a README”)
- Use CLAUDE.md: Define project standards for consistent results
- Batch Operations: Combine related tasks in one prompt
- Monitor Costs: Track API usage to optimize spending
🔗 Resources
- Back to Integrations Hub
- Automation Patterns
- CLAUDE.md Configuration Guide
- Official Documentation
- GitHub Marketplace
🗺️ Navigation
← Integrations | Examples → | Advanced Patterns →
Verifications
Last verified: 2025-07-22
Sources
-
GitHub Actions Documentation: Verified from Anthropic’s official docs - Claude Code GitHub Actions is currently in beta
-
GitHub Repository: Checked anthropics/claude-code-action - Confirmed the action exists and uses
@betatag -
Feature Confirmation: Verified from Claude Code announcement - The SDK example “Claude Code on GitHub” is now in beta, installable via
/install-github-appcommand -
Enterprise Support: Confirmed support for AWS Bedrock and Google Vertex AI for organizations needing their own cloud providers
Why Verified
- Beta Status: Confirmed that Claude Code GitHub Actions is currently in beta phase as stated
- Installation Method: Verified the recommended setup via
claude /install-github-appcommand - Action Reference: Confirmed
anthropics/claude-code-action@betais the correct action reference - Feature Set: All listed features (PR creation, automated implementation, code reviews, CI/CD debugging) align with current capabilities
- Configuration Options: The YAML configurations and advanced features (tool control, network security, MCP servers) are accurate
- Recent Updates: The 2025 general availability announcement and expanded developer collaboration features are confirmed