Configures Bun as an all-in-one JavaScript runtime, bundler, package manager, and test runner with native TypeScript support. Use when building fast applications, bundling for production, or replacing Node.js tooling.
Provides Bun commands for running TypeScript/JavaScript, bundling applications, managing packages, and executing tests with native speed. Use when building applications, bundling for production, or replacing Node.js tooling.
/plugin marketplace add mgd34msu/goodvibes-plugin/plugin install goodvibes@goodvibes-marketThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/api.mdreferences/migration.mdAll-in-one JavaScript runtime, bundler, package manager, and test runner written in Zig.
# Install Bun
curl -fsSL https://bun.sh/install | bash
# Or with npm
npm install -g bun
# Run TypeScript directly
bun run src/index.ts
# Install packages
bun install
# Bundle for production
bun build src/index.ts --outdir=dist
# Run TypeScript/JavaScript
bun run index.ts
bun run index.js
bun run index.jsx
bun run index.tsx
# Run package.json scripts
bun run dev
bun run build
# Shorthand for run
bun dev
bun build
# Auto-restart on changes
bun --watch run index.ts
# Hot reload (preserves state)
bun --hot run index.ts
# Load .env automatically
bun run index.ts
# Specify env file
bun --env-file=.env.local run index.ts
# No env file
bun --no-env-file run index.ts
# Install all dependencies
bun install
# Add package
bun add express
bun add -D typescript
# Add exact version
bun add react@18.2.0
# Global install
bun add -g typescript
# Remove package
bun remove lodash
# Update packages
bun update
bun update react
# Generate/update bun.lockb
bun install
# Frozen install (CI)
bun install --frozen-lockfile
# Convert to yarn.lock
bun pm pack
# Bundle for browser
bun build src/index.ts --outdir=dist
# Single file output
bun build src/index.ts --outfile=dist/bundle.js
# Minify
bun build src/index.ts --outdir=dist --minify
# Source maps
bun build src/index.ts --outdir=dist --sourcemap=external
// build.ts
const result = await Bun.build({
entrypoints: ['./src/index.tsx'],
outdir: './dist',
minify: true,
sourcemap: 'external',
target: 'browser',
splitting: true,
format: 'esm',
});
if (!result.success) {
console.error('Build failed:', result.logs);
process.exit(1);
}
console.log('Build complete!', result.outputs);
await Bun.build({
entrypoints: ['./src/index.ts', './src/worker.ts'],
outdir: './dist',
// Target
target: 'browser', // 'browser' | 'bun' | 'node'
// Format
format: 'esm', // 'esm' | 'cjs' | 'iife'
// Optimization
minify: {
whitespace: true,
identifiers: true,
syntax: true,
},
sourcemap: 'external', // 'none' | 'inline' | 'external' | 'linked'
// Code splitting
splitting: true,
// Naming
naming: {
entry: '[dir]/[name].[ext]',
chunk: 'chunks/[name]-[hash].[ext]',
asset: 'assets/[name]-[hash].[ext]',
},
// Externals
external: ['react', 'react-dom'],
// Define
define: {
'process.env.NODE_ENV': JSON.stringify('production'),
},
// Loaders
loader: {
'.png': 'file',
'.svg': 'dataurl',
},
// Public path
publicPath: '/assets/',
// Plugins
plugins: [],
});
const myPlugin = {
name: 'my-plugin',
setup(build) {
// Resolve hook
build.onResolve({ filter: /^env$/ }, (args) => {
return { path: args.path, namespace: 'env-ns' };
});
// Load hook
build.onLoad({ filter: /.*/, namespace: 'env-ns' }, () => {
return {
contents: `export const API = "${process.env.API_URL}"`,
loader: 'js',
};
});
},
};
await Bun.build({
entrypoints: ['./src/index.ts'],
plugins: [myPlugin],
});
# Run all tests
bun test
# Specific file
bun test src/utils.test.ts
# Pattern matching
bun test --test-name-pattern "should handle"
# Watch mode
bun test --watch
# Coverage
bun test --coverage
// math.test.ts
import { describe, test, expect, beforeEach, mock } from 'bun:test';
describe('math', () => {
test('adds numbers', () => {
expect(1 + 2).toBe(3);
});
test('async operations', async () => {
const result = await fetchData();
expect(result).toBeDefined();
});
});
// Mocking
const mockFn = mock(() => 42);
mockFn();
expect(mockFn).toHaveBeenCalled();
// Spying
import * as module from './module';
const spy = spyOn(module, 'someFunction');
// bunfig.toml
[test]
root = "./tests"
timeout = 5000
preload = ["./setup.ts"]
coverage = true
coverageReporter = ["text", "lcov"]
const server = Bun.serve({
port: 3000,
hostname: '0.0.0.0',
fetch(req) {
const url = new URL(req.url);
if (url.pathname === '/') {
return new Response('Hello World!');
}
if (url.pathname === '/api/data') {
return Response.json({ message: 'Hello' });
}
return new Response('Not Found', { status: 404 });
},
// WebSocket support
websocket: {
message(ws, message) {
ws.send(`Echo: ${message}`);
},
open(ws) {
console.log('Client connected');
},
close(ws) {
console.log('Client disconnected');
},
},
});
console.log(`Server running at http://localhost:${server.port}`);
Bun.serve({
port: 3000,
async fetch(req) {
const url = new URL(req.url);
const filePath = `./public${url.pathname}`;
const file = Bun.file(filePath);
if (await file.exists()) {
return new Response(file);
}
return new Response('Not Found', { status: 404 });
},
});
// Read text
const text = await Bun.file('file.txt').text();
// Read JSON
const json = await Bun.file('data.json').json();
// Read ArrayBuffer
const buffer = await Bun.file('image.png').arrayBuffer();
// Check existence
const exists = await Bun.file('file.txt').exists();
// Get file info
const file = Bun.file('file.txt');
console.log(file.size, file.type);
// Write text
await Bun.write('output.txt', 'Hello World');
// Write JSON
await Bun.write('data.json', JSON.stringify(data, null, 2));
// Write Buffer
await Bun.write('output.bin', buffer);
// Append
const file = Bun.file('log.txt');
await Bun.write(file, await file.text() + '\nNew line');
import { $ } from 'bun';
// Simple command
await $`echo "Hello World"`;
// With variables
const name = 'World';
await $`echo "Hello ${name}"`;
// Capture output
const result = await $`ls -la`.text();
// Check exit code
const { exitCode } = await $`npm test`.nothrow();
// Pipe commands
await $`cat file.txt | grep "pattern"`;
// Environment variables
await $`API_KEY=${key} node script.js`;
# Compile to single executable
bun build --compile src/cli.ts --outfile my-cli
# Cross-compile
bun build --compile --target=bun-linux-x64 src/cli.ts
bun build --compile --target=bun-darwin-arm64 src/cli.ts
bun build --compile --target=bun-windows-x64 src/cli.ts
# Package manager
[install]
registry = "https://registry.npmjs.org"
scope = { "@company" = "https://private.registry.com" }
# Bundler
[bundle]
entrypoints = ["./src/index.ts"]
outdir = "./dist"
minify = true
sourcemap = "external"
# Test runner
[test]
root = "./tests"
preload = ["./setup.ts"]
timeout = 5000
# Development server
[serve]
port = 3000
See references/api.md for complete API reference and references/migration.md for Node.js migration guide.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.