Bun
Validation and quality enforcement for Bun.js projects.
Installation
First, install the Han CLI tool:
npm install -g @thebushidocollective/hanThen install the plugin:
han plugin install buki-bunOverview
Validation and quality enforcement for Bun.js projects.
What This Buki 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 buki 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
Install via the Han marketplace:
npx @thebushidocollective/han install
Or install manually:
claude plugin marketplace add thebushidocollective/han
claude plugin install buki-bun@han
Usage
Once installed, this buki 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"]);
Contributing
See CONTRIBUTING.md for guidelines.
License
MIT License - See LICENSE for details.
Skills
buki-bun:bun-bundler
Use when bundling JavaScript/TypeScript code with Bun's fast bundler. Covers building for different targets, tree-shaking, code splitting, and optimization strategies.
buki-bun:bun-package-manager
Use when managing dependencies with Bun's package manager. Covers installing packages, workspaces, lockfiles, and migrating from npm/yarn/pnpm to Bun.
buki-bun:bun-runtime
Use when working with Bun's runtime APIs including file I/O, HTTP servers, and native APIs. Covers modern JavaScript/TypeScript execution in Bun's fast runtime environment.
buki-bun:bun-sqlite
Use when working with SQLite databases in Bun. Covers Bun's built-in SQLite driver, database operations, prepared statements, and transactions with high performance.
buki-bun:bun-testing
Use when writing tests with Bun's built-in test runner. Covers test organization, assertions, mocking, and snapshot testing using Bun's fast test infrastructure.
Hooks
Stop
Runs when the main Claude Code agent has finished responding.
npx -y @thebushidocollective/han hook run --fail-fast --dirs-with package.json -- bun build --target=bun --no-bundleSubagentStop
Runs when a Claude Code subagent (Task tool call) has finished responding.
npx -y @thebushidocollective/han hook run --fail-fast --dirs-with package.json -- bun build --target=bun --no-bundle