Skip to content
Back to skills

Bun Knowledge Patch

ASecurity

Bun

  • 25 stars
  • 0 votes
  • 0 copies
  • 10 views
  • Added September 5, 2026
developmentjavascripttypescriptrustjavasqlreactnodeexpresstestingdebugging

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 9 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill bun-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Bun Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Bun Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-bun-knowledge-patch-nevaberry-plugins/badge)](https://www.skillsdirectory.com/skills/nevaberry-bun-knowledge-patch-nevaberry-plugins)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: bun-knowledge-patch
description: Bun
version: "1.4.5"
license: MIT
metadata:
  author: Nevaberry
---



# Bun knowledge patch

Load this skill when updating, configuring, building, testing, or debugging Bun
projects. Use the quick reference for migration-sensitive behavior and common
commands; open the topic references for complete API details and examples.
Reference entries attribute behavior to its release or compatibility context.

## Reference index

| Reference | Topics |
| --- | --- |
| [Builds and frontend](references/build-and-frontend.md) | Checking, formatting, templates, HTML, CSS, transforms, plugins, bundles, executables, bytecode |
| [Databases and storage](references/databases-and-storage.md) | SQL adapters, queries, authentication, results, SQLite, Redis, S3 |
| [HTTP and networking](references/http-and-networking.md) | Routes, files, caching, fetch, proxies, HTTP/2, HTTP/3, WebSockets, cookies, TLS, sockets, DNS |
| [Node.js compatibility](references/node-compatibility.md) | API limits, modules, VM contexts, native addons, files, workers, streams, cryptography, diagnostics |
| [Packages and workspaces](references/packages-and-workspaces.md) | Lockfiles, linkers, catalogs, registries, trust, audits, updates, scripts, packing, publishing |
| [Runtime and platforms](references/runtime-and-platform.md) | CLI, environment, streams, subprocesses, FFI, formats, images, browsers, cron, WebAssembly, profiling, types |
| [Testing](references/testing.md) | Discovery, CI, isolation, workers, shards, concurrency, hooks, assertions, mocks, timers, reports, Node tests |

## Breaking changes and deprecations

### Runtime, modules, and native code

- When Bun runs as `node` through `bun --bun`, `bunx --bun`, or a `node`
  symlink, it skips automatic environment-file loading. Use an explicit
  `node --env-file=.env ./app.js` when needed.
- `Bun.TOML.parse()` and startup parsing of `bunfig.toml` reject unquoted
  strings, missing newlines between key-value pairs, and integers outside
  JavaScript's safe integer range with `SyntaxError`.
- A stylesheet's runtime default export is `{}`. A `.module.css` class-name
  map comes from bundling.
- `new CString(ptr)` returns a string without pointer or byte-buffer accessors.
  Retain the C pointer separately if the caller owns the allocation. A `cstring`
  return or callback argument is a string or `null` for a C null pointer.
- `napi_env` and `napi_value` arguments are restricted to `cc()`. Disabling the
  JIT makes FFI entry points throw `TypeError`.
- Main-thread `process.exit()` skips native addon finalizers and cleanup hooks.
  Complete essential cleanup before explicitly exiting.
- `fs.rmdir(path, { recursive: true })` throws `ERR_INVALID_ARG_VALUE`. Use
  `await fs.rm(path, { recursive: true, force: true })` with `node:fs/promises`.
  Omit unset removal options instead of explicitly passing `undefined`.
- Replace `res.writeHeader()` with `res.writeHead()`. A paused binary readable's
  size-less `read()` returns one buffered chunk; drain until it returns `null`.
  Streams using `setEncoding()` still return their full buffered string.

### Networking and TLS

- The `Bun.serve()` option `static` became `routes`. The removed `inspector`
  option is ignored; use `bun --inspect server.ts` to attach a debugger.
- `fetch()`, `WebSocket`, `Bun.connect()`, `Bun.RedisClient`, and `Bun.SQL`
  verify servers during the TLS handshake. In `fetch()`, a falsy return from
  `tls.checkServerIdentity` accepts the certificate; a truthy return rejects.
- For mTLS with `Bun.serve()` or `Bun.listen()`, set `requestCert: true`
  alongside `ca`. Setting `ca` alone no longer requests a client certificate.
- Bun validates custom TLS roots more strictly and may reject legacy roots.
  With `allowPartialTrustChain` and `crl`, the chain must end at a self-issued
  certificate. An expired certificate from an unknown issuer reports
  `CERT_HAS_EXPIRED`.
- Clone requests and responses before reading or locking their bodies.
  Otherwise `clone()` throws `TypeError` with `ERR_BODY_ALREADY_USED`.
  A failed body read sets `bodyUsed`, so retry with a new fetch.
- Add an `'error'` listener to built-in `ws` clients and accepted sockets:
  an unhandled error is an uncaught exception. The default `maxPayload` is
  100 MiB on clients and servers.
- `Bun.Socket#setKeepAlive(true, delay)` takes milliseconds. For 60 seconds,
  pass `60_000`; values below `1000` leave the kernel's idle delay unchanged.

### Database and test behavior

- `Bun.SQL` stops reading generic `PASSWORD`. Use `PGPASSWORD`,
  `MYSQL_PASSWORD`, a connection URL, or the `password` option.
- Babel and SWC loose-mode output for `sql` tagged templates throws `TypeError`.
  Disable loose mode for template literals when compiling those queries.
- `sql({...})` omits `undefined` fields and throws `SyntaxError` if all fields
  are omitted. Use `null` to write SQL `NULL`.
- MySQL `DATETIME` and `TIMESTAMP`, and PostgreSQL `timestamp` read with
  `.simple()`, are interpreted as UTC. Remove manual time-zone corrections.
  MariaDB 10.5 and newer JSON results are decoded; remove manual `JSON.parse()`.
- With SQLite 3.54, `ALTER TABLE` rejects adding, renaming, or dropping columns
  named `rowid`, `oid`, or `_rowid_`. `setAuthorizer()` also receives requests
  for function calls in column `DEFAULT` expressions.
- `jest.resetAllMocks()` and `vi.resetAllMocks()` reset implementations and call
  history. A reset spy returns `undefined` until restored. Use `clearAllMocks()`
  to retain implementations while clearing calls.
- With `CI=true`, focused tests are errors and new snapshots require
  `--update-snapshots`. `CI=false` disables those checks.

### Package and type migrations

- New `bun.lock` files use `lockfileVersion: 2`; nested or version-scoped
  overrides produce version 3 and require a reader supporting that format.
  Versions 0 and 1 still load and can be migrated by `bun install`.
- Linker defaults depend on lockfile `configVersion`. Version `1` defaults to
  isolated installs in workspaces and hoisted installs elsewhere; version `0`
  defaults to hoisted installs even in workspaces. Select `--linker=isolated`
  explicitly to keep that layout. The isolated linker enables its shared store.
- `trustedDependencies` and `--trust` match exact package names. Non-registry
  `file:`, `link:`, `git:`, and `github:` dependencies require explicit trust to
  run lifecycle scripts. Legacy `bun.lockb` entries still use stored name hashes.
- `bun update` updates transitive dependencies too. Use `bun update --depth 0`
  to update direct dependencies while keeping transitive versions pinned.
- Publishing a prerelease requires an explicit tag, such as
  `bun publish --tag beta`, or `publishConfig.tag`.
- Migrate `Bun.ServeOptions` to `Bun.Serve.Options`, `Bun.Build.Target` to
  `Bun.Build.CompileTarget`, and deprecated `Bun.Spawn.OptionsObject` to
  `Bun.Spawn.BaseOptions` or a specific spawn option type. `Bun.Server<Data>`
  takes the WebSocket data type; use `Bun.Server<undefined>` without WebSockets.

## Check, format, build, and serve

`bun check` reads `tsconfig.json` and reports diagnostics with the bundled
TypeScript checker. `bun test --check` includes type diagnostics in a test run.
`bun fmt` uses existing Prettier or oxfmt flags and configuration; `bun fmt --init`
creates `[fmt]` in `bunfig.toml`. Pass `--no-script` to either built-in command
when a package script has the same name.

Run `bun ./index.html` for a development server with hot reloading. HTML
entrypoints can produce deployable assets or an executable serving the page:

```sh
bun build ./index.html --production --outdir=dist
bun build --compile ./index.html --outfile myapp
```

For standalone HTML that opens directly from disk, use
`bun build --compile --target=browser ./index.html`. Every entrypoint must be
HTML, and this mode does not support splitting.

`Bun.build()` rejects on failure. Set `throw: false` to receive errors in
`result.logs`. Use `metafile: true` for build input/output metadata, or
`bun build --metafile-md` for a Markdown report. `--react-compiler` or
`reactCompiler: true` runs the React Compiler on components and hooks.

`bun build --bytecode --outdir=dist app.ts` emits `app.js` and `app.jsc`;
deploy both because some code still needs the JavaScript output. Combine
`--bytecode --compile` for a standalone executable. Repeat `--asset` to embed
files or directories under their original names.

`Bun.serve()` supports method-specific routes, dynamic segments in `req.params`,
HTML imports, fixed responses, files, and `{ dir }` directory routes.
Providing `routes` makes top-level `fetch` optional. `await server.stop()`
waits for in-flight connections; `server.stop(true)` force-closes them.

`http2: true` serves HTTP/2 and HTTP/1.x on the same port. HTTP/2 does not support
WebSockets or response trailers. Experimental `http3: true` requires TLS and
opens a UDP listener on the TCP port; WebSocket upgrades over HTTP/3 return `false`.

## Package and workspace operations

`bun install` migrates npm, pnpm, and Yarn lockfiles. Yarn Berry migration
preserves pins when possible; if it cannot preserve all pins, Bun reports why
and resolves from `package.json`.

`bun install --offline` makes no network requests and fails on cache misses.
`--prefer-offline` reuses expired cached metadata and downloads missing data.
Use `install.minimumReleaseAge` for release-age policy; durations accept units
and a bare number means seconds. `name@version` exclusions exempt one release.

`bun run --parallel` runs selected scripts together; `--sequential` runs them
in order. Both accept script globs and workspace selection. Failures stop the
run by default; `--no-exit-on-error` lets other scripts finish and `--if-present`
skips packages lacking a requested script.

`bun audit fix --dry-run` previews vulnerability fixes. `bun dedupe --check`
fails when locked versions can be consolidated. `bun prune --check` lists
removable packages and exits with status 1 when anything can be pruned.

## Test execution and isolation

`bun test --isolate` gives each file a fresh global environment and cleans up
timers, sockets, and subprocesses. `--parallel[=N]` runs isolated files in worker
processes, defaulting to CPU count when `N` is omitted. Use
`bun test --parallel --no-isolate` to share globals and module state within each
worker. Parallel runs merge coverage and JUnit reports.

`bun test --changed=main --watch` selects tests affected by changes against a
Git ref, including transitive imports. `bun test --shard=2/3` selects the second
of three shards. Timing files can balance shard durations or schedule the
slowest files first in parallel workers.

`test.concurrent()` opts into concurrency within a file; `test.serial()` opts
out. Keep `expect.assertions()`, `expect.hasAssertions()`, and `toMatchSnapshot()`
in serial tests. Concurrent tests support `toMatchInlineSnapshot()`.

## SQL, storage, and runtime APIs

`Bun.SQL` supports PostgreSQL, MySQL, MariaDB, and SQLite. Use tagged templates
for bound values and `sql.unsafe(query)` explicitly for raw SQL. PostgreSQL COPY
uses `query.writable()` or `query.readable()`; plain execution rejects with
`ERR_POSTGRES_COPY_NOT_SUPPORTED`. `sql.json(value)` binds explicit JSON values.

`Bun.FetchSession` supplies a separate connection pool and TLS/proxy defaults.
`Bun.write()` streams a `Response`, `Request`, or `ReadableStream` to disk.
S3 supports listing, presigning, multipart uploads, and object metadata. The
experimental Redis client supports binary reads, Pub/Sub, database selection,
and reconnection.

Experimental `Bun.ModuleGraph` runs trusted app instances with separate module
state, timers, and I/O. `--disallow-code-generation-from-strings` blocks `eval()`
and `new Function()`; strict mode adds further compilation and import limits.
`--no-ffi-cc` disables runtime C compilation, and workers inherit it.

`Bun.markdown.html()` passes raw HTML, event-handler attributes, and
`javascript:` links through verbatim. Sanitize its output for untrusted Markdown.
`Bun.Image` supports transformation pipelines; format support depends on platform.
`Bun.cron` defaults to local time and accepts `{ tz }` for an explicit time zone.

## Node.js compatibility limits

Use JSON serialization for IPC between Bun and Node.js; advanced serialization
requires Bun at both ends. Bun's `node:v8` wire format is incompatible with
Node.js. Web streams cannot be transferred with `postMessage()` or
`structuredClone()`, and cloned errors lose their `cause`.

Use `Bun.plugin()` for loader customization: `module.register()` has no effect
and `registerHooks()` is missing. `AsyncLocalStorage` context does not propagate
into `MessagePort`, `BroadcastChannel`, or `Worker` events. See the Node.js
reference for API-specific limits, including TLS, diagnostics, and native addons.

Files in this skill

  • SKILL.md10.7 KB
  • coverage.json4.6 KB
  • references/build-and-frontend.md22.8 KB
  • references/databases-and-storage.md15.7 KB
  • references/http-and-networking.md25.1 KB
  • references/node-compatibility.md28 KB
  • references/packages-and-workspaces.md20.8 KB
  • references/runtime-and-platform.md34.8 KB
  • references/testing.md12 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.