feat: update Claude Code to 2.1.33 and sync Dockerfile version automatically - #434
Conversation
…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>
📝 WalkthroughWalkthroughThis 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
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
🔍 AI Code Review (Local Hook)Models: Codex (gpt-5.2-codex) / Gemini (gemini-2.5-pro) 🤖 Codex Review
patch is incorrect — 新しい必須依存(npm レジストリと Dockerfile の存在/形式)により、CLI 更新が不必要に失敗する退行が導入されています。信頼度 0.62
|
PR Review: Claude Code バージョン更新とスクリプト改善📋 総合評価LGTM with suggestions - 基本的に良好な変更ですが、いくつかの改善提案があります。 ✅ 良い点1. 自動化の改善
2. コードの構造化
3. ユーザー体験
🔍 潜在的な問題点1. セキュリティ:パイプライン経由の curl 実行script/update-claude-code.sh:84 パイプ経由でのスクリプト実行は、MITM 攻撃や予期せぬコード実行のリスクがあります。 2. エラーハンドリング:sed の失敗を検知できないscript/update-claude-code.sh:51
3. 正規表現の堅牢性script/update-claude-code.sh:31,36
4. テストカバレッジの欠如CLAUDE.md の規定により、TDD が要求されていますが、このスクリプトにはテストが存在しません。 推奨: Bash スクリプトのユニットテスト( 🔧 その他の改善提案5. 並行安全性複数のプロセスが同時にスクリプトを実行した場合、Dockerfile の更新が競合する可能性があります。ロックファイルの使用を推奨します。 6. バージョン検証npm registry から取得したバージョンが妥当な形式かを検証していません。 7. ドキュメント更新の必要性
📊 品質基準チェック
🎯 推奨アクション必須(Merge 前に対応)
推奨(次回以降で対応可)
💡 まとめ全体的に良好な改善ですが、CLAUDE.md で定義されている 70%+ テストカバレッジ の要件を満たしていない点が課題です。最低限のテストを追加した上でマージすることを推奨します。 セキュリティとエラーハンドリングの改善は、別 issue として追跡することも可能です。 Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com |
There was a problem hiding this comment.
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 — considerjqor a more robust fallback.Parsing JSON with
grep+cutcan break if the registry response format changes (e.g., whitespace around:). A safer approach ifjqis 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:sedsubstitution uses version string as an unescaped regex — dots match any character.On line 51,
current_versionis used directly in asedpattern. Version dots (e.g.,2.1.33) are regex wildcards, so2.1.33would also match2X1Y33. In practice this is unlikely to cause a mis-substitution in a Dockerfile, but it's imprecise.Also, if
get_dockerfile_versionreturns an empty string (e.g., the Dockerfile line doesn't match),current_versionwill be empty, making thesedpatternbash -swhich 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 -iwithout backup extension is not portable to macOS.GNU
sed -i(Linux) works without an extension, but BSDsed(macOS) requiressed -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}" + fiIf 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") |
There was a problem hiding this comment.
|| 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).
|
🎉 This PR is included in version 1.64.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
update-claude-code.shを改修し、Dockerfile のバージョンも自動更新するようにChanges
.devcontainer/Dockerfile: Claude Code バージョンを 2.1.33 に更新script/update-claude-code.sh:claude.ai/install.sh行のバージョンを自動更新Test plan
bash script/update-claude-code.shでスクリプトが正常に動作することを確認🤖 Generated with Claude Code
Summary by CodeRabbit