Skip to content

fix: auto-install skills on Codespaces startup - #447

Merged
keito4 merged 1 commit into
mainfrom
fix/skills-auto-install
Feb 11, 2026
Merged

fix: auto-install skills on Codespaces startup#447
keito4 merged 1 commit into
mainfrom
fix/skills-auto-install

Conversation

@keito4

@keito4 keito4 commented Feb 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Codespaces起動時にスキルの自動インストール/修復を行う postStartCommand を追加
  • install-skills.sh のskills.txtパス検索を改善(ワークスペース優先)
  • リポジトリ→スキル名のマッピングを追加し、インストール済みチェックを正確化

Background

Dockerイメージビルド時にスキルのインストールが一部失敗することがあり、Codespacesでスキルが読み込まれない問題が発生していました。

Changes

  1. .devcontainer/codespaces/devcontainer.jsonpostStartCommand を追加
  2. script/install-skills.sh を改善:
    • skills.txtのパス検索順序: 引数 > ワークスペース > ホームディレクトリ
    • 既知のリポジトリとスキル名のマッピングを追加

Test plan

  • Codespacesで起動時にスキルが自動インストールされることを確認
  • 既にインストール済みのスキルがスキップされることを確認

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Chores
    • Updated development environment configuration for improved workspace setup.
    • Enhanced skill installation script with better error handling, validation checks for prerequisites, improved file resolution logic, and enhanced tracking of installation outcomes to provide more detailed feedback.

@coderabbitai

coderabbitai Bot commented Feb 11, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR enhances the Codespaces development environment configuration and refactors the skill installation script. It adds a post-start command to the devcontainer setup and improves the script with flexible path resolution, file validation, prerequisite checks, and installation status tracking.

Changes

Cohort / File(s) Summary
Devcontainer Configuration
.devcontainer/codespaces/devcontainer.json
Added postStartCommand property to execute commands after the container starts in Codespaces environment.
Skill Installation Script
script/install-skills.sh
Refactored to support multi-branch path resolution (argument → workspace → home), added file validation and npx prerequisite checks. Enhanced loop processing to skip empty lines/comments and trim whitespace. Introduced pre-installation verification with counters for installed/skipped/failed skills and improved error handling for "already exists" scenarios.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

size/S

Poem

🐰 A script now learns to find its way,
Through paths both old and new,
With checks and counts and error grace,
The skills install on queue! ✨

🚥 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 directly and concisely summarizes the main change: adding automatic skill installation on Codespaces startup via postStartCommand configuration.
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 docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/skills-auto-install

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
script/install-skills.sh (2)

9-18: PWD may not be the workspace root when invoked via postStartCommand.

When postStartCommand runs /usr/local/script/install-skills.sh, the current working directory isn't guaranteed to be the workspace root. The ${PWD}/.claude/skills/skills.txt check on Line 12 may not resolve as expected. Consider using the Codespaces workspace path explicitly (e.g., /workspaces/${RepositoryName}/.claude/skills/skills.txt) or the CODESPACES_REPO_PATH / GITHUB_WORKSPACE env var, if available.

The /home/vscode fallback on Line 14 mitigates this, so the practical risk is low.


57-74: Hardcoded skill-name mappings are brittle and require manual maintenance.

If any upstream package changes its installed directory names, or new skills are added to a repo, this mapping silently goes stale — causing either unnecessary reinstalls every startup or incorrectly skipping new skills. Consider adding a comment noting this maintenance requirement, or querying npx skills list -g output dynamically instead of checking directory existence.


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.

@claude

claude Bot commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

PR Review: fix: auto-install skills on Codespaces startup

概要

Codespaces起動時のスキル自動インストール機能の追加と改善です。全体的に良い実装ですが、いくつかの改善点と懸念事項があります。

✅ 良い点

  1. 明確な問題解決: Dockerイメージビルド時のスキルインストール失敗を postStartCommand で修復する明確なアプローチ
  2. 柔軟な設定ファイル検索: 引数 → ワークスペース → ホームディレクトリの優先順位は合理的
  3. リポジトリとスキル名のマッピング: vercel-labs/agent-skills が複数スキルをインストールする問題への適切な対応
  4. 詳細なログ: デバッグしやすい情報量

🔴 重大な問題

1. テストカバレッジの欠如(BLOCKER)

問題: script/install-skills.sh に対するテストが存在しません。

