Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

bun

БесплатноБез исполняемых скриптовНе проверен

Assists with using Bun as an all-in-one JavaScript/TypeScript runtime, package manager, bundler, and test runner. Use when building HTTP servers, managing…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

Bun

Overview

Bun is a single binary that is a JavaScript/TypeScript runtime, a package manager, a bundler and a Jest-compatible test runner. It runs .ts and .tsx files directly, reads .env files, and ships built-ins such as Bun.serve(), bun:sqlite and Bun.password. It targets Node.js compatibility, so most npm packages work, but not every Node API behaves identically. Checked against Bun 1.4.4.

Instructions

Install and start a project

npm install -g bun            # or: brew install oven-sh/bun/bun   (macOS, Linux)
bun --version                 # 1.4.x
bun init -y                   # package.json, tsconfig.json, index.ts, bun.lock
bun run index.ts              # run TypeScript directly; add --hot to reload on change

Bun also publishes an install script at https://bun.com/install; if you use it, download it, read it, then run it, rather than piping it into a shell. A package manager is simpler. On Windows use scoop install bun or npm install -g bun.

Packages

bun install                   # reads package.json, writes bun.lock (text lockfile, readable diffs)
bun add zod                   # add a dependency; bun add -d typescript for dev
bun remove zod
bun install --frozen-lockfile # CI: fail if package.json and bun.lock disagree
bun audit                     # vulnerability check; bun outdated lists newer versions
bunx prisma generate          # run a package binary without installing it globally

Bun does not run postinstall and similar lifecycle scripts of dependencies, except for a built-in allow list of popular packages. If a package needs one (native builds), list it in "trustedDependencies" in package.json and reinstall. To hold back brand-new releases, set install.minimumReleaseAge (seconds) in bunfig.toml. A project still on the old binary bun.lockb migrates with bun install --save-text-lockfile --frozen-lockfile --lockfile-only, then delete bun.lockb.

HTTP server

Bun.serve() takes a routes map with :param segments and per-method handlers; fetch handles everything else.

// server.ts
import { Database } from "bun:sqlite";

const db = new Database("app.db");
db.run("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, email TEXT UNIQUE, hash TEXT)");

const server = Bun.serve({
  port: 3000,
  hostname: "127.0.0.1", // bind to loopback unless the service must be reachable from outside
  routes: {
    "/health": new Response("ok"),
    "/api/users/:id": (req) => {
      const user = db.query("SELECT id, email FROM users WHERE id = ?1").get(req.params.id);
      return user ? Response.json(user) : new Response("Not found", { status: 404 });
    },
    "/api/users": {
      POST: async (req) => {
        const { email, password } = await req.json();
        const hash = await Bun.password.hash(password); // argon2id by default
        db.query("INSERT INTO users (email, hash) VALUES (?1, ?2)").run(email, hash);
        return Response.json({ email }, { status: 201 });
      },
    },
  },
  fetch() {
    return new Response("Not found", { status: 404 });
  },
});
console.log(`listening on ${server.url}`);

WebSockets: call server.upgrade(req) inside fetch and add a websocket: { message(ws, msg) { ws.send(...) } } handler to the same Bun.serve() options. Bun.password.verify(password, hash) checks a hash.

Tests

bun test finds *.test.ts files and supports describe, it, expect, snapshots and --coverage.

// mailer.ts
export async function sendWelcome(email: string) { /* send the mail */ }

// signup.ts
import { sendWelcome } from "./mailer";
export async function signup(email: string) {
  await sendWelcome(email);
  return { email, welcomed: true };
}
// signup.test.ts
import { describe, expect, it, mock } from "bun:test";

mock.module("./mailer", () => ({ sendWelcome: mock(async () => {}) })); // before importing the code under test

describe("signup", () => {
  it("welcomes the new user", async () => {
    const { signup } = await import("./signup");
    expect(await signup("[email protected]")).toEqual({ email: "[email protected]", welcomed: true });
  });
});

Bundle and compile

// build.ts — run with: bun run build.ts
const result = await Bun.build({
  entrypoints: ["./src/index.tsx"],
  outdir: "./dist",
  target: "browser", // "bun" or "node" for server code
  splitting: true,
  minify: true,
});
if (!result.success) console.error(result.logs);

CLI equivalent: bun build ./src/index.tsx --outdir dist --minify. bun build ./server.ts --compile --outfile dist/api produces a single self-contained executable.

Files and environment

Bun.file("data.json").json() reads and await Bun.write("out.txt", text) writes. new Bun.Glob("src/**/*.ts").scan(".") lists files. .env, .env.local and .env.<NODE_ENV> load automatically into Bun.env and process.env, so dotenv is not needed.

Examples

Example 1: Build an A

Полный SKILL.md на GitHub

Установить bun в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл bun?

Assists with using Bun as an all-in-one JavaScript/TypeScript runtime, package manager, bundler, and test runner. Use when building HTTP servers, managing packages, running tests, or migrating from Node.js. Trigger words: bun, bun serve, bun install, bun test, bun build, javascript runtime, bun runtime.

Как установить скилл bun?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл bun запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить bun с