Skip to content

feat: enhance package auto-update with Claude Code focus - #239

Merged
keito4 merged 1 commit into
mainfrom
feat/enhance-package-auto-update
Jan 1, 2026
Merged

feat: enhance package auto-update with Claude Code focus#239
keito4 merged 1 commit into
mainfrom
feat/enhance-package-auto-update

Conversation

@keito4

@keito4 keito4 commented Dec 31, 2025

Copy link
Copy Markdown
Owner

Summary

パッケージ自動更新機能を強化し、特にClaude Codeのバージョンを簡単に最新に保てるようにしました。

追加機能

🤖 Claude Code専用更新機能

  • 新しいスクリプト: script/update-claude-code.sh

    • @anthropic-ai/claude-code の最新バージョンをチェック
    • npm/global.json を自動更新
    • リリースノートURLを表示
    • CI環境では自動更新、ローカルでは確認プロンプト表示
  • npm スクリプト: npm run update:claude

    • Claude Code のみを更新する専用コマンド
    • 既存の npm run update:libs との使い分けが可能
  • Claude コマンド: /update-claude-code

    • Claude Code セッション内で対話的に更新可能
    • 更新後の差分を自動表示

📊 update-libraries.sh 改善

  • カラー出力: GREEN/YELLOW/BLUE で視覚的に改善
  • 詳細なサマリー: 更新されたパッケージの before → after を表示
  • Claude Code 強調: バージョン情報を特別に表示

🔄 GitHub Actions ワークフロー改善

  • 自動サマリー生成: 更新内容をPR本文に自動追加
  • 差分表示: npm/global.jsonpackage.json の変更を表示
  • Claude Code 情報: バージョンとリリースノートリンクを表示

📚 ドキュメント更新

  • README.md 拡充:
    • "Update All Libraries" セクション
    • "Update Claude Code Only" セクション
    • 使用方法と注意事項を明記

使用例

Claude Code のみを更新

npm run update:claude

すべてのパッケージを更新

npm run update:libs

Claude コマンドで更新

/update-claude-code

Test Plan

  • npm run update:claude の動作確認
  • カラー出力の確認
  • エラーハンドリングの確認
  • 全テストスイート通過 (101 tests passed)
  • CI での自動実行確認(次回のスケジュール実行で確認)

技術的詳細

  • jq を使用してJSON解析
  • npm view で最新バージョン取得
  • 環境変数 AUTO_UPDATECI でモード切り替え
  • エラーハンドリングとログ出力を統一

影響範囲

  • 既存の npm run update:libs の動作は変更なし
  • 新しいコマンドの追加のみ
  • 後方互換性を維持

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added automated Claude Code update capability via the update:claude command with automatic release notes
  • Documentation

    • Added guides for updating Codex and Claude tooling with version management best practices
    • Documented global version control, build consistency requirements, and commit conventions
    • Enhanced automation workflow documentation for dependency updates

✏️ Tip: You can customize this high-level summary in your review settings.

パッケージ自動更新機能を強化し、特にClaude Codeのバージョンを
簡単に最新に保てるようにしました。

## 追加機能

### Claude Code専用更新スクリプト
- script/update-claude-code.sh を追加
- @anthropic-ai/claude-code の最新バージョンをチェック
- npm/global.json を自動更新
- リリースノートURLを表示
- CI環境では自動更新、ローカルでは確認プロンプト

### npm スクリプト追加
- npm run update:claude: Claude Code専用更新
- /update-claude-code: Claude コマンドで対話的更新

### update-libraries.sh 改善
- カラー出力を追加(GREEN/YELLOW/BLUE)
- 更新されたパッケージの詳細なサマリー表示
- バージョン変更を視覚的に表示(before → after)
- Claude Codeバージョンを特別に強調表示

### GitHub Actions ワークフロー改善
- 更新サマリーの自動生成
- PR本文に詳細な変更内容を含める
- global.json と package.json の差分を表示
- Claude Codeバージョンとリリースノートリンクを表示