影響: CLAUDE.mdで定義された品質基準(70%+行カバレッジ)を満たしていない可能性があります。

推奨対応:

# test/script/install-skills.bats などで以下をテスト
- skills.txt が存在しない場合の動作
- 各パス検索の優先順位(引数/ワークスペース/ホーム)
- リポジトリマッピングの正確性
- 既にインストール済みスキルのスキップ
- npx コマンドが存在しない場合のエラーハンドリング

2. ハードコードされたリポジトリマッピング(保守性問題)

問題: script/install-skills.sh:57-74 のcase文でリポジトリとスキル名を手動マッピングしています。

リスク:

  • 新しいリポジトリ追加時に手動更新が必要
  • スキル構成変更時の追従漏れ
  • 保守コストの増大

推奨対応:

# Option 1: npx skills list -g から実際のインストール済みスキル一覧を取得
installed_skills=$(npx skills list -g | grep -v "^$" | awk '{print $1}')

# Option 2: 設定ファイルでマッピング管理
# .claude/skills/mappings.json
{
  "vercel-labs/agent-skills": ["vercel-composition-patterns", "vercel-react-best-practices", ...],
  "supabase/agent-skills": ["supabase-postgres-best-practices"]
}

⚠️ 中程度の問題

3. エラーハンドリングの不整合

問題: script/install-skills.sh:99-106 で grep -qi "already|exists" によるエラー判定が不正確です。

:

# 誤検知の可能性
echo "Installation failed because the repository already exists"
# → スキップとしてカウントされるが実際は失敗

推奨対応:

# npx skills の終了コードをチェック
if npx skills add "$skill" -y -g; then
    installed=$((installed + 1))
else
    exit_code=$?
    if [[ $exit_code -eq 0 ]]; then
        skipped=$((skipped + 1))
    else
        failed=$((failed + 1))
    fi
fi

4. postStartCommand の実行パス

問題: .devcontainer/codespaces/devcontainer.json:61 で /usr/local/script/install-skills.sh を指定していますが、このパスが実際に存在するかの検証が必要です。

確認事項:

  • ghcr.io/keito4/config-base:1.62.2 イメージに /usr/local/script/install-skills.sh が含まれているか
  • または postStartCommand 実行時に ${PWD}/script/install-skills.sh を使用すべきか

5. 配列宣言の移植性

問題: script/install-skills.sh:59-74 でBash配列を使用していますが、set -euo pipefail との組み合わせで問題が発生する可能性があります。

推奨対応:

# shellcheck をCIで実行してBash特有の問題を検証
npm run shellcheck script/install-skills.sh

💡 改善提案

6. 冪等性の保証

提案: すべてのスキルが既にインストール済みの場合、スクリプトの実行時間を短縮できます。

# 早期リターン
if all_skills_installed; then
    echo "[INFO] 全スキルがインストール済みです"
    exit 0
fi

7. タイムアウト設定

提案: npx skills add の実行時間制限を設定し、ハングを防ぎます。

timeout 300 npx skills add "$skill" -y -g || handle_timeout

📋 チェックリスト(PR マージ前)

  • BLOCKER: シェルスクリプトのテストを追加(bats推奨)
  • /usr/local/script/install-skills.sh のパスを検証
  • ShellCheck でスクリプトを検証(既存のCIに含まれているか確認)
  • Test planのチェックボックスを完了
  • CI が緑であることを確認

🎯 セキュリティ考慮事項

  • ✅ 認証情報の漏洩なし
  • ✅ コマンドインジェクションのリスク低(入力は skills.txt から)
  • ⚠️ npx skills add の信頼性(外部パッケージダウンロード)

📊 品質基準との整合性

基準 状態 備考
Test Coverage 70%+ シェルスクリプトのテストが不足
Lint/Format Pass ⚠️ ShellCheck実行状況不明
Diff ≤ 400行 合計51行の変更
Linked Issue ⚠️ Issue番号が明示されていない
Conventional Commits fix: タイプで適切
Documentation PRの説明は明確

総評

機能追加の方向性は正しいですが、テストカバレッジの欠如がBLOCKERです。CLAUDE.mdの品質基準を満たすため、マージ前にシェルスクリプトのテストを追加してください。


🤖 Generated by Claude Code

@keito4
keito4 merged commit 2fc50b1 into main Feb 11, 2026
18 of 19 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.66.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions github-actions Bot added the released リリース済み label Feb 11, 2026
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