agentleFS
MaheshAwasareMaheshAwasare/claude-skills-pro/skills/bun-runtime/SKILL.md

bun-runtime

Skill1 starsChanged 7 months agoMITView on GitHub

Use Bun as runtime, package manager, bundler, and test runner — when to choose Bun over Node, the Node.js compatibility gotchas, migration from npm/pnpm, the built-in HTTP server, SQLite, and Bun's built-in test runner. Use when starting a new TS/JS project or evaluating a switch from Node.

  • Reads credentials

9 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use nuxt4-patterns, santa-method and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • mryeastcodeSkill

    nuxt4-patterns

    Nuxt 4 app patterns for hydration safety, performance, route rules, lazy loading, and SSR-safe data fetching with useFetch and useAsyncData.

    Also in 5 projects that use this

  • mryeastcodeSkill

    santa-method

    Multi-agent adversarial verification with convergence loop. Two independent review agents must both pass before output ships.

    Also in 6 projects that use this

  • JamkrisSkill

    agent-sort

    Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

    Also in 4 projects that use this

  • JamkrisSkill

    lead-intelligence

    AI-native lead intelligence and outreach pipeline. Replaces Apollo, Clay, and ZoomInfo with agent-powered signal scoring, mutual ranking, warm path discovery, source-derived voice modeling, and channel-specific outreach across email, LinkedIn, and X. Use when the user wants to find, qualify, and reach high-value contacts.

    Also in 4 projects that use this

  • JunMysterySkill

    ecc-guide

    Guide users through ECC's current agents, skills, commands, hooks, rules, install profiles, and project onboarding by reading the live repository surface before answering.

    Also in 3 projects that use this

  • JunMysterySkill

    recsys-pipeline-architect

    Design composable recommendation, ranking, and feed pipelines using the six-stage Source→Hydrator→Filter→Scorer→Selector→SideEffect framework popularized by xAI's open-sourced For You algorithm. Use this skill whenever the user is building any system that picks "the top K items for a (user, context)" — social feeds, content CMSs, RAG rerankers, task prioritizers, notification triage, search reranking, ad ranking.

    Also in 3 projects that use this

  • +4 more from Jamkris
  • +1 more from mryeastcode

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 9 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Run your Node test suite under Bun before committing to it as runtime.

    line 142

“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Bun Runtime

Bun is a Node-compatible JS runtime, package manager, bundler, and test runner — all one binary, written in Zig. Faster than Node + pnpm + tsc + vitest combined for most workloads. Trade-off: 95% Node compatibility, not 100%.

When to use

  • New TS/JS project — install speed alone is worth it.
  • Build/test bottleneck on your CI.
  • Edge-deploy compatible (Cloudflare Workers / Vercel) — Bun runs on Vercel as of 2025.
  • CLI tools — bun build --compile produces single-binary executables.

When NOT to use

  • Production runtime for a Node app with deep ecosystem deps you haven't tested.
  • Apps using native modules that haven't been ported (rare; check your node_modules).
  • Any case where "must be 100% Node identical" is a hard requirement.

What Bun replaces

ToolReplaced by
Nodebun run (runtime)
npm/pnpm/yarnbun install
ts-node / tsxNative — Bun runs .ts files directly
nodemonbun --hot
webpack/esbuild/vite (for libs)bun build
jest/vitestbun test
dotenvBuilt-in .env loading

Migration from Node + pnpm

# In existing repo
bun install                              # reads package.json, replaces node_modules
bun pm ls                                # verify deps installed

# Run scripts
bun run dev                              # uses package.json scripts
bun run build

# Replace runtime
node server.js  →  bun server.js
ts-node script.ts  →  bun script.ts      # no compile step

# Replace tests
vitest  →  bun test                      # if you used vitest's globals

package.json scripts work as-is. bun install produces a bun.lockb (binary lockfile); commit it; delete pnpm-lock.yaml / package-lock.json when fully migrated.

Built-in HTTP server (zero deps)

// server.ts
const server = Bun.serve({
  port: 3000,
  async fetch(req) {
    const url = new URL(req.url);
    if (url.pathname === "/healthz") return new Response("ok");
    if (url.pathname.startsWith("/api/")) return handleApi(req);
    return new Response("not found", { status: 404 });
  },
});

