Why This Matters#

CI/CD (Continuous Integration / Continuous Delivery) is the practice of automatically checking and publishing code. Imagine a factory assembly line: every time you make changes, checks run automatically.

GitHub Actions is GitHub’s built-in automation system. With Claude Code GitHub Actions, you can:

  • 🤖 Automatically review pull requests (PRs)
  • 🏷️ Triage issues by category
  • 💻 Create PRs from task descriptions
  • 📝 Generate code from a @claude comment

Just write @claude in a comment on an issue or PR — and Claude starts working!

How It Works#

You write @claude in a PR → GitHub Actions runs Claude Code →
Claude analyzes the code → Claude leaves a comment or creates changes

Step-by-Step Setup#

Step 1: Installation via Claude Code (Quick Way)#

Open Claude Code in the terminal and run:

/install-github-app

This command will guide you through the entire setup process.

Step 2: Manual Setup#

If automatic installation didn’t work:

2.1. Install the GitHub App#

Go to github.com/apps/claude and install the app for your repository.

The app needs these permissions:

  • Contents — read and write (to modify files)
  • Issues — read and write (to respond to issues)
  • Pull requests — read and write (to create PRs)

2.2. Add the API Key#

Go to repository settings → Secrets and variablesActionsNew repository secret.

Create a secret named ANTHROPIC_API_KEY and paste your Anthropic API key.

2.3. Create the Workflow File#

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

name: Claude Code

on:
  # Triggers on comments in issues and PRs
  issue_comment:
    types: [created]
  # Triggers on PR review submission
  pull_request_review:
    types: [submitted]
  # Triggers when issues are opened or edited
  issues:
    types: [opened, edited]

jobs:
  claude:
    # Run only if @claude is mentioned
    if: |
      contains(github.event.comment.body, '@claude') ||
      contains(github.event.review.body, '@claude') ||
      contains(github.event.issue.body, '@claude')
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write
      issues: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 1

      - name: Run Claude Code
        uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

Step 3: Verify It Works#

  1. Create a new issue in the repository
  2. Write: @claude Tell me what this project does
  3. Wait — Claude will analyze the code and reply with a comment

Usage Examples#

Automatic PR Review#

Write in a PR comment:

@claude Review this PR for errors and security issues

Creating Code from a Description#

Create an issue with:

@claude Create an email validation function
and add tests. Create a PR with the changes.

Claude will create the code, tests, and open a PR.

Issue Triage#

@claude Analyze this bug report and suggest a fix plan.
Determine the priority and assign labels.

Advanced Settings#

Limiting Tools#

You can restrict which tools Claude can use:

- name: Run Claude Code
  uses: anthropics/claude-code-action@v1
  with:
    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
    claude_args: "--allowedTools Read,Edit,Bash"

Adding Instructions#

- name: Run Claude Code
  uses: anthropics/claude-code-action@v1
  with:
    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
    claude_args: "--append-system-prompt 'Always write comments in English'"

Limiting the Number of Steps#

- name: Run Claude Code
  uses: anthropics/claude-code-action@v1
  with:
    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
    claude_args: "--max-turns 10"

The CLAUDE.md File#

Claude Code automatically reads the CLAUDE.md file in the repository root. Use it to give Claude project instructions:

# CLAUDE.md

## Project Rules
- Code is written in TypeScript
- Tests are required for every function
- Commits in Conventional Commits format
- Comments in English

## Project Structure
- src/ — source code
- tests/ — tests
- docs/ — documentation

Security#

  • ✅ Your code stays on GitHub’s servers — it’s not sent anywhere else
  • ✅ The API key is stored in GitHub’s encrypted secrets
  • ✅ Claude works with the same permissions you specified in permissions
  • ⚠️ Be careful with contents: write — this allows Claude to modify files

Lesson Summary#

  • GitHub Actions lets you automate Claude Code’s work in your repository
  • Setup takes 3 steps: GitHub App, API key, workflow file
  • Claude reacts to @claude mentions in issues and PRs
  • The CLAUDE.md file sets the working rules for Claude in the project
  • You can limit tools, number of steps, and add instructions
  • Code stays on GitHub’s servers — security is maintained