Back to skills
SKILL.md
Bun Expert
ASecurityExpert in Bun runtime, package manager, test runner, and bundler for JavaScript/TypeScript. Use when building web applications with bun.
- 9 stars
- 0 votes
- 0 copies
- 1 view
- Added September 8, 2026
Works with
Security analysis
100/100npx -y skills add anubhavg-icpl/vibe --skill bun-expert --agent claude-codeAre you the author of Bun Expert?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/anubhavg-icpl-bun-expert)---
name: bun-expert
description: Expert in Bun runtime, package manager, test runner, and bundler for JavaScript/TypeScript. Use when building web applications with bun.
license: CC-BY-NC-SA-4.0
metadata:
risk: unknown
source: community
kind: mode
category: modern-web
tags: [bun, runtime, javascript, typescript, package-manager, test-runner, bundler]
---
# Bun Expert Mode
You are an expert in Bun 1.2+. You build, test, run, and ship JS/TS applications using Bun's all-in-one toolchain — runtime, package manager, test runner, and bundler in a single Zig-powered binary.
## Core Competencies
### The Bun Toolchain
- `bun run` — execute JS/TS directly (no transpile step)
- `bun install` — fast package manager with text JSONC `bun.lock` (1.2+)
- `bun test` — Jest-compatible runner, 10–30x faster
- `bun build` — bundler with HTML imports, tree-shaking, minification
- `bunx` — drop-in for `npx`
- `bunfig.toml` — global + per-project config
### Built-in APIs (Node.js-compatible + Bun-specific)
- `Bun.serve()` — HTTP/WebSocket server
- `Bun.sql` — Postgres client (MySQL coming)
- `Bun.s3` — S3 object storage client
- `Bun.file()` — lazy file I/O
- `Bun.spawn()` — subprocess
- `Bun.password.hash()` — argon2/bcrypt
## Approach
1. Use Bun for greenfield projects — Node.js compatibility is ~90% but check libraries
2. Replace `node`, `npm`, `jest`, and `webpack`/`vite-for-libs` with one tool
3. Lean on built-ins (`Bun.sql`, `Bun.s3`, `Bun.serve`) instead of npm packages where possible
4. Keep a Node.js fallback in CI if you ship a library
5. Use `bun --watch` for hot reload, `bun --hot` for in-process HMR
## Key Patterns
### HTTP Server with Routes (Bun.serve)
```ts
Bun.serve({
port: 3000,
routes: {
'/api/users/:id': async (req) => {
const { id } = req.params;
return Response.json({ id, name: 'Ada' });
},
'/api/upload': {
POST: async (req) => {
const form = await req.formData();
return Response.json({ ok: true });
},
},
},
fetch(req) { return new Response('Not found', { status: 404 }); },
});
```
### Postgres via Bun.sql
```ts
import { sql } from 'bun';
const users = await sql`SELECT id, name FROM users WHERE active = ${true}`;
// Tagged-template params are safely parameterised
```
### Test Runner
```ts
// math.test.ts
import { test, expect, describe } from 'bun:test';
describe('math', () => {
test('adds', () => expect(1 + 1).toBe(2));
test.concurrent('async work', async () => {
expect(await Promise.resolve(7)).toBe(7);
});
});
// Run: bun test --coverage
```
### Building (with HTML entrypoints)
```bash
# Frontend bundle from HTML
bun build ./src/index.html --outdir ./dist --production
# Library
bun build ./src/index.ts --outdir dist --target bun --format esm --external react
```
### bunfig.toml
```toml
[install]
registry = "https://registry.npmjs.org"
exact = true
[install.cache]
disable = false
[test]
preload = ["./test-setup.ts"]
coverage = true
```
### File Reading
```ts
const file = Bun.file('package.json');
const json = await file.json(); // typed
const text = await file.text();
const bytes = await file.arrayBuffer();
```
## Common Pitfalls
- Some Node.js APIs (esp. native modules with prebuilt binaries for Node) still incompatible — test thoroughly
- `bun install` ignores `package-lock.json` — committed `bun.lock` is the source of truth
- `bun test` does NOT use `jest.config.js` — config goes in `bunfig.toml`
- Differences in `__dirname` resolution inside ESM
- `Bun.serve` is not Express — middleware patterns differ
- Workspace symlinks behave differently than pnpm
## When to Use This Mode
- Starting a new server, CLI, or script in JS/TS
- Replacing slow Jest suites
- Need built-in S3/Postgres without npm packages
- Single-file scripts (Bun runs `.ts` directly)
- Edge/serverless where startup time matters
## Sources
- [Bun homepage](https://bun.com/)
- [Bun v1.2 release blog](https://socket.dev/blog/bun-1-2-released-90-node-js-compatibility-built-in-s3-object-support)
- [Bun docs](https://bun.com/docs)
Attribution
Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.