Skip to content

feat: DevContainerビルド時のClaudeプラグイン自動インストール機能を追加 - #180

Merged
keito4 merged 1 commit into
mainfrom
feat/add-claude-plugin-auto-install
Dec 25, 2025
Merged

feat: DevContainerビルド時のClaudeプラグイン自動インストール機能を追加#180
keito4 merged 1 commit into
mainfrom
feat/add-claude-plugin-auto-install

Conversation

@keito4

@keito4 keito4 commented Dec 25, 2025

Copy link
Copy Markdown
Owner

Summary

DevContainer起動時にClaudeプラグインを自動的にインストールする機能を実装しました。

主な変更

1. script/setup-claude.sh の簡素化

  • 複雑な設定同期機能を削除し、プラグインインストールに特化
  • マーケットプレイスの自動初期化を追加
  • エラーハンドリングとログ出力を改善
  • ユーザースコープでのプラグインインストールに統一

2. .claude/plugins/plugins.txt の更新

  • デフォルトプラグインリストを9個に絞り込み
  • 基本プラグイン: vercel, commit-commands, hookify, plugin-dev, frontend-design
  • プロジェクト固有: supabase, typescript-lsp
  • テンプレート: nextjs-vercel-pro, supabase-toolkit

3. DevContainerビルドの改善

  • Dockerfile: setup-claude.sh を /tmp にコピー
  • devcontainer.json: postCreateCommand で /tmp/setup-claude.sh を実行

Test plan

  • ローカルでDevContainerをビルド・起動
  • プラグインが正常にインストールされることを確認
  • 既存プラグインがある場合スキップされることを確認
  • インストール失敗時のエラーハンドリングを確認
  • CI/CDでイメージビルドが成功することを確認
  • 新バージョンのイメージが公開されることを確認

期待される動作

DevContainer起動時に以下のログが表示され、プラグインが自動インストールされます:

[INFO] Claude Code プラグインセットアップを開始します...
[INFO] マーケットプレイスを初期化中...
[INFO] プラグインをユーザースコープでインストール中...
[INFO]   インストール中: vercel@claude-plugins-official
[SUCCESS]   完了: vercel@claude-plugins-official
...
[INFO] プラグイン: 9 インストール完了、0 スキップ、0 失敗
[SUCCESS] Claude Code プラグインセットアップが完了しました!

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated development environment plugin configuration and setup process
    • Streamlined Claude plugin initialization with simplified installation flow
    • Modified plugin list to include project-specific utilities and templates

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

DevContainer起動時にClaudeプラグインを自動的にインストールする機能を実装。

## 変更内容

- `script/setup-claude.sh`: プラグイン自動インストールスクリプトを簡素化
  - マーケットプレイスの自動初期化を追加
  - エラーハンドリングとログ出力を改善
  - ユーザースコープでのプラグインインストールに統一

- `.claude/plugins/plugins.txt`: デフォルトプラグインリストを更新
  - 基本プラグイン7個を定義(vercel, commit-commands, hookify等)
  - claude-plugins-official と claude-code-templates から選定

- `.devcontainer/Dockerfile`: setup-claude.sh を /tmp にコピー
  - ビルド時にスクリプトをイメージに含める

- `.devcontainer/devcontainer.json`: postCreateCommand を修正
  - /tmp/setup-claude.sh を実行してプラグインをインストール

## 期待される動作

DevContainer起動時に以下のプラグインが自動インストールされます:
- vercel, commit-commands, hookify, plugin-dev, frontend-design
- supabase, typescript-lsp (プロジェクト固有)
- nextjs-vercel-pro, supabase-toolkit (テンプレート)

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

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

coderabbitai Bot commented Dec 25, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The PR refactors the Claude plugin installation flow by moving the setup script to /tmp, simplifying the installation logic to iterate through plugins.txt, adding marketplace initialization, and consolidating plugin management with updated plugin configuration.

Changes

