bun-expert
Bunランタイムを使ったJavaScript/TypeScript開発を支援し、プロジェクト構築、パッケージ管理、HTTPサーバー構築、テスト、Node.jsからの移行など、Bun特有の課題解決をサポートするSkill。
📜 元の英語説明(参考)
Expert guidance for JavaScript/TypeScript development with the Bun runtime. Covers project setup, package management, HTTP servers, built-in APIs, testing, bundling, and migration from Node.js. Use when starting Bun projects, using Bun APIs (Bun.serve, sql/SQL, s3, redis, Bun.$), migrating from Node.js, or troubleshooting Bun-specific behavior.
🇯🇵 日本人クリエイター向け解説
Bunランタイムを使ったJavaScript/TypeScript開発を支援し、プロジェクト構築、パッケージ管理、HTTPサーバー構築、テスト、Node.jsからの移行など、Bun特有の課題解決をサポートするSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o bun-expert.zip https://jpskill.com/download/8867.zip && unzip -o bun-expert.zip && rm bun-expert.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/8867.zip -OutFile "$d\bun-expert.zip"; Expand-Archive "$d\bun-expert.zip" -DestinationPath $d -Force; ri "$d\bun-expert.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
bun-expert.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
bun-expertフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Bun ランタイム開発ガイド
このスキルは、意図的に Bun の公式ドキュメントに基づいています。Bun は動きが速いため、ハードコードされたリリーススケジュールやベンチマークの主張よりも、最新のドキュメントを優先してください。
プロジェクトのセットアップ
新しいプロジェクトの初期化
bun init # インタラクティブなセットアップ (package.json + tsconfig.json)
bun init -y # デフォルトを受け入れる
bun create <template> <dir> # テンプレートからスキャフォールド
TypeScript に関する注意点
- Bun は TypeScript を直接実行します。
bun initは互換性のあるtsconfig.jsonを生成します。- エディタやツールチェーンが必要とする場合にのみ、追加の型定義パッケージを追加してください。
パッケージ管理
必須コマンド
bun install
bun add <pkg>
bun add -d <pkg>
bun add -g <pkg>
bun remove <pkg>
bun update
bunx <pkg>
ロックファイル
bun.lockは、最新の Bun におけるデフォルトのテキスト形式のロックファイルです。bun.lockbは、互換性のために引き続きサポートされています。- テキスト形式のロックファイルを強制的に出力する:
bun install --save-text-lockfile
診断とセキュリティ
bun why <pkg>
bun audit
bun list
bun pm migrate
Monorepo カタログ
Bun は、ワークスペースのルートにおける依存関係カタログをサポートしています。
{
"workspaces": {
"packages": ["packages/*"],
"catalog": {
"react": "^19.0.0",
"typescript": "^5.7.0"
}
}
}
パッケージからの参照:
{
"dependencies": {
"react": "catalog:"
}
}
コードの実行
bun index.ts
bun run start
bun --watch index.ts
bun --hot index.ts
環境変数
Bun は .env ファイルを自動的にロードします。順序は以下の通りです。
.env.env.{NODE_ENV}(development,production,test).env.local
const apiKey = process.env.API_KEY;
const bunApiKey = Bun.env.API_KEY;
HTML エントリーポイント (設定不要)
bun --hot index.html
bun --watch index.html
HTTP サーバー
Bun は Bun.serve() を使用したルートベースのサーバーをサポートしています。
Bun.serve({
port: 3000,
routes: {
"/": new Response("Hello"),
"/api/users/:id": (req) => Response.json({ id: req.params.id }),
"/api/posts": {
GET: () => Response.json({ posts: [] }),
POST: async (req) => Response.json(await req.json(), { status: 201 }),
},
},
fetch() {
return new Response("Not Found", { status: 404 });
},
});
組み込み API マップ
| 必要 | Bun API |
|---|---|
| HTTP サーバー + WebSockets | Bun.serve() |
| SQL データベース | sql, SQL, Bun.sql, Bun.SQL |
| S3 互換ストレージ | s3, S3Client |
| Redis | redis, RedisClient |
| シェルスクリプト | Bun.$ / $ |
| ローカルファイル | Bun.file, Bun.write |
| SQLite (組み込み) | bun:sqlite |
| パスワードハッシュ | Bun.password |
テストとバンドル
テストランナー (bun test)
bun test
bun test --watch
bun test --test-name-pattern "auth"
bun test --bail
bun test --coverage
bun test --coverage-reporter text
バンドル
bun build ./src/index.ts --outdir ./dist
bun build --target=bun ./src/server.ts --outfile ./dist/server.js
bun build --compile ./src/cli.ts --outfile ./dist/my-cli
Node.js 移行チェックリスト
- Bun をインストールし、
bun installを実行します。 - 既存の Node API が動作する場合は、そのまま使用します。Bun は Node との高い互換性があります。
- ツールを段階的に置き換えます (
bun test,bun build,bun run)。 - コードを簡素化できる場合は、Bun ネイティブ API を採用します (
Bun.serve,sql,redis,s3,Bun.$)。 - Node 固有のフォールバックを削除する前に、CI で Bun 上で完全なテストを実行します。
深掘りリファレンス
| リファレンス | 内容 |
|---|---|
| references/builtin-apis.md | Bun.serve, SQL, S3, Redis, シェル、ファイルシステム、暗号/パスワードユーティリティ |
| references/testing-and-bundling.md | bun test の使用法、モックのパターン、bun build の CLI と API |
| references/node-migration.md | 実践的な Node から Bun への移行手順と互換性に関するガイダンス |
信頼できるドキュメント
- https://bun.com/docs
- https://bun.com/docs/cli/test
- https://bun.com/docs/cli/pm
- https://bun.com/docs/runtime/http/routing
- https://bun.com/docs/runtime/env
- https://bun.com/docs/runtime/sql
- https://bun.com/docs/runtime/s3
- https://bun.com/docs/runtime/redis
- https://bun.com/docs/guides/ecosystem/migrate-from-nodejs
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Bun Runtime Development Guide
This skill is intentionally grounded in official Bun documentation. Bun moves quickly, so prefer current docs over hard-coded release timelines or benchmark claims.
Project Setup
Initialize a new project
bun init # Interactive setup (package.json + tsconfig.json)
bun init -y # Accept defaults
bun create <template> <dir> # Scaffold from a template
TypeScript notes
- Bun runs TypeScript directly.
bun initgenerates a compatibletsconfig.json.- Add extra typing packages only when your editor/toolchain requires them.
Package Management
Essential commands
bun install
bun add <pkg>
bun add -d <pkg>
bun add -g <pkg>
bun remove <pkg>
bun update
bunx <pkg>
Lockfile
bun.lockis the default text lockfile format in modern Bun.bun.lockbremains supported for compatibility.- Force text lockfile output:
bun install --save-text-lockfile
Diagnostics and security
bun why <pkg>
bun audit
bun list
bun pm migrate
Monorepo catalogs
Bun supports dependency catalogs in workspace roots:
{
"workspaces": {
"packages": ["packages/*"],
"catalog": {
"react": "^19.0.0",
"typescript": "^5.7.0"
}
}
}
Reference from packages:
{
"dependencies": {
"react": "catalog:"
}
}
Running Code
bun index.ts
bun run start
bun --watch index.ts
bun --hot index.ts
Environment variables
Bun auto-loads .env files. Order is:
.env.env.{NODE_ENV}(development,production,test).env.local
const apiKey = process.env.API_KEY;
const bunApiKey = Bun.env.API_KEY;
HTML entrypoints (zero-config)
bun --hot index.html
bun --watch index.html
HTTP Server
Bun supports route-based servers with Bun.serve().
Bun.serve({
port: 3000,
routes: {
"/": new Response("Hello"),
"/api/users/:id": (req) => Response.json({ id: req.params.id }),
"/api/posts": {
GET: () => Response.json({ posts: [] }),
POST: async (req) => Response.json(await req.json(), { status: 201 }),
},
},
fetch() {
return new Response("Not Found", { status: 404 });
},
});
Built-in API Map
| Need | Bun API |
|---|---|
| HTTP server + WebSockets | Bun.serve() |
| SQL databases | sql, SQL, Bun.sql, Bun.SQL |
| S3-compatible storage | s3, S3Client |
| Redis | redis, RedisClient |
| Shell scripting | Bun.$ / $ |
| Local files | Bun.file, Bun.write |
| SQLite (embedded) | bun:sqlite |
| Password hashing | Bun.password |
Testing and Bundling
Test runner (bun test)
bun test
bun test --watch
bun test --test-name-pattern "auth"
bun test --bail
bun test --coverage
bun test --coverage-reporter text
Bundling
bun build ./src/index.ts --outdir ./dist
bun build --target=bun ./src/server.ts --outfile ./dist/server.js
bun build --compile ./src/cli.ts --outfile ./dist/my-cli
Node.js Migration Checklist
- Install Bun and run
bun install. - Keep existing Node APIs where they work; Bun is highly Node-compatible.
- Replace tooling incrementally (
bun test,bun build,bun run). - Adopt Bun-native APIs where they simplify code (
Bun.serve,sql,redis,s3,Bun.$). - Run your full tests in CI on Bun before removing Node-specific fallbacks.
Deep-Dive References
| Reference | Contents |
|---|---|
| references/builtin-apis.md | Bun.serve, SQL, S3, Redis, shell, filesystem, crypto/password utilities |
| references/testing-and-bundling.md | bun test usage, mocking patterns, bun build CLI and API |
| references/node-migration.md | Practical Node-to-Bun migration steps and compatibility guidance |
Authoritative Docs
- https://bun.com/docs
- https://bun.com/docs/cli/test
- https://bun.com/docs/cli/pm
- https://bun.com/docs/runtime/http/routing
- https://bun.com/docs/runtime/env
- https://bun.com/docs/runtime/sql
- https://bun.com/docs/runtime/s3
- https://bun.com/docs/runtime/redis
- https://bun.com/docs/guides/ecosystem/migrate-from-nodejs