Skip to content
FunCoding

bun

Read before a js eval cell that spawns a process, server or PTY, installs a package, or starts a long run, and before any bun -e, script, server, CLI, test, typecheck, format, bundle, or package-management work: this session's eval js kernel runs Bun 1.4+. Bun 1.4.x builtins replace 20+ npm deps and dev tools — check here BEFORE installing or running tsc/tsgo, prettier/oxfmt, sharp, puppeteer/playwright (scraping), cheerio, marked, node-cron, node-pty, execa/zx, concurrently, serve-static, tar, json5, fast-xml-parser, string-width, dotenv, keytar, aws-sdk (S3/R2) — and before writing Bun.$ / Bun.spawn / bun test code: the traps that cost past sessions hours are listed here. Triggers: eval js, bun, Bun.$, Bun.spawn, Bun.serve, bun test, bun check, bun fmt, bun build, bun install, image resize, headless browser, markdown, cron, PTY, secrets.

Star
530
License
MIT
Last commit
Dec 1, 2026

packages/senpi-codemode/src/skill/bun/SKILL.md

View on GitHub

Bun 1.4.x — Use the Builtins First

Bun 1.4.0 (Aug 2026) through 1.4.4 (Oct 2026) ships builtins and CLIs that replace most utility npm packages and several dev tools. Before adding a dependency, spawning a tool, or writing a workaround, check the map below — if Bun ships it, use the builtin. Version tags ([v1.4.3]) in the references give exact minimums; dated notes (2026-10-25) mark facts measured in our own sessions. Release posts: https://bun.com/blog/bun-v1.4 … https://bun.com/blog/bun-v1.4.4.

Capability map — what you can do now

