📖

Claude Code Action v1リリースされたので、ベータからの移行ガイドと自動化サンプルをまとめた

に公開

Anthropic社のClaude Code Actionが v1.0 をリリースしました。これまでのベータ版からアップデートされ、より多くのGitHubイベントに対応し、より手軽に導入できるようになりました。

https://x.com/claudeai/status/1960387088836169931

新しくなった Claude Code Action v1 の主な特徴

(主に以下のまとめになります)
https://docs.anthropic.com/en/docs/claude-code/github-actions#upgrading-from-beta

より多くのGitHubイベントでのトリガー対応

ベータ版では @claude へのメンションに限定されていましたが、v1では以下のような様々なイベントに対応するようになりました。

  • 新規Issue作成
  • CI/CDの失敗
  • PR作成・更新
  • カスタム条件での実行

カスタマイズ可能なテンプレート

コードレビュー、Issue管理、CI修正などの一般的なワークフロー用に、すぐ使えるテンプレートが用意されています。

公式サンプル例: examples/ から以下のワークフローテンプレートが利用できます

ベータ版からv1への移行(破壊的変更が含まれています)

既存のベータユーザーは、以下の対応する場合があります

必須の変更点

# ベータ版(旧)
- uses: anthropics/claude-code-action@beta
  with:
    mode: "tag"
    direct_prompt: "Review this PR for security issues"
    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
    custom_instructions: "Follow our coding standards"
    max_turns: "10"
    model: "claude-3-5-sonnet-20241022"

# v1.0(新)
- uses: anthropics/claude-code-action@v1
  with:
    prompt: "Review this PR for security issues"
    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
    claude_args: |
      --system-prompt "Follow our coding standards"
      --max-turns 10
      --model claude-sonnet-4-20250514

変更点

旧(ベータ版) 新(v1.0) 詳細
mode (削除) 自動検知されるように
direct_prompt prompt 名前変更
custom_instructions claude_args: --system-prompt CLI引数として指定
max_turns claude_args: --max-turns CLI引数として指定
model claude_args: --model CLI引数として指定

実践的な活用例

1. 基本的なワークフロー(@claudeメンションに対応)

name: Claude Code
on:
  issue_comment:
    types: [created]
  pull_request_review_comment:
    types: [created]
jobs:
  claude:
    runs-on: ubuntu-latest
    steps:
      - uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          # @claude mentions in comments に自動応答

使用例:

@claude このPRのセキュリティ面をレビューしてください
@claude バグの原因を特定して修正方法を提案して
@claude パフォーマンス改善点を分析してください

2. スラッシュコマンドを使ったコードレビュー

name: Automated Code Review
on:
  pull_request:
    types: [opened, synchronize]
jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          prompt: "/review"
          claude_args: "--max-turns 5"

カスタムスラッシュコマンドについても便利になっており、プロジェクトに名前空間としてファイルごとに配置できるようになっていました。
https://docs.anthropic.com/ja/docs/claude-code/slash-commands#カスタムスラッシュコマンド

3. CI失敗時の自動修正

name: CI Failure Auto Fix
on:
  check_run:
    types: [completed]
jobs:
  auto-fix:
    runs-on: ubuntu-latest
    if: github.event.check_run.conclusion == 'failure'
    steps:
      - uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          prompt: "Analyze the CI failure and suggest fixes"
          claude_args: "--max-turns 10"

公式サンプルでは「新しい修正用ブランチを切ってPRを作成する」方式になっていますがチームによってはCIが落ちるごとに修正PRが乱立してしまうので、プロンプトとして「既存のブランチに直接コミット&プッシュする」指示を組み込むことで、既存PRの中に修正を積み上げるワークフローにカスタマイズして使っています。

 prompt: |
            CI FAILURE DETECTED - IMMEDIATE ACTION REQUIRED!

            You are an automated CI fixer. Your job is to:
            1. Read the error logs
            2. Fix lint/type/syntax errors in the code
            3. Commit and push the changes to the existing PR branch
            4. Add a comment to the PR with the result

            ## Failure Details
            - PR: #${{ github.event.check_run.pull_requests[0].number }}
            - Branch: ${{ github.event.workflow_run.head_branch }}

            ## Mandatory Git Steps
            git status
            git add -A
            git commit -m "🔧 Auto-fix CI failures"
            git push origin ${{ github.event.workflow_run.head_branch }}

            ## Notify the PR
            gh pr comment ${{ github.event.check_run.pull_requests[0].number }} \
              --body "✅ Auto-fixed CI failures. Changes pushed to branch."
          claude_args: "--max-turns 10 --allowedTools 'Edit,MultiEdit,Write,Read,Bash(git:*),Bash(gh:*)'"

4. 定期レポート生成

name: Daily Progress Report
on:
  schedule:
    - cron: "0 9 * * *"
jobs:
  report:
    runs-on: ubuntu-latest
    steps:
      - uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          prompt: "Generate a summary of yesterday's commits and open issues"
          claude_args: "--model claude-opus-4-1-20250805"

5. Issue トリアージの自動化

name: Issue Triage
on:
  issues:
    types: [opened]
jobs:
  triage:
    runs-on: ubuntu-latest
    steps:
      - uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          prompt: |
            Analyze this issue and:
            1. Add appropriate labels
            2. Assign to the right team member
            3. Check for duplicates
          claude_args: "--max-turns 3"

mcp__github_inline_comment__create_inline_comment の活用

公式のsampleでも使用していた、mcp__github_inline_comment__create_inline_comment を使うと、PRの特定の行に対してピンポイントなコメントをしてくれます

# Claude が PR の特定行にインラインコメントを作成
- name: Detailed Code Review with Inline Comments
  uses: anthropics/claude-code-action@v1
  with:
    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
    prompt: |
      Review this PR and create inline comments for:
      - Potential bugs or logical errors
      - Performance concerns
      - Best practice violations
      Use mcp__github_inline_comment__create_inline_comment to add specific feedback
    claude_args: "--max-turns 8"

この機能により、ファイル全体へのコメントではなく、問題のある特定の行に対して詳細なフィードバックを提供しれくれます。
個人的にPR内にコメントが来ても、どこのこと?となることがしばしばあるので特定の箇所にコメントをくれるこちらの方が好きです。

まとめ

Claude Code Action v1リリースにより、GitHub上での開発ワークフローがさらに強力になりました。ベータ版からの移行には破壊的変更が含まれますが、新機能と改善されたAPIにより、より柔軟で効率的な自動化が可能となりました。

参考リンク

GMOペパボ株式会社

Discussion