Cohort / File(s) Summary
Plugin Configuration
.claude/plugins/plugins.txt
Removed multiple official/workflow plugins; added project-specific supabase@claude-plugins-official and typescript-lsp@claude-plugins-official; added template plugins (nextjs-vercel-pro@claude-code-templates, supabase-toolkit@claude-code-templates); updated comments to reflect user-scope installation during devcontainer startup.
DevContainer Setup
.devcontainer/Dockerfile, .devcontainer/devcontainer.json
Added COPY instruction for script/setup-claude.sh/tmp/setup-claude.sh; updated postCreateCommand to invoke /tmp/setup-claude.sh instead of ./script/setup-claude.sh.
Installation Script
script/setup-claude.sh
Removed multi-option CLI parsing, directory sync, and file copying logic; added Claude CLI and plugins.txt existence checks; added marketplace initialization; streamlined to line-by-line plugin iteration from plugins.txt with per-plugin installation in user scope; simplified success/failure tracking with counters.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

released

Poem

🐰 Hoppy refactoring day,
Plugins hop in the marketplace way,
Setup moved to /tmp so neat,
Installation flow's now complete—
DevContainer dreams come true!

✨ 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/add-claude-plugin-auto-install

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0447a9d and cbe53e6.

📒 Files selected for processing (4)
  • .claude/plugins/plugins.txt
  • .devcontainer/Dockerfile
  • .devcontainer/devcontainer.json
  • script/setup-claude.sh

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 merged commit af20777 into main Dec 25, 2025
3 of 4 checks passed
@keito4
keito4 deleted the feat/add-claude-plugin-auto-install branch December 25, 2025 08:34
@claude

claude Bot commented Dec 25, 2025

Copy link
Copy Markdown
Contributor

PR Review: DevContainerビルド時のClaudeプラグイン自動インストール機能

📋 概要

DevContainer起動時にClaudeプラグインを自動的にインストールする機能の実装です。script/setup-claude.sh を大幅に簡素化し、プラグインインストールに特化させる変更が行われています。


✅ 良い点

1. コードの簡素化

  • 257行 → 80行(約70%削減)と大幅にスリム化
  • 複雑な設定同期機能を削除し、単一責任の原則に沿った設計
  • 可読性とメンテナンス性が向上

2. エラーハンドリングの改善

  • script/setup-claude.sh:63-76 でインストール結果を詳細に分類(成功/既存/失敗)
  • エラー出力をキャプチャして表示(73行目: head -3 で適切に制限)
  • || true による graceful degradation(devcontainer.json:46)

3. 適切なスコープ管理

  • ユーザースコープでのプラグインインストールに統一
  • マーケットプレイスの自動初期化(40-43行目)

⚠️ 改善提案

1. テストカバレッジの不足 🔴 Critical

問題点:

  • CLAUDE.md で要求される TDD プラクティス(70%+ 行カバレッジ)が満たされていない
  • PR の Test plan で「CI/CDでイメージビルドが成功することを確認」が未完了(チェックボックス未チェック)
  • Bashスクリプトのユニットテストが存在しない

推奨対応:

  • test/setup-claude.test.sh を追加してテストケースを実装
  • Claude CLI が存在しない場合の動作テスト
  • plugins.txt が存在しない場合の動作テスト
  • 既にインストール済みプラグインの検出テスト
  • マーケットプレイス初期化の冪等性テスト
  • エラー時のカウンター更新テスト

根拠:

  • CLAUDE.md 2.1節: 全リポジトリ 70%+ 行カバレッジ、クリティカルパスは 100%
  • DevContainer起動はクリティカルパスに該当

2. セキュリティ考慮事項 🟡 Medium

問題点 (script/setup-claude.sh:40-43):

公式以外のマーケットプレイス(wshobson, davila7)を自動追加している点について:

  • リポジトリの信頼性検証が行われていない
  • 2>/dev/null でエラーが隠蔽され、セキュリティリスクの検出が困難

