11
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AI駆動開発のすゝめ - GitHub Actions × Claude Code で実現する自動コードレビューと実装

11
Last updated at Posted at 2025-12-09

はじめに

本記事では、私たちのプロジェクト(ここではTiroruと呼びます)で導入している AI駆動開発 の仕組みについて紹介します。特に、GitHub IssueやPull Requestに要件を書き込むだけで、Claudeが自動的にコードレビューや実装を行ってくれるワークフローについて解説します。

プロジェクト概要

Tiroru (仮名) は弊社のマイクロサービスのひとつで、以下の技術スタックで構成されています

  • フロントエンド: React 18 + TypeScript + Vite
  • スタイル: SCSS/CSS Modules
  • テスト: Jest + React Testing Library
  • 品質管理: ESLint + Prettier + Stylelint

AI駆動開発の仕組み

1. Claude Code Action の導入

私たちは Anthropic社が提供するclaude-code をGitHub Actionsで活用しています。これにより、ClaudeがGitHub上で以下のタスクを自動実行できます

  • コードレビュー
  • 質問への回答
  • バグ修正の実装
  • 新機能の実装

2. ワークフローの設定

.github/workflows/claude-pr-assistant.yml に以下のようなワークフローを設定しています

name: Claude PR Assistant

on:
  issue_comment:
    types: [created]
  pull_request_review_comment:
    types: [created]
  issues:
    types: [opened, assigned]
  pull_request:
    types: [opened, ready_for_review]
  pull_request_review:
    types: [submitted]

jobs:
  claude-code-action:
    if: |
      (
        (github.event_name == 'issue_comment' && (contains(github.event.comment.body, '@claude') || contains(github.event.comment.body, 'claude'))) ||
        (github.event_name == 'pull_request_review_comment' && (contains(github.event.comment.body, '@claude') || contains(github.event.comment.body, 'claude'))) ||
        (github.event_name == 'pull_request_review' && (contains(github.event.review.body, '@claude') || contains(github.event.review.body, 'claude'))) ||
        (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.body, 'claude'))) ||
        (github.event_name == 'pull_request' && !github.event.pull_request.draft && github.actor != 'dependabot[bot]')
      )
    runs-on: ubuntu-latest
    timeout-minutes: 30
    permissions:
      contents: read
      pull-requests: write
      issues: write
      id-token: write

3. トリガーとなるイベント

Claudeが起動するトリガーは以下の通りです

  1. Issueが作成された時 - Issue本文に @claude または claude が含まれている場合
  2. Issue/PRにコメントがついた時 - コメントに @claude または claude が含まれている場合
  3. Pull Requestが開かれた時 - ドラフトではなく、dependabotによるものでない場合
  4. Pull Requestレビューが投稿された時 - レビュー内容に @claude または claude が含まれている場合

4. Claudeに与えられた役割とツール

Claudeには以下のツールが許可されています

allowed_tools: "Bash(npm:*),Bash(node:*),Bash(ls:*),Bash(grep:*),Bash(find:*),Bash(pwd),Bash(git:*),Bash(eslint:*),Bash(prettier:*),Bash(stylelint:*),Bash(jest:*),Bash(tsc:*),Bash(vite:*),mcp__github__create_issue,mcp__github__create_pending_pull_request_review,mcp__github__add_comment_to_pending_review,mcp__github__submit_pending_pull_request_review,mcp__github__get_pull_request_diff"

これにより、Claudeは以下のことが可能になります

  • コード品質チェック: ESLint、Prettier、Stylelintの実行
  • テスト実行: Jestによるテストの実行
  • 型チェック: TypeScriptの型チェック(tsc)
  • ビルド確認: Viteによるビルドの実行
  • GitHubとの統合: レビューコメントの追加、Issue作成、差分の取得

5. カスタマイズされたレビュープロセス

Claudeには日本語でレビューを行うよう指示し、以下のようなレビュー手順を定義しています:

  1. レビューを開始: mcp__github__create_pending_pull_request_review で保留中のレビューを開始
  2. 差分情報を取得: mcp__github__get_pull_request_diff でコード変更と行番号を理解

6. レビュー観点

Claudeには以下の観点でコードをレビューするよう指示しています

セキュリティ

  • XSS脆弱性
  • 外部API呼び出しの適切な検証
  • 個人情報の適切な取り扱い

パフォーマンス

  • 不要な再レンダリングの回避
  • 大きなファイルの遅延読み込み
  • 画像の最適化
  • バンドルサイズの最適化

コードの品質

  • コードの可読性と保守性
  • 適切なコメント記述
  • 命名規則の一貫性
  • テストカバレッジの確保
  • エラーハンドリングの適切性

AI駆動開発のメリット・デメリット

個人的に感じたメリットとデメリットについてお話しします。
メリットは、なんといっても開発工程がぐんと減ったことです。Tiroruの運用にあたり定期的に軽微修正が発生しますが、その際はissueに該当問題を記述するだけでAIがPRを作成してくれるようになりました。その上で、必要に応じてPR上で開発環境をチェックしたり追加修正を加えたりすることで、一定の品質を担保しつつ、開発サイクルをより早く回せるようになったと感じました。

一方、デメリットはレビューコストがかかることです。AIによるレビューも行ってはいますが、最終的には人のチェックが入るようにしています。PRのみが大量に作られレビューが滞るようなことは現在ありませんが、レビュー負担は以前より多くなったと感じます。

この辺りはまだまだ進化途中という感じですね...

まとめ

GitHub Actions × Claude Code により、Issue に要件を書くだけでAIが実装を提案し、Pull Request のレビューまで自動化できる仕組みを構築できました。この仕組みにより、

  • 開発速度が向上
  • コード品質が安定
    などなど、多くのメリットが得られます。 
    AI駆動開発はまだ発展途上の分野ですが、適切に導入することで開発プロセスを大きく改善できます。みなさんのプロジェクトでもぜひ試してみてください!

参考リンク


11
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?