はじめに
Claude Code GitHub Actions が Max プランで使えるようになったらしい!
ということで、検証用の個人プロジェクトで実際に使ってみました。
Claude Code GitHub Actionsとは
Claude Code GitHub Actionsは、GitHub上のissueやプルリクエストに対してClaude Codeが自動的に対応してくれる機能です。ローカル環境での作業なしに、コードの修正や機能追加を行うことができます。
詳細は公式ドキュメントをご確認ください。
セットアップ
前提条件
今回はv1.0.51のClaude Codeを使用します。以下のコマンドでバージョンを確認してください。1.0.44以降でMaxプランでの対応がされているようです。
> claude -v
1.0.51 (Claude Code)
事前に、GitHub CLIのインストールと、GitHubアカウントの認証を済ませておくと楽です。
# MacOS
> brew install gh
# Windows
> winget install --id GitHub.cli
# ログイン
> gh auth login
GitHub Actionsの設定
公式ドキュメントの例に沿ってClaude Code内で以下実行します
> /install-github-app
リポジトリの選択や、サブスクリプションの確認が表示されるので、指示に従って進めます。
ワークフローの種類を選択します
今回は@Claude Code
を選択
サブスクで接続したいのでCreate a long-lived...
を選択
戻るとセットアップが進む様子が確認できます
そして終了後にはブラウザでPR作成画面が開きます
変更差分を見ると、ワークフローが自動生成されているのがわかります。
今回は追加の設定などはせずそのまま使用するため、マージします。
また、GitHub ActionsのSecretsにトークンが設定されていることがわかります。
生成されたワークフローはこちら
.github/workflows/claude.yml
name: Claude Code
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]
jobs:
claude:
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
actions: read # Required for Claude to read CI results on PRs
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Run Claude Code
id: claude
uses: anthropics/claude-code-action@beta
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
# This is an optional setting that allows Claude to read CI results on PRs
additional_permissions: |
actions: read
# Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4)
# model: "claude-opus-4-20250514"
# Optional: Customize the trigger phrase (default: @claude)
# trigger_phrase: "/claude"
# Optional: Trigger when specific user is assigned to an issue
# assignee_trigger: "claude-bot"
# Optional: Allow Claude to run specific commands
# allowed_tools: "Bash(npm install),Bash(npm run build),Bash(npm run test:*),Bash(npm run lint:*)"
# Optional: Add custom instructions for Claude to customize its behavior for your project
# custom_instructions: |
# Follow our coding standards
# Ensure all new code has tests
# Use TypeScript for new files
# Optional: Custom environment variables for Claude
# claude_env: |
# NODE_ENV: test
.github/workflows/claude-code-review.yml
name: Claude Code Review
on:
pull_request:
types: [opened, synchronize]
# Optional: Only run on specific file changes
# paths:
# - "src/**/*.ts"
# - "src/**/*.tsx"
# - "src/**/*.js"
# - "src/**/*.jsx"
jobs:
claude-review:
# Optional: Filter by PR author
# if: |
# github.event.pull_request.user.login == 'external-contributor' ||
# github.event.pull_request.user.login == 'new-developer' ||
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@beta
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
# Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4)
# model: "claude-opus-4-20250514"
# Direct prompt for automated review (no @claude mention needed)
direct_prompt: |
Please review this pull request and provide feedback on:
- Code quality and best practices
- Potential bugs or issues
- Performance considerations
- Security concerns
- Test coverage
Be constructive and helpful in your feedback.
# Optional: Use sticky comments to make Claude reuse the same comment on subsequent pushes to the same PR
# use_sticky_comment: true
# Optional: Customize review based on file types
# direct_prompt: |
# Review this PR focusing on:
# - For TypeScript files: Type safety and proper interface usage
# - For API endpoints: Security, input validation, and error handling
# - For React components: Performance, accessibility, and best practices
# - For tests: Coverage, edge cases, and test quality
# Optional: Different prompts for different authors
# direct_prompt: |
# ${{ github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' &&
# 'Welcome! Please review this PR from a first-time contributor. Be encouraging and provide detailed explanations for any suggestions.' ||
# 'Please provide a thorough code review focusing on our coding standards and best practices.' }}
# Optional: Add specific tools for running tests or linting
# allowed_tools: "Bash(npm run test),Bash(npm run lint),Bash(npm run typecheck)"
# Optional: Skip review for certain conditions
# if: |
# !contains(github.event.pull_request.title, '[skip-review]') &&
# !contains(github.event.pull_request.title, '[WIP]')
対象のプロジェクト
今回使用したのは、Next.jsベースの簡単なTODOアプリです。
こちらもClaude Codeに作ってもらいました。
CLAUDE.mdは用意していません。
タスクをお願いする
issueの作成
「アーカイブエリアに削除済みタスクを保管する」という内容でissueを作成しました。
中身はこんな感じにしておきます。
- タスク一覧の下にアーカイブエリアを追加
- 削除済みタスクは消滅せずアーカイブエリアに移動する
Claude Code呼び出し
issueを作成し、@claude
で呼び出してみます。
反応してくれました!
ただ、「実装して」レベルの抽象的な指示だと、実装計画提案が返ってきました。
実際にコミットしてPRを作成してもらいたかったので、「PRを作成して」という指示を追加します。
ワークフローが動き出しました。
TODOを立てて、一つ一つ対応するたびにチェックボックスが更新されていきます。
中に入ると詳細のログが確認できました。
実装完了
アーカイブエリアが追加されていることが確認できました。
復元や完全削除など、指示にない基本機能も実装されています。
動作も問題ありません。
日本語で対応内容を聞いてみます。
明示的に日本語を指定すると、日本語で答えてくれました。
内容も整理されていてわかりやすい。
PR作成
PR作成のリンクがissueに追加されているため、簡単にPRが作成できます。
デフォルトではPRは自動作成されないようです。
PRを作成すると、レビューが自動で実行されました。
おまけ
活用シーンと今後の展望
所感
ローカルで呼び出さずとも、GitHub上で完結してしまうので、なかなか便利に使えそうです。
今回大きいタスクは試していないため推測を含みますが、以下のような軽微な修正に適していると感じました。
- 軽微なバグ修正
- 小さな機能追加
- UIの微調整
- リファクタリング
今後試したいこと
今回は初回の体験レポートでしたが、今後は以下のような点を試してみたいです。
-
得意・不得意タスクの見極め
- より複雑な機能実装
- 複数ファイルにまたがる変更
-
CLAUDE.mdの効果検証
- プロジェクト固有のルールを記述した場合の精度向上
- 開発方針の反映度合い
-
他ツールとの連携
- MCPとの組み合わせ
まとめ
MaxプランでClaude Code GitHub Actionsを試してみました。
非常に便利で、簡単なタスクならばローカル環境を立ち上げることなく、GitHub上で完結できました。
気になる方はぜひ試してみてください。
ここまで読んでいただきありがとうございました!