This skill should be used when working with Bun runtime, bun:sqlite, Bun.serve, bun:test, or when Bun, bun:test, or Bun-specific patterns are mentioned.
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
Instruções da origem · Visualização somente leitura
name
bun-fieldguide
description
This skill should be used when working with Bun runtime, bun:sqlite, Bun.serve, bun:test, or when Bun, bun:test, or Bun-specific patterns are mentioned.
metadata
{"version":"1.0.1"}
Bun Development
Bun runtime → native APIs → zero-dependency patterns.
<when_to_use>
Bun runtime development
SQLite database with bun:sqlite
HTTP server with Bun.serve
Testing with bun:test
File operations with Bun.file/Bun.write
Shell operations with $ template
Password hashing with Bun.password
Environment variable handling
Building and bundling
NOT for: Node.js-only patterns, cross-runtime libraries, non-Bun projects
</when_to_use>
<runtime_basics>
Package management:
bun install # Install deps
bun add zod # Add package
bun remove zod # Remove package
bun update # Update all
Script execution:
bun run dev # Run package.json script
bun run src/index.ts # Execute TypeScript directly
bun --watch index.ts # Watch mode
Testing:
bun test
bun src/
bun --watch
bun --coverage
# All tests
test
# Directory
test
# Watch mode
test
# With coverage
Building:
bun build ./index.ts --outfile dist/bundle.js
bun build ./index.ts --compile --outfile myapp # Standalone executable
import { Database } from"bun:sqlite";
const db = newDatabase("app.db", {
create: true,
readwrite: true,
strict: true,
});
// Create tables
db.run(`
CREATE TABLE IF NOT EXISTS users (
id TEXT PRIMARY KEY,
email TEXT UNIQUE NOT NULL,
name TEXT NOT NULL,
created_at TEXT DEFAULT CURRENT_TIMESTAMP
)
`);
// Prepared statements (always use these)const getUser = db.prepare("SELECT * FROM users WHERE id = ?");
const createUser = db.prepare(
"INSERT INTO users (id, email, name) VALUES (?, ?, ?) RETURNING *"
);
// Executionconst user = getUser.get("user-123"); // Single rowconst all = db.prepare("SELECT * FROM users").all(); // All rows
db.prepare("DELETE FROM users WHERE id = ?").run("id"); // No return// Named parametersconst stmt = db.prepare("SELECT * FROM users WHERE email = $email");
stmt.get({ $email: "alice@example.com" });
// Transactions (atomic, auto-rollback on error)const transfer = db.transaction(
(fromId: string, toId: string, amount: number) => {
db.run("UPDATE accounts SET balance = balance - ? WHERE id = ?", [
amount,
fromId,
]);
db.run("UPDATE accounts SET balance = balance + ? WHERE id = ?", [
amount,
toId,
]);
}
);
transfer("alice", "bob", 100);
db.close(); // When done
Level up: Load the bun-first skill for migration auditing, dependency elimination, and the decision framework for when to use Bun native APIs over npm packages.