Skip to content

feat: update Claude Code to 2.1.33 and sync Dockerfile version automatically - #434

Merged
keito4 merged 1 commit into
mainfrom
feat/update-claude-code-with-dockerfile-sync
Feb 6, 2026
Merged

feat: update Claude Code to 2.1.33 and sync Dockerfile version automatically#434
keito4 merged 1 commit into
mainfrom
feat/update-claude-code-with-dockerfile-sync

Conversation

@keito4

@keito4 keito4 commented Feb 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Claude Code を 2.1.25 から 2.1.33 に更新
  • update-claude-code.sh を改修し、Dockerfile のバージョンも自動更新するように

Changes

  • .devcontainer/Dockerfile: Claude Code バージョンを 2.1.33 に更新
  • script/update-claude-code.sh:
    • npm registry から最新バージョンを取得する機能を追加
    • Dockerfile の claude.ai/install.sh 行のバージョンを自動更新
    • バージョン比較と差分表示機能を追加

Test plan

  • bash script/update-claude-code.sh でスクリプトが正常に動作することを確認
  • Dockerfile の Claude Code 行のみが更新され、他の行(rustup等)に影響がないことを確認

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated Claude Code installer to version 2.1.33
    • Enhanced the update script to automatically synchronize the Dockerfile with the latest Claude Code version
    • Improved update workflow with fallback mechanisms and enhanced logging

…tically

- Update Claude Code from 2.1.25 to 2.1.33 in Dockerfile
- Enhance update-claude-code.sh to automatically update Dockerfile version
- Add npm registry version check for latest release detection
- Fix sed pattern to only update claude.ai/install.sh line

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

coderabbitai Bot commented Feb 6, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR updates the Claude Code installer version from 2.1.25 to 2.1.33 and enhances the update script to automatically detect, fetch, and synchronize Dockerfile versions with the latest Claude Code release from npm.

Changes

Cohort / File(s) Summary
Version Configuration
.devcontainer/Dockerfile
Claude Code installer version bumped from 2.1.25 to 2.1.33.
Update Script Enhancement
script/update-claude-code.sh
Added dynamic version management with helper functions to fetch latest version from npm, read/update Dockerfile version. Script now handles Claude CLI presence detection, performs update or reinstall with latest version, and synchronizes Dockerfile version automatically. Includes improved logging and error handling paths.

Sequence Diagram

sequenceDiagram
    participant User
    participant Script as update-claude-code.sh
    participant NPM as npm Registry
    participant Dockerfile
    participant Claude as Claude CLI
    
    User->>Script: Run update script
    Script->>NPM: Fetch latest Claude Code version
    NPM-->>Script: Return latest version (e.g., 2.1.33)
    Script->>Dockerfile: Read current Dockerfile version
    Dockerfile-->>Script: Return current version
    
    alt Claude CLI exists
        Script->>Claude: Execute claude update
        Claude-->>Script: Update result
        alt Update successful
            Script->>Script: Compare versions
        else Update fails
            Script->>Script: Fallback to install.sh
        end
    else Claude CLI not found
        Script->>Script: Skip CLI update
    end
    
    Script->>Dockerfile: Update version to latest
    Dockerfile-->>Script: Confirm update
    Script->>Script: Log git diff
    Script-->>User: Report completion
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

size/XS

Poem

🐰 A rabbit hopped through the Docker file,
Updating versions with automated style,
From npm it fetched the latest release,
Syncing Dockerfile with seamless ease,
Version 2.1.33—no manual fuss! ✨

🚥 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 pull request title clearly and accurately summarizes the main changes: updating Claude Code to version 2.1.33 and automatically syncing the Dockerfile version to match.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/update-claude-code-with-dockerfile-sync

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 Feb 6, 2026

Copy link
Copy Markdown
Owner Author

🔍 AI Code Review (Local Hook)

Models: Codex (gpt-5.2-codex) / Gemini (gemini-2.5-pro)

🤖 Codex Review

  • 重大: script/update-claude-code.sh:56-66 で npm レジストリ取得と Dockerfile 解析が無条件に走るため、.devcontainer/Dockerfile が存在しない/書式が変わった環境では set -euo pipefail により即終了し、ローカルの claude update すら実行できません。以前は CLI 更新だけは可能だったので後方互換性の退行です。
  • 中: script/update-claude-code.sh:29-31script/update-claude-code.sh:56-61 で npm レジストリへの依存が必須になり、ネットワーク制限や npm 側障害時に更新処理全体が終了します。claude update は独自チャネルで更新できる可能性があるため、可用性の退行です。