### ドキュメント更新
- README.md に新しいコマンドの説明を追加
- Update All Libraries vs Update Claude Code Only を明確化
- 使用方法と注意事項を記載

## 技術的詳細
- jq と npm を使用してバージョン情報を取得
- 環境変数 AUTO_UPDATE と CI でモード切り替え
- エラーハンドリングとログ出力を統一

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

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

coderabbitai Bot commented Dec 31, 2025

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR introduces automated tooling and documentation for managing library updates, specifically Claude Code versions. It adds scripts to fetch and update dependencies, enhances CI workflows with dynamic summaries, updates npm scripts, and documents version management practices across the repository.

Changes

Cohort / File(s) Summary
Documentation & Configuration
.claude/commands/update-claude-code.md, README.md
New command documentation for Claude Code update tooling; README enhanced with sections on library update workflows, version management practices, and commit requirements for release-critical files.
Automation Scripts
script/update-claude-code.sh, script/update-libraries.sh
New script to automate Claude Code version updates via npm registry queries and jq-based manifest modifications; existing script enhanced with colored logging utilities, package tracking, and post-run Claude Code version display.
Package Configuration & Scripts
package.json
Added update:claude npm script entry pointing to the new update automation script.
CI/CD Workflow
.github/workflows/update-libraries.yml
New step to dynamically generate update summaries from package diffs (global.json, package.json, package-lock.json); PR creation updated to reference dynamic summary instead of static text.

Sequence Diagram

sequenceDiagram
    participant User/CI as User or CI System
    participant Script as update-claude-code.sh
    participant npmReg as npm Registry
    participant Manifest as npm/global.json
    participant Git as Git/PR

    User/CI->>Script: npm run update:claude
    Script->>Manifest: Read current version
    Script->>npmReg: Query latest `@anthropic-ai/claude-code`
    npmReg-->>Script: Return latest version
    
    alt Version is newer
        Script->>Manifest: Update version via jq
        Manifest-->>Script: Confirm update
        Script->>User/CI: Display release notes URL
        
        rect rgba(76, 175, 80, 0.2)
            Note over User/CI,Script: In CI: Auto-commit
            User/CI->>Git: Create/push commit
        end
        
        rect rgba(33, 150, 243, 0.2)
            Note over User/CI,Script: Interactive: Prompt user
            User/CI-->>User/CI: User commits locally
        end
    else Version is current
        Script->>User/CI: Report: All packages up to date
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

released

Poem

A rabbit hops through version streams,
With scripts that chase the latest dreams,
Automation's gentle, steady care—
Updates flow beyond compare! 🐰✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: enhancing package auto-update functionality with a specific focus on Claude Code. It directly reflects the core objective of adding dedicated Claude Code update capabilities alongside existing library updates.
✨ Finishing touches
  • 📝 Generate docstrings

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.


- name: Generate update summary
id: summary
run: |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:32:6: Double quote to prevent globbing and word splitting [shellcheck]

@claude

claude Bot commented Dec 31, 2025

Copy link
Copy Markdown
Contributor

PR Review: Claude Code Auto-Update Enhancement

PR #239 の品質レビューを実施しました。全体的に非常に高品質な実装で、CLAUDE.md のガイドラインに準拠しています。


✅ 高評価ポイント

1. コード品質・設計

  • 単一責任の原則: update-claude-code.sh が Claude Code のみを扱い、update-libraries.sh とクリアに分離
  • 堅牢なエラーハンドリング: set -euo pipefail による厳格なエラー処理
  • カラー出力: 視認性の高い GREEN/YELLOW/BLUE/RED の出力で UX 向上
  • 環境依存性チェック: jq/npm の存在確認を事前実施

2. セキュリティ・ベストプラクティス

  • 一時ファイル処理: mktemp を使用した安全な一時ファイル生成 (script/update-claude-code.sh:83)
  • 入力検証: jq での JSON 解析前にファイル存在確認 (script/update-claude-code.sh:43)
  • CI/ローカル分離: CI および AUTO_UPDATE 環境変数による動作制御 (script/update-claude-code.sh:72)