console.log(`Listening on ${server.port}`);

Bun.serve is roughly 4x faster than Express for raw throughput. It speaks the standard Request/Response Web API — code is portable to Cloudflare Workers and Deno.

Built-in SQLite

import { Database } from "bun:sqlite";
const db = new Database("app.sqlite");
db.run("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, email TEXT)");
const insert = db.prepare("INSERT INTO users (email) VALUES (?)");
insert.run("a@b.com");
const rows = db.query("SELECT * FROM users").all();

Faster than better-sqlite3, no native compile step, ships with the runtime. Replaces a lot of "small persistent state" use cases for CLI tools.

Built-in test runner

// users.test.ts
import { describe, expect, test } from "bun:test";
import { greet } from "./users";

describe("greet", () => {
  test("returns hello", () => {
    expect(greet("Mahesh")).toBe("Hello, Mahesh");
  });
});
bun test                                # run all *.test.ts
bun test --coverage                     # built-in coverage
bun test --watch
bun test users                          # name filter

Jest-compatible API. Migration from Vitest is mostly imports.

.env loading (built-in)

Bun automatically loads .env, .env.local, .env.<NODE_ENV>. No dotenv package. .env.local overrides .env; both are loaded before your app code runs.

Building a single-binary CLI

bun build --compile --target=bun-linux-x64 --outfile=mycli ./src/cli.ts

Produces a 50–80MB binary that includes the runtime. No node install needed on target machine. Cross-compile for darwin-x64, darwin-arm64, linux-x64, linux-arm64, win-x64.

Performance reality check

  • bun install is 5–25x faster than npm install, 2–10x faster than pnpm.
  • bun run vs node runtime is 1.1–1.5x faster on typical Node workloads (not 3x like marketing claims).
  • bun build is comparable to esbuild.
  • bun test is 2–5x faster than vitest.

The compounded CI win (install + test + build) is the real story. A 4-min CI becomes 90s.

Compatibility gotchas

IssueWorkaround
Some node: modules incomplete (node:cluster, node:vm)Check bun --print 'process.versions.bun' and feature support before relying
Native modules requiring node-gypMost work; some need rebuilding. bun pm trust <pkg>
npm-only postinstall hooksBun doesn't run lifecycle scripts by default — bun install --trust
Differences in process.env mutationBun freezes process.env after start in production; mutate before serving
Worker threads API surfaceMostly works; some edge cases differ

Run your Node test suite under Bun before committing to it as runtime.

Edge deploy

Cloudflare Workers: standard Worker syntax (no Bun APIs); use Bun for bun build step in CI. Vercel: now supports Bun directly as runtime; specify in vercel.json "build": { "env": { "BUN_RUNTIME": "1" } } or use bun install in build step.

Anti-patterns

  • Mixing bun install and npm install in the same repo — divergent lockfiles, irreproducible builds. Pick one.
  • Committing node_modules "for safety" — lockfile + bun install is reproducible.
  • Using bun: imports in code that may run on Node — breaks portability. Either commit fully or feature-detect.
  • Production runtime without testing the actual Node deps — 5% incompatibility usually means 1–2 packages bite. Test before betting prod on it.
  • Relying on bun build for production library bundling without testing the output — output differs from Vite/Rollup in subtle ways for libs.
  • Using Bun.serve then trying to deploy to Lambda — Lambda expects a handler, not a server. Use Hono or similar abstraction.
  • bun --hot in production — dev-only. bun run for prod.
  • Running bun test for end-to-end browser tests — Bun doesn't have a browser. Use Playwright separately.
  • Skipping bun test --coverage because "it might miss edges" — it works fine; the coverage tool is honest about what it sees.

Verify it worked

  • bun install in a fresh clone is < 5s for a typical app.
  • bun test passes the same suite that worked under Node + vitest.
  • bun run build produces the expected output.
  • All native deps work (bun pm ls --all shows no errors).
  • Production app under bun server.js handles the same load as node server.js without crashing.
  • CI time is materially shorter than the Node baseline.
  • .env.local overrides .env automatically (no dotenv import).
  • Single-binary bun build --compile runs on a target machine without Node installed.
  • bun --hot reloads the server on file change.
  • No mixing of npm install / bun install — only bun.lockb exists.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.