bun
Bun JavaScript runtime. Fast all-in-one toolkit with bundler, test runner, package manager. Use when working with Bun projects or considering Node.js alternatives. USE WHEN: user mentions "bun", "bun test", "bun build", asks about "Bun.serve", "bun install", "SQLite in Bun", "bunx", "performance comparison" DO NOT USE FOR: Node.js runtime - use `nodejs` skill instead DO NOT USE FOR: Hono/Elysia frameworks - use framework-specific skills DO NOT USE FOR: Language syntax - use `typescript` or `javascript` skills
What this skill does
# Bun - Quick Reference
> **Deep Knowledge**: Use `mcp__documentation__fetch_docs` with technology: `bun` for comprehensive documentation.
## When to Use This Skill
- Projects requiring high performance
- Replacement for Node.js + npm + bundler
- Fast test runner alternative to Vitest/Jest
- Quick scripts with native TypeScript
## Setup
```bash
# Install Bun
curl -fsSL https://bun.sh/install | bash
# Create project
bun init
# Run TypeScript directly (no compilation needed!)
bun run index.ts
# Run with watch mode
bun --watch run index.ts
```
## Package Manager
```bash
# Install dependencies (faster than npm/pnpm)
bun install
# Add packages
bun add express zod
bun add -d typescript @types/node
# Remove
bun remove package-name
# Update
bun update
# Run scripts
bun run build
bun run dev
# Execute binary
bunx prisma generate
```
### Workspaces
```json
// package.json
{
"workspaces": ["packages/*"]
}
```
```bash
# Install all workspace deps
bun install
# Run in specific workspace
bun run --filter @myorg/api build
```
## Bundler
```typescript
// Build for production
await Bun.build({
entrypoints: ['./src/index.ts'],
outdir: './dist',
target: 'node', // 'browser' | 'bun'
minify: true,
sourcemap: 'external',
splitting: true, // Code splitting
format: 'esm', // 'cjs' | 'esm'
});
// CLI
bun build ./src/index.ts --outdir ./dist --minify
```
### Build Config
```typescript
// bunfig.toml alternative - build.ts
const result = await Bun.build({
entrypoints: ['./src/index.tsx'],
outdir: './dist',
target: 'browser',
minify: {
whitespace: true,
identifiers: true,
syntax: true,
},
define: {
'process.env.NODE_ENV': '"production"',
},
external: ['react', 'react-dom'],
loader: {
'.png': 'file',
'.svg': 'text',
},
});
if (!result.success) {
console.error('Build failed:', result.logs);
process.exit(1);
}
```
## Test Runner
```typescript
// math.test.ts
import { describe, it, expect, beforeAll, mock } from 'bun:test';
describe('math', () => {
it('adds numbers', () => {
expect(1 + 2).toBe(3);
});
it('handles async', async () => {
const result = await fetchData();
expect(result).toBeDefined();
});
});
// Mocking
const mockFn = mock(() => 42);
mockFn();
expect(mockFn).toHaveBeenCalled();
// Module mocking
mock.module('./config', () => ({
apiUrl: 'http://test.local',
}));
```
```bash
# Run tests
bun test
# Watch mode
bun test --watch
# Coverage
bun test --coverage
# Filter
bun test --filter "user"
```
## HTTP Server
```typescript
// Native Bun server (fastest)
Bun.serve({
port: 3000,
fetch(req) {
const url = new URL(req.url);
if (url.pathname === '/api/health') {
return Response.json({ status: 'ok' });
}
if (url.pathname === '/api/users' && req.method === 'POST') {
const body = await req.json();
return Response.json({ id: 1, ...body }, { status: 201 });
}
return new Response('Not Found', { status: 404 });
},
error(error) {
return new Response(`Error: ${error.message}`, { status: 500 });
},
});
console.log('Server running on http://localhost:3000');
```
### With Hono (recommended for APIs)
```typescript
import { Hono } from 'hono';
import { cors } from 'hono/cors';
import { logger } from 'hono/logger';
const app = new Hono();
app.use('*', logger());
app.use('/api/*', cors());
app.get('/api/users', (c) => {
return c.json([{ id: 1, name: 'John' }]);
});
app.post('/api/users', async (c) => {
const body = await c.req.json();
return c.json({ id: 1, ...body }, 201);
});
export default app;
```
## File I/O
```typescript
// Read file (returns string or ArrayBuffer)
const text = await Bun.file('data.txt').text();
const json = await Bun.file('data.json').json();
const buffer = await Bun.file('image.png').arrayBuffer();
// Write file
await Bun.write('output.txt', 'Hello World');
await Bun.write('data.json', JSON.stringify(data));
// Stream large files
const file = Bun.file('large.csv');
const stream = file.stream();
for await (const chunk of stream) {
process.stdout.write(chunk);
}
// File metadata
const file = Bun.file('data.txt');
console.log(file.size); // bytes
console.log(file.type); // MIME type
```
## SQLite (Built-in)
```typescript
import { Database } from 'bun:sqlite';
const db = new Database('app.db');
// Create table
db.run(`
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
email TEXT UNIQUE
)
`);
// Prepared statements (recommended)
const insert = db.prepare('INSERT INTO users (name, email) VALUES (?, ?)');
insert.run('John', '[email protected]');
const select = db.prepare('SELECT * FROM users WHERE id = ?');
const user = select.get(1);
// Query all
const all = db.prepare('SELECT * FROM users').all();
// Transaction
db.transaction(() => {
insert.run('Alice', '[email protected]');
insert.run('Bob', '[email protected]');
})();
```
## Environment Variables
```typescript
// .env file loaded automatically
const apiKey = Bun.env.API_KEY;
const port = Bun.env.PORT ?? '3000';
// process.env also works
const nodeEnv = process.env.NODE_ENV;
```
## Shell Commands
```typescript
import { $ } from 'bun';
// Simple command
const result = await $`ls -la`;
console.log(result.stdout.toString());
// With variables (auto-escaped)
const filename = 'my file.txt';
await $`cat ${filename}`;
// Piping
const files = await $`ls`.text();
const count = await $`echo ${files} | wc -l`.text();
// Error handling
try {
await $`exit 1`;
} catch (error) {
console.error('Command failed:', error.exitCode);
}
```
## Configuration (bunfig.toml)
```toml
# bunfig.toml
[install]
# Registry
registry = "https://registry.npmjs.org"
# Frozen lockfile in CI
frozenLockfile = true
[run]
# Shell for scripts
shell = "bash"
[test]
# Test configuration
coverage = true
coverageDir = "coverage"
```
## Node.js Compatibility
```typescript
// Most Node.js APIs work
import { readFile } from 'fs/promises';
import { createServer } from 'http';
import path from 'path';
// Some differences
import.meta.dir; // __dirname equivalent
import.meta.file; // __filename equivalent
// Check runtime
const isBun = typeof Bun !== 'undefined';
```
---
## When NOT to Use This Skill
| Scenario | Use Instead |
|----------|-------------|
| Node.js runtime specifics | `nodejs` skill |
| Hono framework | Framework-specific skill |
| Elysia framework | Framework-specific skill |
| TypeScript syntax | `typescript` skill |
| Testing strategies | `testing-vitest` skill |
---
## Anti-Patterns
| Anti-Pattern | Why It's Bad | Correct Approach |
|--------------|--------------|------------------|
| Using node_modules/.bin | Not optimized for Bun | Use bunx instead |
| Ignoring compatibility | Some npm packages fail | Test compatibility |
| Complex routing in Bun.serve | Hard to maintain | Use Hono or Elysia |
| Not pinning versions | Breaking changes | Use bun.lockb |
| Mixing package managers | Inconsistent deps | Stick to bun |
| Not using built-in SQLite | Extra dependency | Use bun:sqlite |
| Blocking operations | Defeats performance | Use async APIs |
| Not using watch mode | Slow dev loop | Use --watch flag |
---
## Quick Troubleshooting
| Issue | Cause | Solution |
|-------|-------|----------|
| "Module not found" | npm compatibility issue | Check Bun compatibility list |
| "bun: command not found" | Not installed | Install Bun or add to PATH |
| Tests fail in Bun but not Jest | Different runtime | Check Bun-specific APIs |
| Slow install | Network/cache issue | Clear cache with bun pm cache |
| "Cannot find package" | Wrong specifier | Use npm: prefix for npm packages |
| Type errors with .ts files | tsconfig mismatch | Check Bun's default config |
| Build output incorrect | Wrong target | Set target in Bun.build |
| SQLite errors | Database locked | Close connections properly |
---
## Performance Comparison
| Task | Bun | Node.js |
|--Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.