Communitygithub.com

Bun 技能

協助使用 Bun 作為一站式 JavaScript/TypeScript 執行環境、套件管理器、打包工具和測試執行器。適用於建置 HTTP 伺服器、管理套件、執行測試或從 Node.js 遷移。觸發關鍵字:bun, bun serve, bun install, bun test, bun build, javascript runtime, bun runtime。

Bun 技能 是什麼?

這個技能專為 AI 代理(如 Claude Code、Cursor 或 Codex)設計,提供操作 Bun——一款將 Node.js、npm、webpack 和 Jest 整合為單一二進位檔案的 JavaScript/TypeScript 執行環境——所需的具體知識與指令。Bun 能在一個工具中處理伺服器、套件、打包與測試,適合建立高效能 HTTP 伺服器、管理 npm 類型的套件、執行 Jest 相容的測試,以及從 Node.js 遷移專案。該技能支援所有使用 Bun 的平台,強調利用 `Bun.serve()` 達到超過 100K req/s 的效能、使用 `bun install` 進行更快速的套件安裝、採用 `bun test` 進行相容測試,以及使用 `Bun.build()` 進行打包。透過專注於 Bun 的原生 API(包括 `Bun.file()`、`bun:sqlite` 和 `Bun.password`)來替代常見的 npm 套件,該技能有助於建立依賴更少、速度更快的應用程式。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/TerminalSkills/skills/tree/HEAD/skills/bun

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Bun

總覽

Bun 是一個一站式的 JavaScript/TypeScript 執行環境,將 Node.js、npm、webpack 和 Jest 整合為單一二進位檔案。它提供原生 TypeScript 支援、高效能的 HTTP 伺服器 (Bun.serve())、快速的套件管理器、打包工具,以及與 Jest 相容的測試執行器,效能大幅提升。

使用說明

  • 建立 HTTP 伺服器時,使用 Bun.serve(),它可處理 100K+ req/s,並內建 WebSocket 支援、TLS 和串流回應。
  • 管理套件時,使用 bun install(比 npm 快 10-30 倍)、bun add、bun remove,並優先使用 bun.lock(文字格式)以獲得可讀的 git diff。
  • 打包時,使用 Bun.build() 搭配適當的目標 ("browser"、"bun"、"node"),啟用 splitting: true 進行程式碼分割,並設定 tree shaking。
  • 撰寫測試時,使用 bun test 搭配與 Jest 相容的 API (describe、it、expect)、快照測試、使用 mock.module() 進行模擬,以及 --coverage 取得程式碼涵蓋率。
  • 執行檔案 I/O 時,建議優先使用 Bun.file() 和 Bun.write() 而非 Node.js fs,以獲得顯著更快的檔案操作,並使用 Bun.Glob 進行模式比對。
  • 處理驗證時,使用 Bun.password.hash() 和 Bun.password.verify() 進行 bcrypt/argon2,無需使用 npm 套件。
  • 從 Node.js 遷移時,將指令碼中的 node 替換為 bun,保持 package.json 不變,並注意大多數 npm 套件無需修改即可運作。使用 bun:sqlite 取代 SQLite npm 套件來處理嵌入式資料庫。

範例

範例 1:建立高效能 API 伺服器

使用者請求:「使用 Bun 內建的 HTTP 伺服器建立一個 REST API」

操作步驟:

  1. 使用 Bun.serve() 建立伺服器及路由處理器
  2. 使用 request.json() 解析 JSON 主體並回傳 Response 物件
  3. 加入 WebSocket 升級以支援即時功能
  4. 使用 Bun.password 進行驗證,使用 bun:sqlite 進行資料儲存

**輸出:**一個只使用 Bun 內建功能、無外部相依性的快速 API 伺服器。

範例 2:將 Node.js 專案遷移至 Bun

使用者請求:「將我的 Express 專案從 Node.js 切換到 Bun」

操作步驟:

  1. 在 CI 和本地設定中,將 npm install 替換為 bun install
  2. 更新 package.json 中的指令碼,將 node 改為 bun run
  3. 使用 Bun 內建的 .env 載入功能取代 dotenv
  4. 將測試執行器從 Jest 切換為 bun test,測試檔案保持不變

**輸出:**一個由 Bun 驅動的專案,安裝、啟動和測試執行速度更快。

指導原則

  • 新的 HTTP 伺服器請使用 Bun.serve();它在 Bun 上比 Express 快得多。
  • 檔案操作建議優先使用 Bun.file() 和 Bun.write() 而非 Node.js fs。
  • 本機資料儲存請使用 bun:sqlite,避免新增 SQLite npm 套件。
  • 驗證請使用 Bun.password,而非 bcrypt/argon2 npm 套件,以達到零原生相依性。
  • 將 bun.lock(文字格式)納入 git 以獲得可讀的 diff。
  • 使用 bun test 而非 Jest 進行測試,即可獲得相同 API 但執行速度顯著提升。
  • 若目標為瀏覽器,請使用 Bun.build() 並搭配 target: "browser"。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

TerminalSkills/skills

>- Run GitHub Actions locally with act. Use when a user asks to test GitHub Actions workflows locally, debug CI pipelines without pushing, or run workflows offline.

TerminalSkills/skills

>- You are an expert in AG2 (formerly AutoGen), the open-source multi-agent conversation framework. You help developers build systems where multiple AI agents collaborate through structured conversations — with tool use, human-in-the-loop, code execution, group chat orchestration, and nested conversations — for complex tasks like software development, research, and data analysis.

