bun-patterns

Detect and enforce Bun-specific API usage in backend TypeScript code.

Updated Dec 3, 2025
One-click install
npx skills add https://github.com/Grips001/Chess-Sensei --skill bun-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bun-patterns
Source: https://github.com/Grips001/Chess-Sensei/tree/main/.claude/skills/bun-patterns
Command: npx skills add https://github.com/Grips001/Chess-Sensei --skill bun-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill checks that backend TypeScript code uses Bun-specific APIs instead of Node.js patterns to improve performance and consistency.

Core Features & Use Cases

  • Bun File I/O Patterns: Use Bun.file() and Bun.write() for file operations.
  • Process & Environment: Prefer Bun.env over process.env for environment variables.
  • HTTP Server Patterns: Write Bun.serve-based HTTP handlers.
  • Use Case: When refactoring backend services to Bun, run this to ensure code adheres to Bun patterns.

Quick Start

Review backend code in src/backend/ to confirm Bun APIs are used instead of Node.js equivalents and run checks across the codebase.

Frequently Asked Questions about bun-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate backend TypeScript code to use Bun APIs instead of Node.js?

Bun APIs like Bun.file(), Bun.write(), Bun.env, and Bun.serve replace Node.js equivalents (fs, fs/promises, process.env). Migrate by replacing import fs statements with Bun file methods, process.env references with Bun.env, and traditional HTTP servers with Bun.serve-based handlers for improved performance and consistency.

What's the difference between Bun file I/O and Node.js fs module?

Bun.file() and Bun.write() provide optimized file operations native to Bun, while Node.js fs and fs/promises require additional imports and lack Bun-specific optimizations. Bun patterns integrate directly with the runtime for faster file operations in backend services.

Can I use process.env in Bun backend code?

While process.env may work, Bun.env is the preferred approach for environment variable access in Bun applications. Using Bun.env ensures consistency with Bun patterns and optimizes for the Bun runtime rather than Node.js compatibility.

How do I verify my backend code follows Bun API patterns?

Run pattern verification on src/backend/ code to detect Node.js imports (fs, fs/promises, process.env) and enforce Bun equivalents (Bun.file, Bun.write, Bun.env, Bun.serve). This automated check ensures backend services adhere to Bun-specific APIs during code reviews and feature development.

What HTTP server patterns should I use with Bun?

Use Bun.serve() to create HTTP handlers instead of traditional Node.js patterns. Bun.serve provides native performance benefits and integrates directly with the Bun runtime for backend applications.

When refactoring to Bun, which Node.js APIs must I replace?

Replace import fs and fs/promises with Bun.file() and Bun.write(), process.env with Bun.env, and HTTP servers with Bun.serve(). These are the core Node.js patterns disallowed when enforcing Bun API compliance in backend code.