3. ドキュメント品質

  • README.md の充実: Update All Libraries と Update Claude Code Only を明確に区別
  • Claude コマンド: .claude/commands/update-claude-code.md で使用方法を完備
  • コミットメッセージ規約: 適切に feat: タイプを使用し、semantic-release と整合

4. CI/CD 統合

  • GitHub Actions 改善: 更新サマリー生成機能 (.github/workflows/update-libraries.yml:31-65)
  • 差分表示: package.json と npm/global.json の変更を自動抽出
  • リリースノート連携: Claude Code のバージョン情報とリリースノート URL を PR に自動追加

5. テスト

  • ✅ 101 tests passed - 既存テストスイート全通過
  • ✅ Lint 通過 - コーディング規約遵守

🔍 改善提案

1. テストカバレッジ不足 ⚠️ 重要

現状: 新規追加された bash スクリプトに対するテストが存在しない

リスク:

  • script/update-claude-code.sh:49 での current_version 抽出失敗時のハンドリング未検証
  • script/update-claude-code.sh:84-86 での jq 更新処理の冪等性未確認
  • CI 環境での自動更新フローの統合テスト不在

推奨対応: bash スクリプトに対する bats や shunit2 によるテスト追加を推奨

TDD 基準との整合: CLAUDE.md で要求される 70%+ 行カバレッジを満たすため


2. Claude コマンドのコミットメッセージ

箇所: .claude/commands/update-claude-code.md:47

現状: git commit -m 'chore: update Claude Code to latest version'

問題: CLAUDE.md:12 では、npm/global.json を変更する場合は release-triggering type (feat/fix/perf/revert/docs) の使用が必須。chore: は commitlint でブロックされる

推奨修正: git commit -m 'fix: update Claude Code to latest version' または feat:


3. セキュリティ強化

箇所: script/update-claude-code.sh:54

潜在的リスク: npm registry への接続が MITM 攻撃を受けた場合、悪意のあるバージョン番号が取得される可能性

推奨: バージョン形式の検証を追加(semver 形式チェック)


📊 品質メトリクス

総合評価: ⭐⭐⭐⭐☆ (4.2/5.0)

  • コード品質: ⭐⭐⭐⭐⭐ (5/5)
  • セキュリティ: ⭐⭐⭐⭐☆ (4/5)
  • ドキュメント: ⭐⭐⭐⭐⭐ (5/5)
  • テストカバレッジ: ⭐⭐⭐☆☆ (3/5)
  • CI/CD 統合: ⭐⭐⭐⭐⭐ (5/5)
  • パフォーマンス: ⭐⭐⭐⭐☆ (4/5)

🎯 マージ前推奨アクション

Critical (マージ前に対応推奨)

  1. ✅ コミットメッセージを chore:feat: に修正 (.claude/commands/update-claude-code.md:47)

High (次回イテレーションで対応)

  1. bash スクリプトの自動テスト追加 (TDD 基準達成)
  2. バージョン形式の検証追加 (セキュリティ強化)

🤖 まとめ

非常に高品質な実装です。以下の点で特に優れています:

機能分離: Claude Code 専用更新と全体更新を明確に分離
UX 向上: カラー出力、詳細なサマリー、リリースノート連携
自動化: GitHub Actions での週次自動更新と PR 生成
ドキュメント: 使用方法と注意事項が完備

Critical な修正事項はコミットメッセージタイプのみで、それ以外は将来的な改善提案です。修正後にマージ可能と判断します。


🤖 Generated with Claude Code

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: 0

🧹 Nitpick comments (2)
script/update-claude-code.sh (1)

16-19: Consider unifying logging format across scripts.

The logging functions in this script use [INFO], [SUCCESS], [WARN], [ERROR] prefixes, while script/update-libraries.sh uses symbols like and . For consistency and maintainability across the codebase, consider adopting the same format.