You want to...UseReplacesRef = references/<name>.md
Type-check a TS project: tsc-identical errors, 3-6x faster, no typescript installbun check --no-script, bun run/test/build --checktsc, tsgodev-tooling
Format with your Prettier/oxfmt configbun fmt --no-script (--check, --changed, --staged)prettier, oxfmt, lint-stageddev-tooling
Run shell commands from JS, no /bin/shBun.$`...` → .nothrow().quiet().text()/.json()/.lines()execa, zx, shelljssession-recipes
Spawn with timeout / PTY / IPC; measure a childBun.spawn({ env: process.env, timeout, killSignal, terminal, ipc }), proc.resourceUsage()node-pty, tree-kill, pidusagesession-recipes
Keep tokens out of files, argv and env dumpsBun.secrets.get/set (OS keychain), --env-file=/dev/stdinkeytar, dotenvsession-recipes
Resize/convert/rotate imagesBun.file(p).image().resize().webp().write()sharpruntime-apis
Headless browser: navigate, click, screenshot, evaluate, CDPnew Bun.WebView()puppeteer, playwright (scraping)runtime-apis
Scrape or rewrite HTML by CSS selector, streamingnew HTMLRewriter().on("a[href]", { element })cheerio, jsdom (scraping)runtime-apis
Markdown → HTML / React / ANSIBun.markdown.html() / .react() / .ansi()marked, react-markdown, glowruntime-apis
Schedule cron jobsBun.cron()node-cronruntime-apis
Run package scripts concurrently, glob-matchedbun run --parallel "build:*"concurrently, npm-run-allruntime-apis
Parse JSON5 / JSONL / JSONC / XML / TOML / YAML; tarballs; globsBun.JSON5/.JSONL/.JSONC/.XML/.TOML/.YAML, Bun.Archive, Bun.Globjson5, ndjson, jsonc-parser, fast-xml-parser, @iarna/toml, js-yaml, tar, fast-globruntime-apis
ANSI-aware terminal text; table renderingBun.stringWidth/sliceAnsi/wrapAnsi/stripANSI(), Bun.inspect.table()string-width, slice-ansi, wrap-ansi, strip-ansi, cli-tableruntime-apis
Hash, UUID v7, semver, deep-equal, gzip/zstd, whichBun.hash/CryptoHasher/password, randomUUIDv7, Bun.semver, deepEquals, gzipSync/zstdCompressSync, Bun.whichuuid, semver, lodash.isequal, pako, whichruntime-apis
Postgres / MySQL / SQLite, Redis, S3-compatible (R2) clientsBun.SQL, bun:sqlite, Bun.RedisClient, Bun.S3Client / s3://pg, mysql2, better-sqlite3, ioredis, aws-sdkruntime-apis
Serve a static dir (ETag/Range/304 handled)Bun.serve({ routes: { "/x/*": { dir } } })express.static, serve-static, sirvhttp-networking
HTTP/2 + HTTP/3 server; fetch protocol/compress/proxy; per-client poolshttp2: true, http3: true, fetch(url, { protocol, compress, proxy }), new Bun.FetchSession()undici Agenthttp-networking
Stream a download to disk; replay a request as curlBun.write(path, await fetch(url)), BUN_CONFIG_VERBOSE_FETCH=curlpipeline + createWriteStreamhttp-networking
Tests across CPU workers / CI shards / changed files / flaky retrybun test --parallel --shard=1/3 --changed=main --retry=3jest/vitest infratest
Kill "passes alone, fails in suite" bugs; hunt flakesbun test --isolate, --rerun-each N, --only-failuresvitest default behaviortest
Single-file executables with embedded assets and profile-guided startup; feature flags; in-memory bundling; metafile; React Compilerbun build --compile --bytecode --bytecode-order=<profile> --asset ./public, bun:bundle feature(), files:{}, metafile: true, --react-compilerpkg hacks, esbuild define/plugins, babel-plugin-react-compilerbuild
Diff package versions, fix vulns, dedupe/prune, licenses, explain a depbun pm diff, bun audit fix, bun dedupe, bun prune, bun pm licenses, bun whynpm-diff, npm audit fix, npm lsinstall
Offline / cached installs; Docker layers; CI cache; 7x faster CIbun install --offline|--prefer-offline, bun pm fetch, bun pm cache pack|unpack, linker = "isolated"pnpm storeinstall
Profile CPU/heap/bundle as grep-able Markdownbun --cpu-prof-md, --heap-prof-md, bun build --metafile-mdChrome DevTools round-tripdev-tooling
Run untrusted JS without eval / new Function / FFI--disallow-code-generation-from-strings=strict, --no-ffi-ccvm2security
Run Playwright, vitest, Next.js 16, OpenTelemetry, dd-trace; undici, node-fetch, wsthey now just work (the last three load Bun's builtin even when installed)Node.jsnode-compat-platforms

Free wins (no code change): 2x lower CPU, 13-48% less server memory, 2-2.5x faster startup — numbers in performance.

Operating rules — 2 to 6 are what past sessions paid for

  1. Eval-first, builtin-first. The eval js kernel runs on Bun (that is why this skill is present): call Bun.* APIs directly inside js cells and reach for bash or a spawned bun only for CLI surfaces (bun test, bun build, bun pm) or work that needs a separate process. The Replaces column above is a ban list for new dependencies in production code, test helpers and one-off scripts alike.
  2. Anything that must outlive a cell starts outside it. The kernel SIGKILLs every Bun.spawn child when its cell settles, so browsers, daemons, dev servers, remote ssh jobs and slow git hooks start through tool.monitor({ command }) or tool.bash({ run_in_background: true }); a stopped long Bun.$ cell restarts the kernel and loses every global, so helpers live in an importable file.
  3. Bun.$ runs one command with array-interpolated args; real shell syntax goes to bash. ${"a b"} is ONE argument, $?/$VAR are literal, for/until/heredocs are parse errors or silent command not found with rc 0, and VAR=x cmd is not applied to a binary — each of these produced a false-green gate. Use $`cmd ${[args]}`.nothrow().quiet() for a command and Bun.spawn(["bash", "-c", script], { env: process.env, stdin: "ignore" }) for a script.
  4. Every Bun.spawn passes env: process.env, and re-spawns Bun as process.execPath — but only when this runtime IS standalone Bun. An env-less child gets the environment the process STARTED with (runtime HOME/TMPDIR edits never arrive), and "bun" from PATH has resolved to three different shims on our machines. Inside a compiled host (the OmO engine, any --compile binary) process.execPath is the host binary itself, not Bun: spawning it with a script path starts another agent instead of running the script (omo#12569). There, resolve bun through PATH — senpi appends a real Bun shim to PATH — and never hand a script path to an unverified process.execPath. Give a child that reads stdin stdin: "ignore" or an explicit end, or it waits for EOF forever.
  5. bun test gets its timeout on the command line and exact paths with ./. --timeout N is the only budget that reaches every file (a preload's setDefaultTimeout covers the first file, bunfig's is ignored); a timeout SIGTERMs every child the test spawned, so a database started in beforeAll dies with it; bun test path.ts without ./ is a substring filter. The full table is in test — read it before writing or debugging a suite.
  6. Measure with the Bun the work targets. The kernel's Bun.version, the shell's bun --version and a repo's pinned Bun (CI bun-version, devDependencies.bun) differ on one machine and 1.4.2 vs 1.4.3 changed test outcomes, so evidence runs use the pin; probe a feature in an empty directory, because bun check/bun fmt/bun lint otherwise run a same-named package.json script. Installs: CI=1, visible output, and after --ignore-scripts run node node_modules/bun/install.js — install lists why.
  7. Read the matching reference before using an unfamiliar API — signatures and caveats (Bun.markdown HTML is unsanitized, HTTP/3 is experimental, writer({ append: true }) truncated a results file) live there, not here; session-recipes holds the rest of the session-learned traps.
  8. Upgrading a project or debugging behavior that changed? Read breaking-changes first — 1.4.0 changed YAML/TOML strictness, .xml/.css imports, Bun.$ globbing and fetch headers; 1.4.1-1.4.4 changed Bun.Glob parsing, WebSocket close timing and bun install flag handling.
  9. TLS errors after upgrade are usually intentional — 1.4.x tightened certificate verification across fetch, tls.connect, Bun.connect, RedisClient, Bun.SQL. See security before loosening anything.
  10. Close what a cell opens with using / await using. The binding disposes when its block exits, on a throw too: await using child = Bun.spawn(...) kills and awaits the child, await using dir = await fs.promises.mkdtempDisposable(prefix) removes the directory, and await using stack = new AsyncDisposableStack() collects the rest through stack.use(x), stack.adopt(value, close) and stack.defer(fn). A Bun.serve server only disposes synchronously, so register stack.defer(() => server.stop(true)); values with no dispose method keep try/finally. Under the jsCells.scope profile, scope() does this for servers, children, temp dirs and tool.monitor watches, and stack.move() hands what must outlive the block to its new owner.

Similar Skills

reverse-engineer-anything

MOmorluto/rea485k9,215 new stars in the last 7 days

reverse-engineer-anything

MOmorluto/rea485k9,215 new stars in the last 7 days

test-driven-development

OBobra/superpowers331k5,757 new stars in the last 7 days

agent-runtime-gateway-smoke-test

AFaffaan-m/ECC314k4,125 new stars in the last 7 days

ai-regression-testing

AFaffaan-m/ECC314k4,125 new stars in the last 7 days

Featured

accessibility

Audit accessibility on Web, iOS, and Android to meet WCAG 2.2, with keyboard navigation and screen-reader support.

AFaffaan-m/ECC314k4,125 new stars in the last 7 days