推奨対応:

  1. 公式以外のマーケットプレイスは明示的なユーザー承認を必要とする
  2. または、README/ドキュメントで使用するマーケットプレイスのセキュリティリスクを明記
  3. エラーログを適切に記録(完全に隠蔽しない)

3. プラグインリストの妥当性 🟡 Medium

問題点 (.claude/plugins/plugins.txt):

  • 17個 → 9個に削減されたが、削除基準が不明確
  • 特に github@claude-plugins-official の削除はGitHub連携機能に影響する可能性
  • context7@claude-plugins-official の削除理由が不明

推奨対応:

  • PR本文またはコミットメッセージで削除プラグインの選定基準を説明
  • 削除されたプラグインの機能が他で補完されるか確認

4. postCreateCommand のチェーン長 🟢 Low

問題点 (devcontainer.json:46):

6つのコマンドを && でチェーンしており:

  • 可読性が低く、デバッグが困難
  • どのステップで失敗したか特定しにくい

推奨対応:

  • スクリプトファイルに切り出すことを検討(例: /tmp/post-create.sh)
  • または、各ステップにログ出力を追加

5. Dockerfile のレイヤー最適化 🟢 Low

問題点 (.devcontainer/Dockerfile:80):

install-claude-plugins.sh と setup-claude.sh が別レイヤーになっており、これらを統合することでイメージサイズを削減可能


🔍 コード品質

Bashスクリプトのベストプラクティス ✅

  • set -euo pipefail の使用(7行目)
  • 変数のクォート処理が適切
  • カラー出力による視認性向上
  • 関数の適切な命名(log_info, log_success, log_warn)

潜在的なバグ

script/setup-claude.sh:56:

xargs の使用は空白を含むプラグイン名で問題が発生する可能性があります。より安全な実装として sed の使用を検討してください。


📊 パフォーマンス

想定される改善点 ✅

  • プラグイン数が17 → 9に削減され、インストール時間が短縮
  • マーケットプレイスの初期化が冪等(既に追加済みの場合はスキップ)

潜在的なボトルネック

  • プラグインインストールが逐次実行(並列化の余地あり)
  • ただし、Claude CLIの並列実行安全性が不明のため慎重な判断が必要

🎯 CLAUDE.md 準拠チェック

項目 状態 詳細
TDD (70%+ カバレッジ) Bashスクリプトのテストが存在しない
Static Quality Gates ⚠️ ShellCheck などの静的解析ツール未使用
Git Workflow Conventional Commits に準拠
CI/CD パイプライン ⚠️ Test plan の一部が未完了
セキュリティ配慮 ⚠️ 非公式マーケットプレイスのリスク評価不足

🚀 次のステップ

マージ前に対応すべき項目(Must)

  1. テストカバレッジの追加

    • Bashスクリプトの基本的なテストケースを追加
    • CI/CD でのイメージビルド成功を確認
  2. セキュリティドキュメントの追加

    • 使用するマーケットプレイスのリスク評価を README に記載
    • または公式マーケットプレイスのみに制限

マージ後に検討すべき項目(Should)

  1. ShellCheck の導入と CI への統合
  2. postCreateCommand のスクリプト化
  3. プラグインの並列インストールの検討
  4. プラグイン削除基準のドキュメント化

📝 総評

全体的な評価: 🟡 条件付き承認推奨

コードの簡素化とエラーハンドリングの改善は素晴らしいですが、CLAUDE.md で要求されるテスト基準を満たしていない点が懸念事項です。特に DevContainer の起動はクリティカルパスであり、確実な動作保証が必要です。

推奨アクション:

  1. 最低限の統合テスト(実際のDevContainerビルドテスト)を CI で実行
  2. セキュリティドキュメントの追加
  3. 上記対応後にマージ

コードの方向性は正しく、実装品質も高いため、テストとセキュリティ文書の追加で十分に本番投入可能な品質になると判断します。


🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

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