🔎 Proposed fix to align with update-libraries.sh format
-log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
-log_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
-log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
-log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
+log_info() { printf "${BLUE}==> %s${NC}\n" "$1"; }
+log_success() { printf "${GREEN}✓ %s${NC}\n" "$1"; }
+log_warn() { printf "${YELLOW}⚠ %s${NC}\n" "$1"; }
+log_error() { printf "${RED}✗ %s${NC}\n" "$1"; }
.github/workflows/update-libraries.yml (1)

31-65: Dynamic summary generation works well.

The summary generation logic correctly handles different file changes and conditionally includes Claude Code version information. The use of || echo fallbacks prevents grep failures from breaking the workflow.

Optional improvement for package.json diff filtering:

Line 51's grep pattern '^\+.*".*":|^-.*".*":' may be overly broad and could match non-dependency lines. Consider narrowing it to focus on the devDependencies section if you want more precise output in the PR summary:

git diff package.json | grep -A999 '"devDependencies"' | grep -E '^\+.*".*":|^-.*".*":' | grep -v '^\+\+\+\|^---' || echo "No changes"

However, the current implementation is acceptable and provides useful information.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9196e41 and 1259c2b.

📒 Files selected for processing (6)
  • .claude/commands/update-claude-code.md
  • .github/workflows/update-libraries.yml
  • README.md
  • package.json
  • script/update-claude-code.sh
  • script/update-libraries.sh
🧰 Additional context used
📓 Path-based instructions (2)
.github/workflows/update-libraries.yml

📄 CodeRabbit inference engine (CLAUDE.md)

Execute npm run update:libs on schedule and open pull requests when dependencies or Codex/Claude tooling changes in .github/workflows/update-libraries.yml

