Bun.js validation hook plus five skills for runtime, testing, bundling, packages, and SQLite.
- CCM score
- 48 of 100
- GitHub stars
- 201
Own this plugin? Claim it
What it does
- Adds five skills:
bun-runtime,bun-testing,bun-bundler,bun-package-manager, andbun-sqlite, plus a validation hook - Covers file I/O,
Bun.serve()HTTP servers, the built-in test runner, tree-shaking, and workspaces with lockfile migration - Runs
bun build --target=bun --no-bundleas a type check when a conversation or agent task finishes - Designed for developers building TypeScript projects on Bun who want type-level feedback without full bundling
Validation and quality enforcement for Bun.js projects with runtime, testing, bundler, package manager, and SQLite skills.
Add marketplace
/plugin marketplace add TheBushidoCollective/hanRun it inside Claude Code once, then install the plugin below.
Install
/plugin install bun@hanRun it inside Claude Code after adding the marketplace.
Files
Discovered from sourceBun Bundler
Use this skill when bundling JavaScript/TypeScript applications with Bun's built-in bundler, which provides exceptional performance and modern features.
Key Concepts
Basic Bundling
Bun can bundle your code for different targets:
# Bundle for Bun runtime
bun build ./src/index.ts --outdir ./dist
# Bundle for browsers
bun build ./src/index.ts --outdir ./dist --target=browser
# Bundle for Node.js
bun build ./src/index.ts --outdir ./dist --target=node
# Minify output
bun build ./src/index.ts --outdir ./dist --minify
Programmatic API
Use Bun's build API in TypeScript:
import { build } from "bun";
await build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
target: "bun",
minify: true,
sourcemap: "external",
});
Build Targets
Bun supports multiple build targets:
bun- Optimized for Bun runtime (default)browser- Browser-compatible bundlenode- Node.js-compatible bundle
Output Formats
Control output format:
await build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
format: "esm", // or "cjs", "iife"
});
Best Practices
Entry Points Configuration
Define multiple entry points for complex applications:
await build({
entrypoints: [
"./src/client/index.ts",
"./src/server/index.ts",
"./src/worker.ts",
],
outdir: "./dist",
naming: {
entry: "[dir]/[name].[ext]",
chunk: "[name]-[hash].[ext]",
asset: "assets/[name]-[hash].[ext]",
},
});
Tree Shaking
Bun automatically tree-shakes unused code:
// utils.ts
export function used() {
return "used";
}
export function unused() {
return "unused";
}
// index.ts
import { used } from "./utils";
console.log(used()); // Only 'used' function will be bundled
Code Splitting
Split code for better loading performance:
await build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
splitting: true, // Enable code splitting
target: "browser",
});
Environment Variables
Replace environment variables at build time:
await build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
define: {
"process.env.API_URL": JSON.stringify("https://api.example.com"),
"process.env.NODE_ENV": JSON.stringify("production"),
},
});
External Dependencies
Mark dependencies as external to exclude from bundle:
await build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
external: ["react", "react-dom"], // Don't bundle React
target: "browser",
});
Source Maps
Generate source maps for debugging:
await build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
sourcemap: "external", // or "inline", "none"
minify: true,
});
Common Patterns
Building a Library
// build.ts
import { build } from "bun";
// ESM build
await build({
entrypoints: ["./src/index.ts"],
outdir: "./dist/esm",
format: "esm",
target: "node",
minify: true,
sourcemap: "external",
});
// CJS build
await build({
entrypoints: ["./src/index.ts"],
outdir: "./dist/cjs",
format: "cjs",
target: "node",
minify: true,
sourcemap: "external",
});
console.log("Build complete!");
Building a Web Application
// build.ts
import { build } from "bun";
await build({
entrypoints: ["./src/index.tsx"],
outdir: "./dist",
target: "browser",
format: "esm",
minify: true,
splitting: true,
sourcemap: "external",
publicPath: "/assets/",
naming: {
entry: "[dir]/[name].[ext]",
chunk: "[name]-[hash].[ext]",
asset: "assets/[name]-[hash].[ext]",
},
define: {
"process.env.NODE_ENV": JSON.stringify("production"),
},
});
Building Multiple Outputs
// build.ts
import { build } from "bun";
const builds = [
{
entrypoints: ["./src/index.ts"],
outdir: "./dist/esm",
format: "esm" as const,
target: "browser" as const,
},
{
entrypoints: ["./src/index.ts"],
outdir: "./dist/cjs",
format: "cjs" as const,
target: "node" as const,
},
{
entrypoints: ["./src/index.ts"],
outdir: "./dist/iife",
format: "iife" as const,
target: "browser" as const,
},
];
for (const config of builds) {
await build({
...config,
minify: true,
sourcemap: "external",
});
}
console.log("All builds complete!");
Build Script with Watching
// watch-build.ts
import { watch } from "fs";
import { build } from "bun";
async function buildApp() {
console.log("Building...");
await build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
target: "bun",
});
console.log("Build complete!");
}
// Initial build
await buildApp();
// Watch for changes
watch("./src", { recursive: true }, async (event, filename) => {
console.log(`File changed: ${filename}`);
await buildApp();
});
Plugin System
Create custom build plugins:
import type { BunPlugin } from "bun";
const myPlugin: BunPlugin = {
name: "my-plugin",
setup(build) {
build.onLoad({ filter: /\.custom$/ }, async (args) => {
const text = await Bun.file(args.path).text();
return {
contents: `export default ${JSON.stringify(text)}`,
loader: "js",
};
});
},
};
await build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
plugins: [myPlugin],
});
Anti-Patterns
Don't Bundle Node Modules for Node Target
// Bad - Bundling all dependencies for Node
await build({
entrypoints: ["./src/server.ts"],
target: "node",
// Missing external configuration
});
// Good - Mark dependencies as external
await build({
entrypoints: ["./src/server.ts"],
target: "node",
external: ["express", "mongoose", "*"], // "*" excludes all node_modules
});
Don't Ignore Build Errors
// Bad - No error handling
await build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
});
// Good - Handle build errors
try {
const result = await build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
});
if (!result.success) {
console.error("Build failed");
process.exit(1);
}
console.log("Build succeeded");
} catch (error) {
console.error("Build error:", error);
process.exit(1);
}
Don't Minify Development Builds
// Bad - Always minifying
await build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
minify: true, // Hard to debug in development
});
// Good - Conditional minification
const isDev = Bun.env.NODE_ENV === "development";
await build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
minify: !isDev,
sourcemap: isDev ? "inline" : "external",
});
Don't Over-Split Code
// Bad - Excessive code splitting
await build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
splitting: true,
target: "bun", // Code splitting not needed for Bun target
});
// Good - Split only when beneficial
await build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
splitting: true,
target: "browser", // Beneficial for browsers
});
Related Skills
- bun-runtime: Understanding Bun's runtime for target optimization
- bun-package-manager: Managing build dependencies
- bun-testing: Testing bundled code
Readme
Bun
Validation and quality enforcement for Bun.js projects.
What This Plugin Provides
Validation Hooks
- Bun Type Check: Runs Bun's build type checker to ensure TypeScript code is valid
- Fast Validation: Leverages Bun's exceptional performance for rapid feedback
Skills
This plugin provides the following skills:
- bun-runtime: Working with Bun's runtime APIs including file I/O, HTTP servers, WebSockets, and native APIs
- bun-testing: Writing tests with Bun's built-in test runner, assertions, mocking, and snapshot testing
- bun-bundler: Bundling JavaScript/TypeScript code with Bun's fast bundler for different targets
- bun-package-manager: Managing dependencies with Bun's package manager, workspaces, and lockfiles
- bun-sqlite: Working with SQLite databases using Bun's built-in high-performance SQLite driver
Installation
han plugin install bun
Usage
Once installed, this plugin automatically validates your Bun code:
- When you finish a conversation with Claude Code
- When Claude Code agents complete their work
- Before commits (when combined with git hooks)
The validation runs bun build --target=bun --no-bundle to check for type errors without actually bundling your code.
Requirements
- Bun 1.0.0 or higher
- TypeScript (for type checking)
Why Bun?
Bun is an all-in-one JavaScript runtime and toolkit designed for speed:
- Fast Runtime: 3x faster than Node.js for many operations
- Built-in Tools: Bundler, test runner, package manager all included
- Web Standard APIs: First-class support for Web APIs like fetch, WebSocket
- TypeScript Native: Run TypeScript and JSX directly without transpilation
- npm Compatible: Works with existing npm packages
- SQLite Built-in: High-performance SQLite driver included
Features Covered by Skills
Runtime APIs
- File I/O with
Bun.file()andBun.write() - HTTP servers with
Bun.serve() - WebSocket support
- Password hashing
- Environment variables
- Shell command execution with
Bun.$
Testing
- Built-in test runner
- Jest-compatible API
- Mocking and spies
- Snapshot testing
- Coverage reporting
- Watch mode
Bundler
- Fast bundling for multiple targets (bun, browser, node)
- Tree shaking
- Code splitting
- Minification
- Source maps
- Plugin system
Package Manager
- Fast dependency installation
- Binary lockfile (bun.lockb)
- Workspace support for monorepos
- npm/yarn/pnpm compatibility
- Global packages
- Link local packages
SQLite
- Native SQLite driver
- Prepared statements
- Transactions
- Migration support
- High performance
Examples
Create a Simple HTTP Server
Bun.serve({
port: 3000,
fetch(req) {
return new Response("Hello from Bun!");
},
});
Run Tests
import { test, expect } from "bun:test";
test("addition", () => {
expect(1 + 1).toBe(2);
});
Bundle Your Code
bun build src/index.ts --outdir dist --target browser --minify
Install Dependencies
bun add express
bun add -d @types/express
Use SQLite
import { Database } from "bun:sqlite";
const db = new Database("mydb.sqlite");
db.run("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)");
db.run("INSERT INTO users (name) VALUES (?)", ["Alice"]);
Details
- Marketplace
- TheBushidoCollective/han
- Source
- plugins/tools/bun
- Category
- Tool
- Keywords
- bun, javascript, typescript, runtime, testing, bundler
- Listed since
- Apr 7, 2026
More from TheBushidoCollective/han
All 340Similar to bun
More Developer Toolsjutsu-bunPluginTheBushidoCollective/han201 starsValidation and quality enforcement for Bun.js projects with runtime, testing, bundler, package manager, and SQLite skills.
clippyPluginTheBushidoCollective/han201 starsComprehensive Clippy skills for Rust linting and code quality with lint configuration, categories, and custom lint development.
unit-testingPluginwshobson/agents42.9K starsUnit and integration test automation for Python and JavaScript with debugging support
elysiajsSkillelysiajs/skills14.8K installsComprehensive Elysia v2 TypeScript backend skill for building, debugging, and migrating typed APIs with validation and plugins.