Skip to content

feat: Claude Code の自動バージョン更新ワークフローを追加 - #550

Merged
keito4 merged 1 commit into
mainfrom
feat/auto-update-claude-code
Mar 9, 2026
Merged

feat: Claude Code の自動バージョン更新ワークフローを追加#550
keito4 merged 1 commit into
mainfrom
feat/auto-update-claude-code

Conversation

@keito4

@keito4 keito4 commented Mar 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • Dockerfile で Claude Code のバージョンを ARG で管理するように変更
  • Claude Code を 2.1.632.1.71 に更新
  • 自動バージョン更新ワークフロー update-claude-code.yml を追加

自動更新ワークフローの動作

項目 内容
実行タイミング 毎日 UTC 4:00(JST 13:00)
バージョン取得 npm view @anthropic-ai/claude-code version
動作 新しいバージョンがあれば Dockerfile を更新して PR を自動作成

Test plan

  • ワークフローの手動実行でバージョンチェックが正常に動作することを確認
  • イメージビルドが正常に完了することを確認

🤖 Generated with Claude Code

Summary by CodeRabbit

Chores

  • Updated development container configuration with configurable version management for tooling components.
  • Introduced automated workflow to periodically check and synchronize development dependencies with their latest published versions, creating pull requests when updates are available.

- Dockerfile でバージョンを ARG で管理するように変更
- Claude Code を 2.1.63 → 2.1.71 に更新
- update-claude-code.yml ワークフローを追加
  - 毎日 UTC 4:00 に最新バージョンをチェック
  - 新しいバージョンがあれば自動で PR を作成

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Mar 9, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR automates Claude Code version management by introducing a build argument in the dev container Dockerfile and adding a GitHub Actions workflow that periodically checks npm for updates, creating pull requests when newer versions are available.

Changes

Cohort / File(s) Summary
Dockerfile Parameterization
.devcontainer/Dockerfile
Added CLAUDE_CODE_VERSION build argument (default: 2.1.71) and replaced hardcoded version 2.1.63 with dynamic reference. Includes workflow management note.
Version Update Automation
.github/workflows/update-claude-code.yml
New workflow that runs on schedule and manual dispatch to check npm for latest Claude Code version, compare against current Dockerfile version, update if needed, and create PR with dependencies label.

Sequence Diagram

sequenceDiagram
    actor Schedule
    participant Workflow as GitHub Actions<br/>(Workflow)
    participant npm as npm Registry
    participant Git as Git/GitHub
    participant File as Dockerfile

    Schedule->>Workflow: Trigger (daily or manual)
    Workflow->>Git: Checkout repository
    Workflow->>File: Read current CLAUDE_CODE_VERSION
    Workflow->>npm: Query `@anthropic-ai/claude-code` latest
    Workflow->>Workflow: Compare versions
    alt Update Needed
        Workflow->>File: Update CLAUDE_CODE_VERSION build arg
        Workflow->>Git: Create branch (fix/update-claude-code-*)
        Workflow->>Git: Commit and push changes
        Workflow->>Git: Create PR with dependencies label
        Workflow->>Git: Delete branch after PR creation
    else Already Latest
        Workflow->>Workflow: Report no update needed
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • #434: Directly modifies the same Dockerfile Claude Code installer and adds automation for version synchronization.
  • #239: Implements automation to keep Claude Code version up to date with workflow enhancements and version management scripts.
  • #479: Touches the Claude Code version update flow with scripts and workflow steps operating on the same Dockerfile version.

Suggested labels

dependencies

Poem

🐰 Twitches nose with glee
A version that dances with npm's release,
No manual bumps to disturb my peace!
Each day a check, each check a care,
Claude Code flows fresh through the dev container air. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title in Japanese accurately describes the main change: adding an automatic Claude Code version update workflow. It directly corresponds to the primary change in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/auto-update-claude-code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@keito4

keito4 commented Mar 9, 2026

Copy link
Copy Markdown
Owner Author

🔍 AI Code Review (Local Hook)

Models: Codex (default) / Gemini (default)

🤖 Codex Review

指摘事項なし。

