bun-dev_skill
- TypeScript
25
GitHub Stars
1
Bundled Files
3 weeks ago
Catalog Refreshed
2 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstart where the catalogue uses aiagentskills.
npx veilstart add skill outfitter-dev/agents --skill bun-dev- SKILL.md10.1 KB
Overview
This skill provides concise guidance and patterns for developing with the Bun runtime, including Bun.serve, bun:sqlite, bun:test, and Bun native APIs. It focuses on idiomatic, zero-dependency workflows: file I/O, SQLite usage, HTTP and WebSocket servers, testing, password hashing, shell integration, and building. Use it to replace Node-centric patterns with Bun-native alternatives and to follow safe, high-performance defaults.
How this skill works
The skill inspects mentions of Bun, bun:test, Bun.serve, bun:sqlite, and other Bun-specific patterns and returns targeted advice, code snippets, and best practices. It highlights native APIs like Bun.file, Bun.write, Bun.password, Bun.serve, and bun:sqlite, and maps common tasks—database queries, transactions, file streaming, testing, and builds—to Bun idioms. It also enforces safety rules: prepared statements, environment validation, and proper resource cleanup.
When to use it
- Building HTTP or WebSocket servers with Bun.serve or Hono on Bun
- Working with SQLite using bun:sqlite for local databases and transactions
- Writing scripts that read/write files or stream large payloads with Bun.file and Bun.write
- Running tests and coverage with bun:test and test lifecycle hooks
- Hashing and verifying passwords using Bun.password for secure auth flows
- Executing shell commands and CI tasks via the $ template and Bun.spawn
Best practices
- Prefer Bun native APIs (Bun.file, Bun.write, Bun.env) over Node fs/process shims
- Always use prepared statements and named parameters for SQL to avoid injection
- Use transactions for multi-step DB operations and close Database instances when done
- Hash passwords with argon2id and verify via Bun.password; never store plaintext
- Validate environment variables at startup with a schema (zod recommended)
- Use bun:test watch/coverage for fast feedback and isolate DB state in beforeEach/afterEach
Example use cases
- Create a small API with Bun.serve and route handling via Hono, serving JSON and static assets
- Implement user registration: hash passwords, insert into bun:sqlite using prepared statements, return safe responses
- Build a CLI or background job that reads large files with Bun.file.stream and writes processed output with Bun.write
- Write fast unit and integration tests with bun:test using in-memory SQLite and lifecycle hooks
- Bundle a production binary with bun build --compile for distribution across platforms
FAQ
Some Node code works, but prefer Bun-native APIs for performance and compatibility. Replace deprecated Node APIs with Bun.file, Bun.write, Bun.env, and bun:sqlite where possible.
How should I handle migrations and pooling with bun:sqlite?
Use prepared migration patterns and a lightweight pooling/repository approach documented in migration patterns. Keep long-lived Database instances controlled and close them when no longer needed.