TerminalSkills/skills

>- Generate short-form videos with AI — script writing, text-to-speech narration, stock footage selection, subtitle generation, and video assembly. Use when: creating TikTok/YouTube Shorts/Reels content, automating video production, building content pipelines.

TerminalSkills/skills

>- Animate 3D objects and characters in Blender with Python. Use when the user wants to keyframe properties, create armatures and rigs, set up IK/FK chains, animate shape keys for facial animation, edit F-Curves, use the NLA editor to blend actions, add drivers for expression-based animation, or script any animation workflow in Blender.

TerminalSkills/skills

>- Automate motion capture and tracking workflows in Blender with Python. Use when the user wants to import BVH or FBX mocap data, retarget motion to armatures, track camera or object motion from video, solve camera motion, clean up motion capture data, or script any tracking pipeline in Blender.

TerminalSkills/skills

>- You are an expert in Bolt.new by StackBlitz, the AI-powered full-stack development environment that runs entirely in the browser. You help developers go from idea to deployed app in minutes using natural language prompts — Bolt generates complete applications with frontend, backend, database, and deployment, all running in a WebContainer without local setup.

TerminalSkills/skills

>- Self-host customer support with Chatwoot. Use when a user asks to set up open-source customer support, add live chat without SaaS costs, build a multi-channel inbox, or deploy a free Intercom alternative.

TerminalSkills/skills

>- You are an expert in Chi, the lightweight, idiomatic Go HTTP router built on `net/http`. You help developers build composable HTTP services using Chi's middleware stack, route groups, URL parameters, sub-routers, and context-based request scoping — providing Express-like ergonomics while staying 100% compatible with Go's standard library.

TerminalSkills/skills

When the user wants to edit, review, or improve existing marketing copy. Also use when the user mentions 'edit this copy,' 'review my copy,' 'copy feedback,' 'proofread,' 'polish this,' 'make this better,' or 'copy sweep.' This skill provides a systematic approach to editing marketing copy through multiple focused passes.

TerminalSkills/skills

>- Add live chat and customer support with Crisp. Use when a user asks to add a chat widget, implement live customer support, set up a help desk, create a knowledge base, or add a chatbot to a website.

TerminalSkills/skills

>- Assists with building custom interactive data visualizations using D3.js. Use when creating charts, graphs, maps, force layouts, or hierarchical diagrams that require fine-grained control beyond what charting libraries provide. Trigger words: d3, data visualization, chart, svg, scales, force graph, treemap, choropleth.

TerminalSkills/skills

dbt (data build tool) transforms data in your warehouse using SQL SELECT statements. Learn project setup, models, tests, documentation, incremental materializations, and integration with data warehouses like PostgreSQL, BigQuery, and Snowflake.

TerminalSkills/skills

>- You are an expert in dlt, the open-source Python library for building data pipelines. You help developers load data from any API, file, or database into warehouses and lakes using simple Python decorators — with automatic schema inference, incremental loading, and built-in data contracts. dlt is the "requests library for data pipelines.

TerminalSkills/skills

Data Version Control for ML projects. Track large datasets and models alongside Git, build reproducible ML pipelines, and run experiments with metric comparison. Works with any storage backend including S3, GCS, Azure, and local filesystems.

TerminalSkills/skills

>- You are an expert in E2B, the cloud platform for running AI-generated code in secure sandboxes. You help developers give AI agents the ability to execute code, install packages, read/write files, and run long processes in isolated cloud environments — each sandbox is a lightweight VM that boots in ~150ms with full Linux, filesystem, and networking.

TerminalSkills/skills

>- Transcode, convert, edit, and process audio and video with FFmpeg. Use when a user asks to convert video formats (webm to mp4, mkv to mp4), extract audio from video, compress video files, trim or cut clips, concatenate videos, add subtitles, create thumbnails, apply filters, change resolution or bitrate, re-encode media, create GIFs from video, add watermarks, normalize audio, stream media, or build automated media processing pipelines.

TerminalSkills/skills

>- Create advanced animations with GSAP. Use when building complex timelines, scroll-driven animations, SVG morphing, text animations, or high-performance web animations beyond CSS capabilities.

TerminalSkills/skills

>- Generate deterministic MP4 videos from HTML, CSS, media, and seekable animations using HeyGen's HyperFrames framework. Use when someone asks to "render HTML to video", "make a video with HyperFrames", "create a programmatic video", "turn an animation into MP4", "build a launch/product video from HTML", "render GSAP/Lottie/Three.js to video", or set up an agent-driven video pipeline. Covers init/preview/render/add/lint/inspect commands, data-* timing attributes, animation adapters, and the component catalog.

TerminalSkills/skills

When the user wants to perform load testing, stress testing, or performance testing of APIs and websites using k6. Also use when the user mentions "k6," "load test," "performance test," "stress test," "spike test," "soak test," "thresholds," "virtual users," or "VUs." For browser-based testing, see selenium.

TerminalSkills/skills

>- Lovable (formerly GPT Engineer) is a browser-based AI app builder that turns a natural-language description into a working full-stack web app with a built-in backend, authentication, database and one-click publishing. Use when the user wants to prototype or ship a web app with Lovable, write effective Lovable prompts, connect Supabase or GitHub, review generated security rules, or move a Lovable project into their own editor.

相關技能