判定: patch is correct
理由: 変更はバージョン固定のARG導入と自動更新ワークフロー追加のみで、既存挙動を壊す要素や明確な不整合は見当たりません。
信頼度: 0.66

✨ Gemini Review

レビュー結果は以下の通りです。

指摘事項

  1. [要確認] バージョン取得方法の妥当性

    • 説明: ワークフローは@anthropic-ai/claude-codeというnpmパッケージから最新バージョンを取得していますが、install.shでインストールされるツールがこのパッケージのバージョンと一致しているか不明です。バージョン体系が異なる場合、自動更新が正しく機能しない可能性があります。
    • ファイル: .github/workflows/update-claude-code.yml
    • 行範囲: 38-40
  2. [要確認] リリースノートのURL

    • 説明: 自動作成されるプルリクエスト内のリリースノートへのリンクが、正しいリポジトリとタグ形式を指しているか確認が必要です。誤っている場合、リンク切れになります。
    • ファイル: .github/workflows/update-claude-code.yml
    • 行範囲: 77

総合評価

  • 判定: patch is correct
  • 理由: この変更は、ハードコードされたバージョンをARG変数に置き換え、自動更新ワークフローを追加することで、保守性を大幅に向上させます。上記2点の外部情報に関する仮定が正しければ、このパッチは意図通りに機能します。
  • 信頼度スコア: 0.8

🤖 Generated by post_pr_ai_review.py hook

@keito4

keito4 commented Mar 9, 2026

Copy link
Copy Markdown
Owner Author

🔍 AI Code Review (Local Hook)

Models: Codex (default) / Gemini (default)

🤖 Codex Review

指摘事項

  • セキュリティ/信頼性: 最新版の取得元が npm(npm view @anthropic-ai/claude-code version)なのに、実際のインストールは https://claude.ai/install.sh 経由です。両者のバージョン整合が保証されていないため、npm で公開された直後にインストーラ側が未対応だと自動更新でビルド失敗を誘発します。更新元をインストーラが参照する実際の配布元に合わせるか、更新前にインストール可否を検証するガードが必要です。
    影響範囲: .github/workflows/update-claude-code.yml:28-47, .devcontainer/Dockerfile:103-106

判定: patch is incorrect
理由: 自動更新がインストーラ側の実配布状況と乖離する可能性があり、CI/DevContainer ビルドを継続的に破壊し得るため。
信頼度: 0.36

✨ Gemini Review

レビュー結果

発見事項リスト

  1. [問題] 存在しないnpmパッケージを参照している

    • ファイル: .github/workflows/update-claude-code.yml
    • 行: 40
    • 説明: ワークフローが最新バージョンを取得するために npm view @anthropic-ai/claude-code version を実行していますが、@anthropic-ai/claude-code というnpmパッケージは存在しないようです。おそらく、公式のCLIパッケージである @anthropic/claude-cli の間違いだと思われます。このままではワークフローがバージョン取得に失敗し、機能しません。
  2. [問題] リリースノートのURLが間違っている

    • ファイル: .github/workflows/update-claude-code.yml
    • 行: 77
    • 説明: 生成されるプルリクエストの本文に含まれるリリースノートへのリンクが、存在しないGitHubリポジトリ (anthropics/claude-code) を指しています。これも問題1と同様に、正しいリポジトリ名に修正する必要があります。
  3. [改善提案] Dockerfileを更新するコマンドの堅牢性が低い

    • ファイル: .github/workflows/update-claude-code.yml
    • 行: 54
    • 説明: sed コマンドが現在のバージョン番号を基に置換を行っていますが、これは将来的に予期せぬ挙動を引き起こす可能性があります。バージョン番号の文字列に依存せず、ARG CLAUDE_CODE_VERSION= という行全体を置換するアプローチ(例: sed -i "s/^ARG CLAUDE_CODE_VERSION=.*/ARG CLAUDE_CODE_VERSION=${{ steps.versions.outputs.latest }}/" .devcontainer/Dockerfile)に変更することで、より堅牢になります。

全体的な判定

patch is incorrect

  • 理由: 中核機能であるClaude Codeの最新バージョンを取得するためのnpmパッケージ名が誤っているため、このワークフローは期待通りに動作しません。
  • 信頼度: 0.9

