jpskill.com
🛠️ 開発・MCP コミュニティ

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本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
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
🪟 Windows (PowerShell)
$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. 1. 下の青いボタンを押して bun-expert.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → bun-expert フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

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 ファイルを自動的にロードします。順序は以下の通りです。

  1. .env
  2. .env.{NODE_ENV} (development, production, test)
  3. .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 移行チェックリスト

  1. Bun をインストールし、bun install を実行します。
  2. 既存の Node API が動作する場合は、そのまま使用します。Bun は Node との高い互換性があります。
  3. ツールを段階的に置き換えます (bun test, bun build, bun run)。
  4. コードを簡素化できる場合は、Bun ネイティブ API を採用します (Bun.serve, sql, redis, s3, Bun.$)。
  5. 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 への移行手順と互換性に関するガイダンス

信頼できるドキュメント

📜 原文 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 init generates a compatible tsconfig.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.lock is the default text lockfile format in modern Bun.
  • bun.lockb remains 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:

  1. .env
  2. .env.{NODE_ENV} (development, production, test)
  3. .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

  1. Install Bun and run bun install.
  2. Keep existing Node APIs where they work; Bun is highly Node-compatible.
  3. Replace tooling incrementally (bun test, bun build, bun run).
  4. Adopt Bun-native APIs where they simplify code (Bun.serve, sql, redis, s3, Bun.$).
  5. 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