Communitygithub.com

Bun 技能

帮助使用 Bun 作为一体化 JavaScript/TypeScript 运行时、包管理器、打包器和测试运行器。适用于构建 HTTP 服务器、管理包、运行测试或从 Node.js 迁移。触发词:bun, bun serve, bun install, bun test, bun build, javascript runtime, bun runtime。

Bun 技能 是什么?

Bun 技能提供了一个详细的指南,帮助开发者使用 Bun——一个一体化 JavaScript/TypeScript 运行时,旨在替代 Node.js、npm、webpack 和 Jest。该技能涵盖了 Bun 的关键功能,包括使用 `Bun.serve()` 构建高性能 HTTP 服务器,使用 `bun install` 进行快速包管理,使用 `Bun.build()` 进行打包,以及通过兼容 Jest 的 `bun test` 进行测试。它还为文件 I/O 操作(`Bun.file()`、`Bun.write()`)、身份验证(`Bun.password`)和嵌入式数据库(`bun:sqlite`)提供指导,并详细说明了从 Node.js 迁移的步骤。该技能适用于任何支持自定义技能的 AI 代理平台,如 Claude Code、Cursor 或 Codex,帮助开发者利用 Bun 的内置功能来减少外部依赖并提高性能。

兼容平台~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(),它支持每秒 10 万以上请求,并内置 WebSocket 支持、TLS 和流式响应。
  • 管理包时,使用 bun install(比 npm 快 10-30 倍)、bun add、bun remove,并优先使用 bun.lock(文本格式)以获得可读的 git 差异。
  • 打包时,使用 Bun.build() 并设置适当的目标("browser"、"bun"、"node"),通过 splitting: true 启用代码分割,并配置摇树优化。
  • 编写测试时,使用 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 脚本,使用 bun run 而非 node
  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 中,以获得可读的差异。
  • 使用 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.

相关技能