Claude Code Action Integration
Prerequisites
- •GitHub repository with Actions enabled
- •Anthropic API key (ANTHROPIC_API_KEY secret)
- •Repository write permissions configured
- •Understanding of GitHub Actions workflow syntax
Instructions
- •Choose the appropriate workflow template from
templates/workflows/based on your use case (PR review, @claude mention, or issue triage) - •Copy the selected YAML file to your repository's
.github/workflows/directory - •Add the
ANTHROPIC_API_KEYsecret in your repository settings under Settings > Secrets and variables > Actions - •Configure repository permissions by enabling "Read and write permissions" and "Allow GitHub Actions to create and approve pull requests" in Settings > Actions > General
- •Customize the workflow file if needed (model selection, allowed tools, custom prompts)
- •Test the workflow on a draft PR or test issue to verify it triggers correctly
- •Monitor API usage and costs after deployment
Trigger Conditions
- •User asks to "set up automated code review"
- •User wants "Claude to review PRs automatically"
- •User asks about "GitHub Actions with Claude"
- •User needs "@claude mention integration"
- •User wants "automated issue triage"
Overview
The claude-code-action is Anthropic's official GitHub Action for running Claude Code in CI/CD workflows. This skill provides ready-to-use workflow templates for common integration patterns.
Available Templates
| Template | Purpose | Location |
|---|---|---|
| claude-pr-review.yml | Automatic PR code review | templates/workflows/ |
| claude-mention.yml | @claude mention responses | templates/workflows/ |
| claude-issue-triage.yml | Automated issue triage | templates/workflows/ |
Quick Start
Step 1: Choose a Template
Select the workflow template that matches your use case from templates/workflows/.
Step 2: Copy to Repository
Copy the YAML file to your repository's .github/workflows/ directory:
# Example: Set up PR review cp claude-pr-review.yml /path/to/repo/.github/workflows/
Step 3: Configure Secrets
Add required secrets in your repository settings:
- •Go to Settings > Secrets and variables > Actions
- •Add
ANTHROPIC_API_KEYwith your Anthropic API key
Step 4: Configure Permissions
- •Go to Settings > Actions > General
- •Under "Workflow permissions", select "Read and write permissions"
- •Check "Allow GitHub Actions to create and approve pull requests"
Template Details
PR Review Workflow
File: templates/workflows/claude-pr-review.yml
Triggers:
- •Pull request opened
- •New commits pushed to PR
- •PR marked ready for review
- •PR reopened
Features:
- •Comprehensive code review (quality, bugs, security, performance)
- •Inline comments on specific code issues
- •Summary comment with overall assessment
- •Concurrency control (one review per PR at a time)
- •Draft PR handling (skips drafts)
Review Categories:
- •Code Quality - patterns, naming, organization, DRY
- •Potential Bugs - null handling, edge cases, race conditions
- •Security - injection, XSS, auth issues
- •Performance - complexity, queries, caching
- •Testing - coverage, edge cases, clarity
Mention Response Workflow
File: templates/workflows/claude-mention.yml
Triggers:
- •@claude mentioned in issue comment
- •@claude mentioned in PR comment
Features:
- •Responds to direct questions
- •Provides code explanations
- •Suggests fixes for reported issues
- •Answers architecture questions
Issue Triage Workflow
File: templates/workflows/claude-issue-triage.yml
Triggers:
- •New issue opened
Features:
- •Automatic label assignment
- •Priority assessment
- •Initial response to reporter
- •Related issue linking
Customization
Changing the Model
Edit the claude_args section in any workflow:
claude_args: | --model "claude-sonnet-4-20250514" # or claude-opus-4-5-20251101
Restricting Tools
Modify the --allowedTools argument to limit what Claude can do:
--allowedTools "Read,Glob,Grep" # Read-only, no bash
Custom Prompts
Edit the prompt section to customize Claude's behavior for your project's specific needs.
Examples
Example 1: Basic PR Review Setup
# .github/workflows/claude-review.yml
name: Claude PR Review
on:
pull_request:
types: [opened, synchronize, ready_for_review]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: anthropics/claude-code-action@v1
with:
prompt: "Review this PR for code quality and potential bugs"
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
Example 2: @claude Mention Handler
# .github/workflows/claude-mention.yml
name: Claude Mention
on:
issue_comment:
types: [created]
jobs:
respond:
if: contains(github.event.comment.body, '@claude')
runs-on: ubuntu-latest
steps:
- uses: anthropics/claude-code-action@v1
with:
prompt: "Respond to this comment helpfully"
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
Error Handling
Workflow Not Triggering
- •Check workflow file is in
.github/workflows/ - •Verify YAML syntax is valid
- •Ensure trigger conditions match your action
Authentication Errors
- •Verify
ANTHROPIC_API_KEYsecret is set - •Check API key has not expired
- •Ensure key has required permissions
Permission Denied Errors
- •Enable "Read and write permissions" in repository settings
- •Add required permissions block to workflow
Timeout Issues
- •Increase
timeout-minutesin workflow - •Consider using a faster model for large repos
Resources
- •claude-code-action GitHub - Official action repository
- •GitHub Actions Documentation - Actions reference
- •
templates/workflows/claude-pr-review.yml- PR review template - •
templates/workflows/claude-mention.yml- Mention handler template - •
templates/workflows/claude-issue-triage.yml- Issue triage template
Best Practices
- •Start with PR Review - Most common and valuable integration
- •Use Sonnet for Speed - Faster reviews, lower cost
- •Limit Tools - Only allow necessary tools for security
- •Test on Draft PRs - Test workflow before enabling widely
- •Monitor Costs - Watch API usage with track_progress enabled
Output
| Field | Type | Description |
|---|---|---|
| Workflow File | YAML | GitHub Actions workflow configured in .github/workflows/ |
| API Key Secret | Secret | ANTHROPIC_API_KEY configured in repository settings |
| Permissions | Config | Repository permissions set to "Read and write" |
| Status | Boolean | Workflow enabled and ready to trigger |
Checklist
Copy this checklist and track your progress:
- • Select appropriate workflow template (PR review, @claude mention, or issue triage)
- • Copy template YAML to
.github/workflows/directory - • Add
ANTHROPIC_API_KEYsecret in repository settings - • Enable "Read and write permissions" for GitHub Actions
- • Enable "Allow GitHub Actions to create and approve pull requests"
- • Customize
claude_argsmodel if needed (default: sonnet) - • Customize
--allowedToolsfor security requirements - • Test workflow on a draft PR or test issue
- • Verify workflow triggers correctly
- • Monitor API usage and costs
- • Document custom prompts for team reference