一键导入
bun
Must use whenever Bun is used.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Must use whenever Bun is used.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | bun |
| description | Must use whenever Bun is used. |
| author | alexgorbatchev |
Always use native, highly-optimized Bun APIs instead of falling back to Node.js stdlib or heavy npm packages. Bun's standard library is written in Zig, runs natively, and is dramatically faster.
fs, child_process, crypto, zlib) or heavy npm packages (like dotenv, bcrypt, uuid, better-sqlite3, tar, ioredis) unless native Bun APIs do not support the task.node:fs/promises is approved for directories (mkdir, readdir with recursive globbing). For files, ALWAYS use Bun.file and Bun.write.| Node.js / Third-Party | Native Bun API (DO THIS) | Detailed Reference |
|---|---|---|
fs.readFileSync, readFile | await Bun.file(path).text() / .json() / .bytes() | See section 1 (below) |
fs.writeFileSync, writeFile | await Bun.write(path, data) | See section 1 (below) |
fs.unlinkSync, unlink | await Bun.file(path).delete() | See section 1 (below) |
child_process.spawn | Bun.spawn / Bun.spawnSync | See section 2 (below) |
http.createServer, express | Bun.serve({ fetch(req) { ... } }) | See section 4 (below) |
ws package | Bun.serve({ websocket: { ... } }) | See section 4 (below) |
esbuild, rollup, webpack | Bun.build({ entrypoints, outdir }) | See bundling.md |
better-sqlite3 package | import { Database } from "bun:sqlite"; | See section 3 (below) |
@aws-sdk/client-s3 package | import { S3Client } from "bun"; | See s3.md |
ioredis, redis packages | import { RedisClient } from "bun"; | See redis.md |
tar, archiver packages | import { Archive } from "bun"; | See archive.md |
bcrypt, argon2 packages | await Bun.password.hash(pwd) | See utilities.md |
cheerio, jsdom packages | new HTMLRewriter() | See section 4 (below) |
fast-glob, glob packages | import { Glob } from "bun"; | See section 5 (below) |
semver package | import { semver } from "bun"; | See utilities.md |
dotenv package | Built-in .env autoloaded into process.env & Bun.env | See utilities.md |
uuid package | Bun.randomUUIDv7() | See utilities.md |
Bun.file & Bun.write)Do not import Node fs for file reads, writes, copies, or deletions.
const file = Bun.file(path); await file.text(); await file.json(); await file.bytes();await Bun.write(dest, content); (Supports writing strings, Blobs, Response bodies, and copying files directly).await Bun.file(path).delete();import { readdir, mkdir } from "node:fs/promises".Bun.$ & Bun.spawn)Do not run subprocesses via child_process.
$): Natively cross-platform, safe from injection, and integrates JS objects (like Response or BunFile) as stdin/stdout.
import { $ } from "bun";
const outputText = await $`echo "Hello!"`.text(); // quiet by default
const { exitCode } = await $`git status`.nothrow();
Bun.spawn or Bun.spawnSync.
const proc = Bun.spawn(["python3", "script.py"], { stdout: "pipe" });
const output = await new Response(proc.stdout).text();
bun:sqlite)Do not use sqlite3 or better-sqlite3. Bun's native driver is synchronous and 3-6x faster.
import { Database } from "bun:sqlite";
const db = new Database("mydb.sqlite");
db.run("PRAGMA journal_mode = WAL;"); // WAL mode is highly recommended
const query = db.query("SELECT * FROM users WHERE id = $id");
const user = query.get({ $id: 1 }); // strict: false (requires '$' prefix)
// With strict parameter matching (allows omitting prefixes in binding objects)
const dbStrict = new Database("mydb.sqlite", { strict: true });
const userStrict = dbStrict.query("SELECT * FROM users WHERE id = $id").get({ id: 1 });
Do not import Express, Fastify, or ws for standard servers.
Bun.serve({
port: 3000,
fetch(req, server) {
if (server.upgrade(req)) return; // handles websocket upgrade
return new Response("Hello from Bun Server!");
},
websocket: {
message(ws, msg) { ws.send(`Echo: ${msg}`); }
}
});
lol-html engine). See references/s3.md or basic docs.Bun.Glob)Do not import glob or fast-glob.
import { Glob } from "bun";
const glob = new Glob("**/*.ts");
for await (const file of glob.scan(".")) {
console.log(file);
}
Open and read these reference files whenever your task involves the following domains:
Bun.build: Read references/bundling.md. Includes options, custom loaders, virtual in-memory builds (files), env inlining, code splitting, and browser/bun targets.S3Client): Read references/s3.md. Covers file reading/writing, presigning URLs (PUT/GET), automatic streaming multipart uploads, and 302 download redirect responses.RedisClient): Read references/redis.md. Covers automatic command pipelining, Pub/Sub channels (subscriber connections), key/hash/set basic operations, and connection options.Bun.Archive): Read references/archive.md. Covers creating archives from in-memory objects, recursive file extraction, file filtering via globbing, and native gzip/deflate/zstd compression.Bun.sleep & Bun.sleepSync), monotonic UUID v7s (Bun.randomUUIDv7), synchronous promise sniffing (Bun.peek), deep object equivalence (Bun.deepEquals), escape/stripping terminal formatting (Bun.stripANSI, Bun.wrapAnsi, Bun.stringWidth), and fast cryptography password hashing (Bun.password).Use agent-browser for browser automation against real rendered web pages or web apps. Trigger when tasks require navigation, element interaction, extracting rendered data, or taking screenshots. Do not use for static fetches, direct API calls, or non-browser work.
Use when the user wants to scrape websites, crawl or map URLs, search the web, extract structured data from web pages, or run AI web agents using the Firecrawl API from the command line.
Create, revise, and validate effective skills. Use when adding a new skill or changing an existing skill's SKILL.md, bundled scripts, references, assets, scaffold templates, or validation tooling.
Must use any time a TypeScript file is read or written.
OpenCode session storage locations and inspection guidance. Use when asked where OpenCode stores session data, chat history, local databases, or repo-specific session metadata.
Apply Go coding rules, design principles, and project conventions for maintainable Go code and repositories. Use when writing, reviewing, refactoring, or releasing Go code, or when working on Go-specific project structure, APIs, tests, CI, or binaries. Do not use for non-Go codebases or for language-agnostic tasks that do not depend on Go conventions.