bun-runtime
affaan-m/everything-claude-code
Fast all-in-one JavaScript runtime with integrated package manager, bundler, and test runner.
What is bun-runtime?
Bun is a Node-compatible JavaScript runtime built on JavaScriptCore that combines package management, bundling, and testing in a single toolchain. Use it for new projects, performance-critical scripts, or when migrating from Node and seeking faster install and build times.
- Drop-in Node-compatible runtime with native TypeScript support
- Fast package manager with `bun install` significantly faster than npm/yarn
- Built-in bundler and transpiler for applications and libraries
- Jest-like test runner with `bun test` and watch mode
- Native Bun APIs for file I/O and HTTP servers
- Environment variable and script management via `bun run`
How to install bun-runtime
npx skills add https://github.com/affaan-m/everything-claude-code --skill bun-runtime- Bun installed on your system
- Existing Node.js project (optional, for migration)
How to use bun-runtime
- 1.Install dependencies with `bun install` (creates bun.lock or bun.lockb)
- 2.Replace `node script.js` with `bun run script.js` or `bun script.js`
- 3.Use `bun run` for npm scripts defined in package.json
- 4.Run tests with `bun test` or `bun test --watch` for watch mode
- 5.For Vercel: set runtime to Bun in project settings and use `bun install --frozen-lockfile` in build command
- 6.Commit the lockfile (bun.lock or bun.lockb) for reproducible installs
Use cases
- Migrating Node.js projects to Bun for faster install and build times
- Writing and testing TypeScript files natively without compilation setup
- Deploying applications to Vercel with Bun runtime for improved performance
- Building CLI tools and scripts where startup speed matters
- Running test suites with Jest-compatible API and watch mode
- JavaScript/TypeScript developers starting new projects
- Teams migrating from Node.js seeking performance improvements
- Developers deploying to Vercel or other platforms supporting Bun
- DevOps engineers optimizing build and install pipelines
bun-runtime FAQ
Replace `npm install` with `bun install`, then use `bun run` instead of `npm run` for scripts. Most packages work out of the box. Use `bun x` for one-off commands like `npx`.
Current Bun versions use `bun.lock` (text format) by default, while older versions used `bun.lockb` (binary format). Both serve as lockfiles for reproducible installs.
Prefer Bun for new projects, performance-critical scripts, and Vercel deployments. Use Node.js for maximum ecosystem compatibility or when dependencies have known Bun issues.
Yes, Bun runs `.ts` files natively without requiring a separate compilation step. Use `bun run script.ts` or `bun script.ts`.
Set the runtime to Bun in project settings, use `bun run build` for your build command, and `bun install --frozen-lockfile` for reproducible installs.
Full instructions (SKILL.md)
Source of truth, from affaan-m/everything-claude-code.
name: bun-runtime description: Bun as runtime, package manager, bundler, and test runner. When to choose Bun vs Node, migration notes, and Vercel support. metadata: origin: ECC
Bun Runtime
Bun is a fast all-in-one JavaScript runtime and toolkit: runtime, package manager, bundler, and test runner.
When to Use
- Prefer Bun for: new JS/TS projects, scripts where install/run speed matters, Vercel deployments with Bun runtime, and when you want a single toolchain (run + install + test + build).
- Prefer Node for: maximum ecosystem compatibility, legacy tooling that assumes Node, or when a dependency has known Bun issues.
Use when: adopting Bun, migrating from Node, writing or debugging Bun scripts/tests, or configuring Bun on Vercel or other platforms.
How It Works
- Runtime: Drop-in Node-compatible runtime (built on JavaScriptCore, implemented in Zig).
- Package manager:
bun installis significantly faster than npm/yarn. Lockfile isbun.lock(text) by default in current Bun; older versions usedbun.lockb(binary). - Bundler: Built-in bundler and transpiler for apps and libraries.
- Test runner: Built-in
bun testwith Jest-like API.
Migration from Node: Replace node script.js with bun run script.js or bun script.js. Run bun install in place of npm install; most packages work. Use bun run for npm scripts; bun x for npx-style one-off runs. Node built-ins are supported; prefer Bun APIs where they exist for better performance.
Vercel: Set runtime to Bun in project settings. Build: bun run build or bun build ./src/index.ts --outdir=dist. Install: bun install --frozen-lockfile for reproducible deploys.
Examples
Run and install
# Install dependencies (creates/updates bun.lock or bun.lockb)
bun install
# Run a script or file
bun run dev
bun run src/index.ts
bun src/index.ts
Scripts and env
bun run --env-file=.env dev
FOO=bar bun run script.ts
Testing
bun test
bun test --watch
// test/example.test.ts
import { expect, test } from "bun:test";
test("add", () => {
expect(1 + 2).toBe(3);
});
Runtime API
const file = Bun.file("package.json");
const json = await file.json();
Bun.serve({
port: 3000,
fetch(req) {
return new Response("Hello");
},
});
Best Practices
- Commit the lockfile (
bun.lockorbun.lockb) for reproducible installs. - Prefer
bun runfor scripts. For TypeScript, Bun runs.tsnatively. - Keep dependencies up to date; Bun and the ecosystem evolve quickly.
Related skills
More from affaan-m/everything-claude-code and the wider catalog.
security-review
Security checklist and patterns for authentication, input validation, secrets, and sensitive features.
golang-patterns
Idiomatic Go patterns, best practices, and conventions for building robust, efficient, and maintainable applications.
coding-standards
Baseline coding conventions for naming, readability, immutability, and quality across projects.
frontend-patterns
React and Next.js patterns for components, state management, performance, and modern frontend practices.
backend-patterns
REST/GraphQL API design, database optimization, and server-side patterns for Node.js, Express, and Next.js.
golang-testing
Go testing patterns: table-driven tests, subtests, benchmarks, fuzzing, and TDD methodology.