⚠️ 修正が必要です

上記のレビューで問題が指摘されています。修正してからマージしてください。


🤖 Generated by post_pr_ai_review.py hook

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c5254dcb7d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

id: versions
run: |
# 現在のバージョンを Dockerfile から取得
CURRENT_VERSION=$(grep -oP 'CLAUDE_CODE_VERSION=\K[0-9.]+' .devcontainer/Dockerfile)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse full semver for CLAUDE_CODE_VERSION

The current-version parser only accepts digits and dots, so versions like 2.2.0-beta.1 or 2.2.0+build are truncated before comparison. In that case needs_update stays true forever and the later sed replacement can produce an invalid version string (for example by replacing only the prefix and leaving the suffix behind), which breaks the auto-update workflow when upstream publishes non-plain semver tags.

Useful? React with 👍 / 👎.

@claude

claude Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

PR レビュー

全体的に良い取り組みです。Claude Code のバージョン管理を自動化することで、手動更新の手間を削減できます。

✅ 良い点

  • ARG CLAUDE_CODE_VERSION でバージョンを一箇所で管理できるようにした設計はクリーン
  • concurrency 設定で並列実行を防いでいる(cancel-in-progress: false で実行中のジョブを保護)
  • timeout-minutes: 10 でハング時の保護がある
  • workflow_dispatch で手動トリガーが可能
  • Dockerfile コメントでワークフローとの関連を明示している

⚠️ 要修正

1. sed コマンドの正規表現エスケープ問題

sed の s/// の検索側はデフォルトで正規表現として解釈されるため、バージョン文字列中の .(例: 2.1.71)は「任意の1文字」にマッチします。現状は実害が出にくいですが、正確性のため修正を推奨します。

修正案: env: 経由で変数を渡し、ドットをエスケープしてから sed に渡す。

- name: Update Dockerfile
  if: steps.versions.outputs.needs_update == 'true'
  env:
    CURRENT: ${{ steps.versions.outputs.current }}
    LATEST: ${{ steps.versions.outputs.latest }}
  run: |
    ESCAPED_CURRENT=$(printf '%s\n' "$CURRENT" | sed 's/\./\\./g')
    sed -i "s/CLAUDE_CODE_VERSION=${ESCAPED_CURRENT}/CLAUDE_CODE_VERSION=${LATEST}/" .devcontainer/Dockerfile
    echo "Updated Claude Code version from $CURRENT to $LATEST"

2. シェルインジェクションの軽減

steps.versions.outputs.* を直接シェルコマンドに展開するのは、外部データ(npm レジストリから取得した値)をシェルに渡すパターンです。npm のバージョン文字列は通常安全ですが、env: 経由で渡す方がより安全です(上記修正案に含む)。

💡 提案(任意)

3. npm view 失敗時のバリデーション

ネットワーク障害時に LATEST_VERSION が空になった場合、誤った Dockerfile 更新が発生する可能性があります。

LATEST_VERSION=$(npm view @anthropic-ai/claude-code version 2>/dev/null)
if [ -z "$LATEST_VERSION" ]; then
  echo "::error::Failed to fetch latest Claude Code version"
  exit 1
fi

4. 自動生成PRにリンクIssueがない

CLAUDE.md では「Linked Issue必須」とされていますが、自動生成PRでは付与が難しいです。自動生成PRを例外として扱うか、トラッキングIssueへのリンクを検討してください。

まとめ

項目 評価
設計 ✅ 良好
sed の正規表現 ⚠️ 修正推奨
シェルインジェクション対策 ⚠️ 修正推奨
エラーハンドリング 💡 改善余地あり

主要な修正点は sed のエスケープとシェルインジェクション対策の2点です。それ以外は概ね問題ありません。

