Comprehensive Bun runtime toolkit covering runtime, package manager, bundler, testing, HTTP servers, WebSockets, databases, framework integrations (Hono, Next.js, Nuxt, TanStack Start, SvelteKit), deployment, and Node.js compatibility.
- version
- 3.12.0
- GitHub stars
- 250
Add marketplace
/plugin marketplace add secondsky/claude-skillsRun it inside Claude Code once, then install the plugin below.
Install
/plugin install bun@claude-skillsRun it inside Claude Code after adding the marketplace.
Files
Discovered from sourceBun Bundler
Bun's bundler is a fast JavaScript/TypeScript bundler built on the same engine as Bun's runtime. It's an esbuild-compatible alternative with native performance.
Quick Start
CLI
# Basic bundle
bun build ./src/index.ts --outdir ./dist
# Production build
bun build ./src/index.ts --outdir ./dist --minify
# Multiple entry points
bun build ./src/index.ts ./src/worker.ts --outdir ./dist
JavaScript API
// Since Bun 1.2, Bun.build REJECTS on failure (throws).
// Wrap in try/catch to handle errors; pass { throw: false } to restore the
// old resolve-with-{ success, logs } contract if you prefer that style.
try {
const result = await Bun.build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
});
console.log(`Built ${result.outputs.length} files`);
} catch (err) {
console.error("Build failed:", err);
process.exit(1);
}
Bun.build Options
await Bun.build({
// Entry points (required)
entrypoints: ["./src/index.ts"],
// Output directory
outdir: "./dist",
// Target environment
target: "browser", // "browser" | "bun" | "node"
// Output format
format: "esm", // "esm" | "cjs" | "iife"
// Minification
minify: true, // or { whitespace: true, identifiers: true, syntax: true }
// Code splitting
splitting: true,
// Source maps
sourcemap: "external", // "none" | "inline" | "external" | "linked"
// Naming patterns
naming: {
entry: "[dir]/[name].[ext]",
chunk: "[name]-[hash].[ext]",
asset: "[name]-[hash].[ext]",
},
// Define globals
define: {
"process.env.NODE_ENV": JSON.stringify("production"),
},
// External packages
external: ["react", "react-dom"],
// Loaders
loader: {
".svg": "text",
".png": "file",
},
// Plugins
plugins: [myPlugin],
// Root directory
root: "./src",
// Public path for assets
publicPath: "/static/",
});
CLI Flags
bun build <entrypoints> [flags]
| Flag | Description |
|---|---|
--outdir | Output directory |
--outfile | Output single file |
--target | browser, bun, node |
--format | esm, cjs, iife |
--minify | Enable minification |
--minify-whitespace | Minify whitespace only |
--minify-identifiers | Minify identifiers only |
--minify-syntax | Minify syntax only |
--splitting | Enable code splitting |
--sourcemap | none, inline, external, linked |
--external | Mark packages as external |
--define | Define compile-time constants |
--loader | Custom loaders for extensions |
--public-path | Public path for assets |
--root | Root directory |
--entry-naming | Entry point naming pattern |
--chunk-naming | Chunk naming pattern |
--asset-naming | Asset naming pattern |
Target Environments
Browser (default)
await Bun.build({
entrypoints: ["./src/index.ts"],
target: "browser",
outdir: "./dist",
});
Bun Runtime
await Bun.build({
entrypoints: ["./src/server.ts"],
target: "bun",
outdir: "./dist",
});
Node.js
await Bun.build({
entrypoints: ["./src/server.ts"],
target: "node",
outdir: "./dist",
});
Code Splitting
await Bun.build({
entrypoints: ["./src/index.ts", "./src/admin.ts"],
splitting: true,
outdir: "./dist",
});
Shared dependencies are extracted into separate chunks automatically.
Loaders
| Loader | Extensions | Output |
|---|---|---|
js | .js, .mjs, .cjs | JavaScript |
jsx | .jsx | JavaScript |
ts | .ts, .mts, .cts | JavaScript |
tsx | .tsx | JavaScript |
json | .json | JavaScript |
toml | .toml | JavaScript |
text | - | String export |
file | - | File path export |
base64 | - | Base64 string |
dataurl | - | Data URL |
css | .css | CSS file |
Custom loaders:
await Bun.build({
entrypoints: ["./src/index.ts"],
loader: {
".svg": "text",
".png": "file",
".woff2": "file",
},
});
Plugins
const myPlugin = {
name: "my-plugin",
setup(build) {
// Resolve hook
build.onResolve({ filter: /\.special$/ }, (args) => {
return { path: args.path, namespace: "special" };
});
// Load hook
build.onLoad({ filter: /.*/, namespace: "special" }, (args) => {
return {
contents: `export default "special"`,
loader: "js",
};
});
},
};
await Bun.build({
entrypoints: ["./src/index.ts"],
plugins: [myPlugin],
});
Build Output
// Bun 1.2+: Bun.build rejects on failure. Use try/catch to surface build
// errors (or pass { throw: false } and keep the legacy { success, logs } shape).
try {
const result = await Bun.build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
});
// Access outputs
for (const output of result.outputs) {
console.log(output.path); // File path
console.log(output.kind); // "entry-point" | "chunk" | "asset"
console.log(output.hash); // Content hash
console.log(output.loader); // Loader used
// Read content
const text = await output.text();
}
} catch (err) {
console.error("Build failed:", err);
process.exit(1);
}
Common Patterns
Production Build
await Bun.build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
target: "browser",
minify: true,
sourcemap: "external",
splitting: true,
define: {
"process.env.NODE_ENV": JSON.stringify("production"),
},
});
Library Build
await Bun.build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
target: "bun",
format: "esm",
external: ["*"], // Externalize all dependencies
sourcemap: "external",
});
Build Script
// build.ts
// Bun 1.2+: Bun.build rejects on failure, so try/catch is the modern idiom.
try {
const result = await Bun.build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
minify: process.env.NODE_ENV === "production",
});
console.log(`Built ${result.outputs.length} files`);
} catch (err) {
console.error("Build failed:", err);
process.exit(1);
}
Run: bun run build.ts
Common Errors
| Error | Cause | Fix |
|---|---|---|
Could not resolve | Missing import | Install package or fix path |
No matching export | Named export missing | Check export name |
Unexpected token | Syntax error | Fix source code |
Target not supported | Invalid target | Use browser, bun, or node |
When to Load References
Load references/options.md when:
- Need complete option reference
- Configuring advanced features
Load references/plugins.md when:
- Writing custom plugins
- Understanding plugin API
Load references/macros.md when:
- Using compile-time macros
- Build-time code generation
Readme
Bun Plugin for Claude Code
Comprehensive Claude Code plugin for the Bun JavaScript runtime. Covers runtime, package manager, bundler, testing, servers, databases, frameworks, and deployment.
Installation
/plugin install bun@claude-skills
Features
27 Skills
Core (3 skills)
bun-runtime- Runtime execution, CLI, environment, module resolutionbun-package-manager- Dependencies, workspaces, lockfiles, migrationsbun-bundler- Code bundling, tree shaking, code splitting
Testing (5 skills)
bun-test-basics- Writing tests, assertions, describe/it blocksbun-test-mocking- Mock functions, spyOn, module mockingbun-test-lifecycle- beforeAll, afterAll, setup/teardownbun-test-coverage- Code coverage reports, thresholds, CI integrationbun-jest-migration- Migrate Jest tests to Bun
Servers & APIs (3 skills)
bun-http-server- Bun.serve(), request handling, routingbun-websocket-server- WebSocket connections, pub/sub, broadcastingbun-hono-integration- Hono framework, middleware, RPC
Databases (4 skills)
bun-sqlite- Built-in SQLite, prepared statements, transactionsbun-drizzle-integration- Drizzle ORM, schema, migrationsbun-redis- Redis caching, pub/sub, ioredis/Upstashbun-file-io- File operations, Bun.file(), streaming
Frameworks (6 skills)
bun-nextjs- Next.js with Bun runtimebun-nuxt- Nuxt 3 with Bun presetbun-sveltekit- SvelteKit with svelte-adapter-bunbun-tanstack-start- TanStack Start full-stack Reactbun-react-ssr- Custom React SSR without frameworksbun-hot-reloading- --watch, --hot, HMR
Advanced (4 skills)
bun-macros- Compile-time code executionbun-ffi- Foreign function interface for native codebun-workers- Web Workers, worker_threadsbun-shell- Bun.$, shell scripting, subprocess
Deployment (2 skills)
bun-cloudflare-workers- Deploy to Cloudflare Workersbun-docker- Docker containers with oven/bun images
6 Commands
| Command | Description |
|---|---|
/bun-init | Initialize new Bun project with optional framework |
/bun-migrate | Migrate from Node.js/npm to Bun |
/bun-debug | Debug runtime, test, or build issues |
/bun-optimize | Optimize performance and bundle size |
/bun-deploy | Deploy to Docker, Cloudflare, Vercel, etc. |
/bun-upgrade | Upgrade Bun runtime and dependencies |
3 Agents
| Agent | Purpose |
|---|---|
bun-troubleshooter | Diagnose and fix errors, crashes, failures |
bun-performance-analyzer | Profile and optimize performance |
bun-migration-assistant | Migrate from Node.js/Jest to Bun |
2 Hooks
PreToolUse (validate-bun-command.sh)
- Suggests Bun equivalents for npm/yarn/pnpm commands
- Warns about deprecated patterns
PostToolUse (bun-suggestions.sh)
- Provides tips after bun install, test, build
- Suggests fixes for common errors
Usage Examples
Start a New Project
/bun-init my-app hono
Migrate from npm
/bun-migrate npm
Debug Issues
Ask: "My Bun server keeps crashing" - triggers bun-troubleshooter agent
Optimize Performance
/bun-optimize bundle
Deploy
/bun-deploy docker
Skill Triggers
Skills trigger automatically based on context:
- "How do I write tests in Bun?" →
bun-test-basics - "Help me set up Drizzle ORM" →
bun-drizzle-integration - "I want to build a WebSocket server" →
bun-websocket-server - "Deploy my app to Cloudflare Workers" →
bun-cloudflare-workers
Requirements
- Bun 1.0+ installed
- Claude Code CLI
License
MIT
Links
Details
- Marketplace
- secondsky/claude-skills
- Source
- plugins/bun
- Category
- Tooling
- Keywords
- bun, tooling, workflow, http, sveltekit, tanstack, websockets
- Listed since
- Apr 7, 2026
More from secondsky/claude-skills
All 122- claude-code-bash-patternsv3.12.0
- claude-hook-writerv3.12.0
- clefcut-cloudflare-remotion-videov3.12.0
- clefcut-cloudflare-videov3.12.0
- code-reviewv3.12.0
- csrf-protectionv3.12.0
- cybersecurityv3.12.0
- defense-in-depth-validationv3.12.0
- delegate-my-workv3.12.0
- dependency-upgradev3.12.0
- design-reviewv3.12.0
- design-system-creationv3.12.0
- drizzle-orm-d1v3.12.0
- feature-devv3.12.0
- frontend-designv3.12.0
- gemini-cliv3.12.0
- github-project-automationv3.12.0
- graphql-implementationv3.12.0
- health-check-endpointsv3.12.0
- hono-routingv3.12.0
- hugov3.12.0
- humanize-writingv3.12.0
- idempotency-handlingv3.12.0
- image-optimizationv3.12.0
Similar to bun
More Developer Tools
bun-sveltekitSkillsecondsky/claude-skills440 installsGuide for building and running SvelteKit apps on Bun, covering SSR, the Bun adapter, and Bun-specific APIs.
nitroSkillantfu/skills3K installsFramework-agnostic server toolkit for building and deploying web servers across many runtimes.
base44Pluginanthropics/claude-plugins-official47.9K starsBuild and deploy Base44 full-stack apps with CLI project management and JavaScript/TypeScript SDK development skills
vercel-pluginPluginvercel/vercel-plugin338 starsBuild and deploy web apps and agents
better-t-stackPluginAmanVarshney01/create-better-t-stack5.9K starsLet your AI scaffold and extend projects with Better-T-Stack. Bundles the create-better-t-stack MCP server plus skills, commands, and an agent so the assistant