Files:

  • .github/workflows/update-libraries.yml
{.codex/**,.devcontainer/codex*,package*.json,npm/global.json}

📄 CodeRabbit inference engine (CLAUDE.md)

Use Conventional Commits format with release-triggering types (feat/fix/perf/revert/docs) for commits touching .codex/**, .devcontainer/codex*, package*.json, or npm/global.json

Files:

  • package.json
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/update-libraries.yml : Execute npm run update:libs on schedule and open pull requests when dependencies or Codex/Claude tooling changes in .github/workflows/update-libraries.yml
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/claude.yml : Trigger automatic AI assistance on claude mentions in issues, PRs, and comments using .github/workflows/claude.yml
Learnt from: CR
Repo: keito4/config PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-09T08:39:14.049Z
Learning: Follow development quality standards defined in `CLAUDE.md` when using Claude Code for development assistance
📚 Learning: 2025-12-01T03:45:17.253Z
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/update-libraries.yml : Execute npm run update:libs on schedule and open pull requests when dependencies or Codex/Claude tooling changes in .github/workflows/update-libraries.yml

Applied to files:

  • script/update-claude-code.sh
  • .github/workflows/update-libraries.yml
  • .claude/commands/update-claude-code.md
  • script/update-libraries.sh
  • package.json
  • README.md
📚 Learning: 2025-12-01T03:45:17.253Z
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/claude.yml : Trigger automatic AI assistance on claude mentions in issues, PRs, and comments using .github/workflows/claude.yml

Applied to files:

  • script/update-claude-code.sh
  • .claude/commands/update-claude-code.md
  • package.json
📚 Learning: 2025-12-09T08:39:14.049Z
Learnt from: CR
Repo: keito4/config PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-09T08:39:14.049Z
Learning: Follow development quality standards defined in `CLAUDE.md` when using Claude Code for development assistance

Applied to files:

  • script/update-claude-code.sh
  • script/update-libraries.sh
  • README.md
📚 Learning: 2025-12-01T03:45:17.253Z
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to {.codex/**,.devcontainer/codex*,package*.json,npm/global.json} : Use Conventional Commits format with release-triggering types (feat/fix/perf/revert/docs) for commits touching .codex/**, .devcontainer/codex*, package*.json, or npm/global.json

Applied to files:

  • README.md
🧬 Code graph analysis (2)
script/update-claude-code.sh (1)
script/update-libraries.sh (2)
  • log_success (18-20)
  • log_warn (22-24)
script/update-libraries.sh (1)
script/update-claude-code.sh (2)
  • log_warn (18-18)
  • log_success (17-17)
🪛 LanguageTool
README.md

[uncategorized] ~244-~244: The official name of this software platform is spelled with a capital “H”.
Context: ...r Node.js releases (semantic-release, @semantic-release/github) are excluded by default. Override the...

(GITHUB)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: claude-review
🔇 Additional comments (17)
script/update-claude-code.sh (5)

21-26: LGTM!

Path resolution logic correctly determines the script directory and project root using standard Bash idioms.


30-46: LGTM!

Dependency checks are comprehensive with clear error messages and appropriate exit codes. The installation hint for jq is helpful.


48-69: LGTM!

Version retrieval and comparison logic is correct. The simple string equality check is sufficient since the script only needs to detect differences, not determine ordering. The npm registry always returns the absolute latest version, so any difference indicates an update is needed.


71-79: LGTM!

User confirmation logic correctly handles CI and AUTO_UPDATE modes. The safe default (cancel on non-Y) and single-character input provide good user experience.


81-93: LGTM!

The JSON update uses proper atomic write pattern with a temporary file. The jq command correctly updates the specific package version while preserving the rest of the file structure. Success messages and release notes URL provide good feedback.

package.json (1)

22-22: LGTM!

The new update:claude script follows the existing naming convention and correctly references the newly added update script. This change aligns with the coding guidelines requirement for release-triggering commit types when modifying package.json.

.claude/commands/update-claude-code.md (3)

1-17: LGTM!

The documentation clearly describes the purpose, execution steps, and usage of the update command. The structure is well-organized and aligns with the actual script implementation.


20-51: LGTM!

The implementation example correctly demonstrates how to invoke the update script non-interactively. The path resolution, environment variable setup, and post-update git diff check are all appropriate. The manual commit instructions provide clear guidance for users.


53-57: LGTM!

The notes section clearly documents important constraints and behavior differences between local and CI environments, helping users understand when manual intervention is required.

script/update-libraries.sh (3)

5-24: LGTM!

The colored logging functions improve readability and provide visual feedback. The use of symbols (=>, ✓, ⚠) and printf with format strings is consistent and maintainable.


49-78: LGTM - Great improvement!

The package tracking logic significantly improves visibility by collecting and displaying all updates in a summary. The fallback pattern for version retrieval (|| echo "$current_version") is good defensive coding that prevents failures when npm view encounters issues.


89-95: LGTM!

The Claude Code version highlight aligns with the PR's objective to enhance Claude Code update visibility. The conditional check ensures graceful handling when jq or the manifest file is unavailable.

README.md (4)

240-246: LGTM!

The documentation accurately describes the library update workflow, including the exclusion mechanism and automated weekly PR process. Clear and helpful for users.


247-253: LGTM!

The documentation clearly describes the Claude Code-specific update workflow and its relationship to the general library update process. The mention of both the npm script and Claude command provides complete usage guidance.


254-256: LGTM!

The commit requirements section correctly documents the Conventional Commits enforcement for release-critical files, aligning with the coding guidelines and ensuring proper semantic-release automation.


258-263: LGTM!

This section clearly documents the architectural decision to use npm/global.json as the single source of truth for CLI versions. The explanation of DevContainer integration and rebuild requirements helps users maintain environment consistency.

.github/workflows/update-libraries.yml (1)

67-87: LGTM!

The PR body template effectively incorporates the dynamically generated summary and provides clear context about what gets updated. The workflow file link adds transparency and helps maintainers understand the automation.

@keito4
keito4 merged commit b2343c6 into main Jan 1, 2026
15 checks passed
@github-actions

github-actions Bot commented Jan 1, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.32.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