🤖 Reviewed by Claude Code

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/update-claude-code.yml:
- Around line 28-79: The workflow currently sets LATEST_VERSION by running `npm
view `@anthropic-ai/claude-code` version` (in the "Get current and latest
versions" step) but the Dockerfile uses the native installer; replace the
npm-based lookup with a call to the native installer's release source (or GitHub
release tag) to populate LATEST_VERSION (keeping the CURRENT_VERSION extraction
from the Dockerfile and the existing outputs like steps.versions), and update
the sed replacement/branch naming logic to use that value; alternatively (or
additionally) add a new step before "Create pull request" that performs a Docker
build/install validation using the retrieved LATEST_VERSION to ensure the
installer and Dockerfile version match before opening the PR.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9d8b420e-c8ea-422b-8f14-32a3bbfea7fc

📥 Commits

Reviewing files that changed from the base of the PR and between 34637e7 and c5254dc.

📒 Files selected for processing (2)
  • .devcontainer/Dockerfile
  • .github/workflows/update-claude-code.yml

Comment on lines +28 to +79
- name: Get current and latest versions
id: versions
run: |
# 現在のバージョンを Dockerfile から取得
CURRENT_VERSION=$(grep -oP 'CLAUDE_CODE_VERSION=\K[0-9.]+' .devcontainer/Dockerfile)
echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT

# 最新バージョンを npm から取得
LATEST_VERSION=$(npm view @anthropic-ai/claude-code version)
echo "latest=$LATEST_VERSION" >> $GITHUB_OUTPUT

echo "Current version: $CURRENT_VERSION"
echo "Latest version: $LATEST_VERSION"

# 更新が必要かチェック
if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then
echo "needs_update=true" >> $GITHUB_OUTPUT
else
echo "needs_update=false" >> $GITHUB_OUTPUT
fi

- name: Update Dockerfile
if: steps.versions.outputs.needs_update == 'true'
run: |
sed -i "s/CLAUDE_CODE_VERSION=${{ steps.versions.outputs.current }}/CLAUDE_CODE_VERSION=${{ steps.versions.outputs.latest }}/" .devcontainer/Dockerfile
echo "Updated Claude Code version from ${{ steps.versions.outputs.current }} to ${{ steps.versions.outputs.latest }}"

- name: Create pull request
if: steps.versions.outputs.needs_update == 'true'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: fix/update-claude-code-${{ steps.versions.outputs.latest }}
delete-branch: true
commit-message: 'fix: update Claude Code to ${{ steps.versions.outputs.latest }}'
title: 'fix: update Claude Code to ${{ steps.versions.outputs.latest }}'
body: |
## Claude Code バージョン更新

| 項目 | 値 |
|------|-----|
| 現在のバージョン | `${{ steps.versions.outputs.current }}` |
| 新しいバージョン | `${{ steps.versions.outputs.latest }}` |

### 📝 リリースノート