patch is incorrect — 新しい必須依存(npm レジストリと Dockerfile の存在/形式)により、CLI 更新が不必要に失敗する退行が導入されています。信頼度 0.62


⚠️ 修正が必要です

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


🤖 Generated by post_pr_ai_review.py hook

@claude

claude Bot commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

PR Review: Claude Code バージョン更新とスクリプト改善

📋 総合評価

LGTM with suggestions - 基本的に良好な変更ですが、いくつかの改善提案があります。


✅ 良い点

1. 自動化の改善

  • Dockerfile のバージョンも自動更新する仕組みは excellent です
  • npm registry から最新バージョンを動的に取得する実装により、手動更新の手間を削減

2. コードの構造化

  • 関数化により可読性が向上(get_latest_version, get_dockerfile_version, update_dockerfile_version
  • エラーハンドリングが適切に実装されている

3. ユーザー体験

  • カラー出力によるログの視認性向上
  • Dockerfile の変更内容を git diff で表示する親切な実装

🔍 潜在的な問題点

1. セキュリティ:パイプライン経由の curl 実行

script/update-claude-code.sh:84

パイプ経由でのスクリプト実行は、MITM 攻撃や予期せぬコード実行のリスクがあります。

2. エラーハンドリング:sed の失敗を検知できない

script/update-claude-code.sh:51

sed -i が失敗しても関数は成功を返します。変更が実際に適用されたか確認する処理を追加することを推奨します。

3. 正規表現の堅牢性

script/update-claude-code.sh:31,36

  • バージョン形式の変化(例: 2.1.33-beta)に対応できない
  • JSON パースに jq を使わず grep/cut に依存

4. テストカバレッジの欠如

CLAUDE.md の規定により、TDD が要求されていますが、このスクリプトにはテストが存在しません。

推奨: Bash スクリプトのユニットテスト(batsshunit2)を追加


🔧 その他の改善提案

5. 並行安全性

複数のプロセスが同時にスクリプトを実行した場合、Dockerfile の更新が競合する可能性があります。ロックファイルの使用を推奨します。

6. バージョン検証

npm registry から取得したバージョンが妥当な形式かを検証していません。

7. ドキュメント更新の必要性

.claude/commands/update-claude-code.md のドキュメントが古くなっています。Dockerfile の自動更新機能について記載されていません。


📊 品質基準チェック

項目 状態 備考
コード品質 ⚠️ 関数化は良好だが、エラーハンドリングに改善余地
セキュリティ ⚠️ パイプライン経由の curl 実行にリスク
テストカバレッジ テストが存在しない(CLAUDE.md 要件未達)
ドキュメント ⚠️ .claude/commands/update-claude-code.md の更新が必要
パフォーマンス 問題なし

🎯 推奨アクション

必須(Merge 前に対応)

  1. テストの追加: 最低限、主要な関数のユニットテストを追加
  2. ドキュメント更新: .claude/commands/update-claude-code.md に Dockerfile 自動更新機能を記載

推奨(次回以降で対応可)

  1. sed のエラーハンドリング強化
  2. バージョン検証ロジックの追加
  3. セキュリティ強化(curl のチェックサム検証)
  4. jq を使った堅牢な JSON パース

💡 まとめ

全体的に良好な改善ですが、CLAUDE.md で定義されている 70%+ テストカバレッジ の要件を満たしていない点が課題です。最低限のテストを追加した上でマージすることを推奨します。

セキュリティとエラーハンドリングの改善は、別 issue として追跡することも可能です。

Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com

@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

🤖 Fix all issues with AI agents
In `@script/update-claude-code.sh`:
- Line 70: The pipeline uses "|| echo \"unknown\"" after head which is
unreachable; change the command substitutions (e.g., the assignment to
current_version and the two similar occurrences) to group the producer so the
fallback runs when claude fails, for example wrap the calls as a grouped
pipeline like: { claude --version 2>/dev/null || echo "unknown"; } | head -1
(use this pattern for the assignments that currently use claude --version and
the two other identical patterns).
🧹 Nitpick comments (3)
script/update-claude-code.sh (3)

30-32: Fragile JSON parsing — consider jq or a more robust fallback.

Parsing JSON with grep + cut can break if the registry response format changes (e.g., whitespace around :). A safer approach if jq is available:

♻️ Suggested improvement
 get_latest_version() {
-    curl -s "https://registry.npmjs.org/@anthropic-ai/claude-code/latest" | grep -o '"version":"[^"]*"' | head -1 | cut -d'"' -f4
+    local json
+    json=$(curl -s "https://registry.npmjs.org/@anthropic-ai/claude-code/latest")
+    if command -v jq &>/dev/null; then
+        echo "${json}" | jq -r '.version'
+    else
+        echo "${json}" | grep -o '"version" *: *"[^"]*"' | head -1 | cut -d'"' -f4
+    fi
 }

If staying with grep, at least allow optional spaces in the pattern ("version" *: *"[^"]*") so it's resilient to formatting variations.


39-54: sed substitution uses version string as an unescaped regex — dots match any character.

On line 51, current_version is used directly in a sed pattern. Version dots (e.g., 2.1.33) are regex wildcards, so 2.1.33 would also match 2X1Y33. In practice this is unlikely to cause a mis-substitution in a Dockerfile, but it's imprecise.

Also, if get_dockerfile_version returns an empty string (e.g., the Dockerfile line doesn't match), current_version will be empty, making the sed pattern bash -s which could match unintended lines.

🛡️ Defensive improvement
 update_dockerfile_version() {
     local new_version="$1"
     local current_version
     current_version=$(get_dockerfile_version)
 
+    if [[ -z "${current_version}" ]]; then
+        log_error "Dockerfile から現在のバージョンを取得できませんでした"
+        return 1
+    fi
+
     if [[ "${current_version}" == "${new_version}" ]]; then
         log_info "Dockerfile は既に最新バージョンです (${current_version})"
         return 1
     fi

51-51: sed -i without backup extension is not portable to macOS.

GNU sed -i (Linux) works without an extension, but BSD sed (macOS) requires sed -i ''. If developers may run this script locally on macOS, consider:

-    sed -i "/claude.ai\/install.sh/s|bash -s ${current_version}|bash -s ${new_version}|" "${DOCKERFILE}"
+    if [[ "$(uname)" == "Darwin" ]]; then
+        sed -i '' "/claude.ai\/install.sh/s|bash -s ${current_version}|bash -s ${new_version}|" "${DOCKERFILE}"
+    else
+        sed -i "/claude.ai\/install.sh/s|bash -s ${current_version}|bash -s ${new_version}|" "${DOCKERFILE}"
+    fi

If the script is strictly Linux-only (CI / devcontainer), this can be ignored.

log_info "Claude Code を更新中..."
# claudeコマンドの存在確認
if command -v claude &> /dev/null; then
current_version=$(claude --version 2>/dev/null | head -1 || echo "unknown")

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 | 🟡 Minor

|| echo "unknown" is unreachable in a pipeline.

In claude --version 2>/dev/null | head -1 || echo "unknown", the || applies to head -1, which always exits 0 (even on empty input). If claude --version fails, current_version will be an empty string, not "unknown".

🔧 Proposed fix
-    current_version=$(claude --version 2>/dev/null | head -1 || echo "unknown")
+    current_version=$(claude --version 2>/dev/null | head -1)
+    current_version="${current_version:-unknown}"

The same pattern appears on lines 76 and 85.

🤖 Prompt for AI Agents
In `@script/update-claude-code.sh` at line 70, The pipeline uses "|| echo
\"unknown\"" after head which is unreachable; change the command substitutions
(e.g., the assignment to current_version and the two similar occurrences) to
group the producer so the fallback runs when claude fails, for example wrap the
calls as a grouped pipeline like: { claude --version 2>/dev/null || echo
"unknown"; } | head -1 (use this pattern for the assignments that currently use
claude --version and the two other identical patterns).

@keito4
keito4 merged commit 013b226 into main Feb 6, 2026
39 checks passed
@keito4
keito4 deleted the feat/update-claude-code-with-dockerfile-sync branch February 6, 2026 04:36
@github-actions

github-actions Bot commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.64.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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