Closed16

今更だがClaude Code Github Actions触ってみた

バタンヌバタンヌ
/init

コードベースを読み込んでプロジェクト用のCLAUDE.mdを生成してくれる。

/initコマンドでできるプロジェクト用のCLAUDE.mdは、プロジェクト固有の知識をメモリ上に保管し、
Claude Code はこのファイルを継続的に参照し、プロジェクト固有の知識として学習し実行してくれるっぽい。
毎回プロンプトで指示していることはここに書いておけば、良さそう。
コンテキストウィンドウが長くなると、生成するコードの精度も落ちやすいと聞いたことがあるので
前提情報はCLAUDE.md書いておく。
例)こんなのを設定しておくといいかも

  • アーキテクチャ設計
  • コーディング規則
  • 共通ワークフロー

https://docs.anthropic.com/en/docs/claude-code/memory

バタンヌバタンヌ

Claude Code Actionsの概要

githubとClaudeのモデルが連携して、issueやPRのコメントに@claudeにメンションつけて指示するといい感じにコード生成してコミットを作ってくれるやつ

バタンヌバタンヌ

claude codeを起動して、/install-github-appコマンドでgithubとclaudeとを連携するための認証を済ます。

バタンヌバタンヌ

/install-github-appで以下のエラーが出た。どうやらGitHub CLIツールがインストールされていなかったらしい

 ※ Tip: Cmd+Escape to launch Claude in your IDE
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ⚠ Setup Warnings                                                                                                                                               │
│ We found some potential issues, but you can continue anyway                                                                                                    │
│                                                                                                                                                                │
│ GitHub CLI not found                                                                                                                                           │
│ GitHub CLI (gh) does not appear to be installed or accessible.                                                                                                 │
│                                                                                                                                                                │
│   • Install GitHub CLI from https://cli.github.com/                                                                                                            │
│   • macOS: brew install gh                                                                                                                                     │
│   • Windows: winget install --id GitHub.cli                                                                                                                    │
│   • Linux: See installation instructions at https://github.com/cli/cli#installation                                                                            │
│                                                                                                                                                                │
│ GitHub CLI not authenticated                                                                                                                                   │
│ GitHub CLI does not appear to be authenticated.                                                                                                                │
│                                                                                                                                                                │
│   • Run: gh auth login                                                                                                                                         │
│   • Follow the prompts to authenticate with GitHub                                                                                                             │
│   • Or set up authentication using environment variables or other methods  
バタンヌバタンヌ
  1. GitHub CLIツールのインストール
    macの場合
brew install gh
  1. GitHub CLIの認証設定
gh auth login

このコマンド実行後に認証に関していくつか聞かれるが、聞かれた通りに答えていけばいい

バタンヌバタンヌ

claude code actionsを走らせているときに以下のエラーが出た。
私用によりタイムアップのため、続きはこのエラーの調査からする。

Error: Process completed with exit code 1.
Run bun run ${GITHUB_ACTION_PATH}/src/entrypoints/update-comment-link.ts
Fetching issue comment 3162221727
Successfully fetched as issue comment
GET /repos/bata515/claud-code-test/branches/claude%2Fissue-1-20250807-0240 - 404 with id 67C0:F1C6F:752AC7E:EBA4412:68941241 in 134ms
Branch claude/issue-1-20250807-0240 does not exist remotely
Branch claude/issue-1-20250807-0240 does not exist remotely, no branch link will be added
GET /repos/bata515/claud-code-test/compare/main...claude%2Fissue-1-20250807-0240 - 404 with id 67C0:F1C6F:752AD0E:EBA4510:68941241 in 107ms
Error checking for changes in branch: 11 |   /**
12 |    * Response object if a response was received
13 |    */
14 |   response;
15 |   constructor(message, statusCode, options) {
16 |     super(message);
         ^
HttpError: Not Found - https://docs.github.com/rest/commits/commits#compare-two-commits
   status: 404,
  request: {
  method: "GET",
  url: "https://api.github.com/repos/bata515/claud-code-test/compare/main...claude%2Fissue-1-20250807-0240",
  headers: [Object ...],
  request: [Object ...],
},
 response: {
  url: "https://api.github.com/repos/bata515/claud-code-test/compare/main...claude%2Fissue-1-20250807-0240",
  status: 404,
  headers: [Object ...],
  data: [Object ...],
},

      at new RequestError (/home/runner/work/_actions/anthropics/claude-code-action/beta/node_modules/@octokit/rest/node_modules/@octokit/core/node_modules/@octokit/request-error/dist-src/index.js:16:5)
      at fetchWrapper (/home/runner/work/_actions/anthropics/claude-code-action/beta/node_modules/@octokit/rest/node_modules/@octokit/core/node_modules/@octokit/request/dist-bundle/index.js:122:11)
バタンヌバタンヌ

原因はclaudeの従量課金プランでAPIキーを使う方法と定額プランでAPIを使う方法での認証キーの取得方法が違っていたことが原因だった。だからリクエストがうまく承認されていなくてエラーだったのか
https://zenn.dev/acntechjp/articles/3f361da473eac8#:~:text=で成功です!-,2025年7月13日追記 MAXプランで使う方法,-Claude Code経由
↑この設定通りやったら解決した

動き出した🎉

バタンヌバタンヌ

結構時間かかってる。
タスクの完了まで積読している技術書でも読んで待っていよう。

バタンヌバタンヌ

5〜10分ほどで完了した。変更用のブランチを自動で作ってくれてclaudeが完了したことを教えてくれる。
PRは手動で作成しなければいけないらしい。もしかしたらPRも自動で作成できるかもしれないが、いまは深ぼらずに先に進める。

before

after

タイトルにモダンをつけられたww
まあその他はいい感じに修正してくれたので良しとする。画像ではわからないがボタンをホバーした時の動きもいい感じになっている。

バタンヌバタンヌ

使ってみた感想としては、
スマホのgithubアプリでissueを作成して、@claudeで修正お願いすれば
PC使えない時も開発を進められて便利かもと思った。

あとはissueごとに並行して開発を進められるのはいいかも。

バタンヌバタンヌ

どんな時に業務で使えそうかなどを考えながら、引き続き個人的に使ってみようと思う。

バタンヌバタンヌ

余談だが、PR内のコメントで@claudeを使えることも確認できた。

このスクラップは1ヶ月前にクローズされました