---
name: bun-runtime-pro
description: "Bun-native apps — bun.serve, sqlite-native, test runner, package manager, hot reload, single binary. Builds Bun-native apps: Bun.serve HTTP server, bun:sqlite (native SQLite), bun test runner, bun install (faster than npm), hot module reload, and bun build to compile a single binary. Covers the Bun 1.x APIs that beat Node + npm + Vitest + sqlite3."
license: MIT
---

# Bun Runtime Pro

Bun Runtime Pro helps you build applications that lean on Bun's built-in runtime APIs instead of stitching together Node, npm, a bundler, and a test framework. It's for developers starting a new server, CLI, or library who want one toolchain — and for teams migrating an existing Node project onto Bun 1.x and replacing `express`, `sqlite3`, `vitest`, and `pkg` with native equivalents.

## When to use it

- Spinning up an HTTP or WebSocket service and you want a zero-dependency server.
- Adding a local database without a native-module compile step (`bun:sqlite` ships in the runtime).
- Replacing Jest/Vitest with `bun test` and its Jest-compatible `expect` matchers.
- Shipping a CLI as a single self-contained executable via `bun build --compile`.
- Tightening dev loops with `bun --hot` instead of `nodemon` + `ts-node`.

## What it does

It scaffolds and reviews code against the real Bun 1.x surface:

- **HTTP / WebSocket:** `Bun.serve({ port, fetch, websocket })`, returning standard `Response` objects, plus `routes` for path matching and `server.upgrade(req)` for WS.
- **SQLite:** `import { Database } from "bun:sqlite"`, prepared statements via `db.query(...).all()/.get()/.run()`, and `db.transaction()`.
- **Testing:** `import { test, expect, describe, mock } from "bun:test"`, run with `bun test --watch` and `--coverage`.
- **Packages & scripts:** `bun install` (uses `bun.lockb`), `bunx`, and `bun run`.
- **Bundling:** `Bun.build({ entrypoints, outdir, target })` and `bun build --compile --target=bun-linux-x64`.
- **Env & files:** automatic `.env` loading, `Bun.file()` / `Bun.write()`.

## Usage example

```bash
curl -fsSL --create-dirs -o ~/.claude/skills/bun-runtime-pro/SKILL.md https://claudeskil.com/skills/bun-runtime-pro/SKILL.md
bun init -y
```

```ts
// server.ts
import { Database } from "bun:sqlite";
const db = new Database("app.db");
db.run("CREATE TABLE IF NOT EXISTS hits (n INTEGER)");

Bun.serve({
  port: 3000,
  fetch(req) {
    db.run("INSERT INTO hits (n) VALUES (1)");
    const { c } = db.query("SELECT count(*) c FROM hits").get() as any;
    return new Response(`hits: ${c}`);
  },
});
```

```bash
bun --hot server.ts                 # hot reload
bun test --coverage                 # run tests
bun build server.ts --compile --outfile app   # single binary
```

## Tips & gotchas

- `bun --hot` keeps state across reloads (the process isn't restarted); use `bun --watch` if you need a full restart.
- `bun:sqlite` is synchronous by design — no `await` on queries. Reuse prepared statements; don't rebuild `db.query()` in hot paths.
- `--compile` embeds the Bun runtime, so binaries are ~50MB+ and are platform-specific; cross-compile with `--target`.
- `bun install` reads `bun.lockb` (binary). Commit it, but expect `package-lock.json` to be ignored.

## FAQ

**Can I keep using npm packages?** Yes. `bun install` resolves the npm registry; most CommonJS and ESM packages work unchanged.

**Does it replace tsc?** Bun executes `.ts`/`.tsx` directly (no emit), but it does not type-check — run `tsc --noEmit` in CI for that.

**Node APIs?** Most `node:` built-ins are polyfilled; check Bun's compatibility table for gaps before migrating.