[Claude Code Releases](https://github.com/anthropics/claude-code/releases/tag/v${{ steps.versions.outputs.latest }})

---

**Auto-generated by:** [update-claude-code.yml](.github/workflows/update-claude-code.yml)
labels: dependencies

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

Does Claude Code's official installer claude.ai/install.shsupport installing an explicit version, and are versions guaranteed to stay in sync with the npm package@anthropic-ai/claude-code?

💡 Result:

  • Yes. Anthropic’s official docs show that the claude.ai/install.sh installer accepts a version argument (passed to bash -s), e.g. curl -fsSL https://claude.ai/install.sh | bash -s 1.0.58, explicitly labeled “To install a specific version number.” [1]
  • No guarantee they stay in sync. Anthropic documents that npm installation is deprecated in favor of the native installer (which auto-updates), and also notes that other distribution channels can lag (“may notify you of updates before the new version is available in these package managers”), implying releases are not guaranteed to land everywhere simultaneously. There’s no statement in the official docs promising the native-installer versioning will always match the npm package @anthropic-ai/claude-code. [1]

Sources
[1] Anthropic Claude Code docs – Setup / Install & Update (includes “install a specific version number”, “Deprecated npm installation”, and channel lag note) (docs.anthropic.com)

Citations:


Replace npm-based version check with the native installer, which supports explicit versioning.

The workflow reads the version from npm's @anthropic-ai/claude-code package, but the Dockerfile installs Claude via claude.ai/install.sh. The official Anthropic docs indicate that:

  • The native installer accepts explicit version parameters (curl -fsSL https://claude.ai/install.sh | bash -s VERSION)
  • npm installation is deprecated in favor of the native installer
  • Version channels are not guaranteed to stay in sync across distribution channels

Instead of fetching from npm, fetch the version from the native installer's release source and use its versioning directly. Alternatively, add a Docker build/install validation step before the create-pull-request action to catch channel mismatches before opening PRs.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/update-claude-code.yml around lines 28 - 79, The workflow
currently sets LATEST_VERSION by running `npm view `@anthropic-ai/claude-code`
version` (in the "Get current and latest versions" step) but the Dockerfile uses
the native installer; replace the npm-based lookup with a call to the native
installer's release source (or GitHub release tag) to populate LATEST_VERSION
(keeping the CURRENT_VERSION extraction from the Dockerfile and the existing
outputs like steps.versions), and update the sed replacement/branch naming logic
to use that value; alternatively (or additionally) add a new step before "Create
pull request" that performs a Docker build/install validation using the
retrieved LATEST_VERSION to ensure the installer and Dockerfile version match
before opening the PR.

@keito4

keito4 commented Mar 9, 2026

Copy link
Copy Markdown
Owner Author

(aside)
@claude PRがbaseにマージする際にCIが落ちています。
修正してください。

@claude

claude Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Claude finished @keito4's task in 5m 38s —— View job


CI修正調査結果

  • CIの失敗状況を確認
  • 失敗原因を特定
  • 対応方針を検討

📊 現在のCI状態

すべてのCIチェックが ✅ パス しています:

チェック 状態
Workflow Lint (actionlint) ✅ pass
Quality Gate ✅ pass
Trivy Container Scan ✅ pass
Generate SBOM ✅ pass
GitGuardian Security Checks ✅ pass
PR mergeable ✅ CLEAN / MERGEABLE

コメント投稿時点では Container Security Scan が in_progress 中(Docker イメージビルド+Trivy 脆弱性スキャン実行中)でしたが、現在は正常完了しています。


⚠️ 修正できない制限について

レビューコメントで指摘されている問題は .github/workflows/update-claude-code.yml 内にありますが、GitHub App の権限制限により、ワークフローファイルを直接編集することができません

詳細は FAQ をご参照ください。


🔍 指摘されている問題点(手動対応が必要)

以下の問題は .github/workflows/update-claude-code.yml の修正が必要です:

1. npm パッケージ名の確認(Gemini・Codex レビュー指摘)

# 現在(line 36)
LATEST_VERSION=$(npm view @anthropic-ai/claude-code version)

@anthropic-ai/claude-code が実際に npm に存在するか確認が必要です。Gemini レビューでは「存在しない」と指摘されています。Claude Code の公式インストーラー(claude.ai/install.sh)のリリース情報と同期していない可能性があります。

2. sed コマンドのシェルインジェクション(Claude・Codex レビュー指摘)

# 現在(line 52)
sed -i "s/CLAUDE_CODE_VERSION=${{ steps.versions.outputs.current }}/CLAUDE_CODE_VERSION=${{ steps.versions.outputs.latest }}/" .devcontainer/Dockerfile

外部データ(npm レジストリ)から取得した値を直接シェルに展開しています。env: 経由で渡す方法が推奨されます。

3. リリースノートURLが不正(Gemini レビュー指摘)

# 現在(line 74)
[Claude Code Releases](https://github.com/anthropics/claude-code/releases/tag/v${{ steps.versions.outputs.latest }})

anthropics/claude-code リポジトリが存在するか確認が必要です。


まとめ

現在のPRに対するCIはすべて通過しており、マージ可能な状態です。ただし、追加した update-claude-code.yml ワークフローがスケジュール実行された際に上記の問題で失敗する可能性があります。ワークフローファイルの修正は直接実施できないため、手動での対応をお願いします。
| Container Security Scan | Branch

@keito4
keito4 merged commit acf4a32 into main Mar 9, 2026
19 checks passed
@github-actions

github-actions Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.91.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions github-actions Bot added the released リリース済み label Mar 9, 2026
@keito4
keito4 deleted the feat/auto-update-claude-code branch March 20, 2026 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released リリース済み

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant