Skip to content
Cursor Rules Generator
Backend4 sections

Bun Cursor Rules Template

Generate production-ready Bun Cursor rules for Project Rules (.mdc), AGENTS.md, or legacy .cursorrules. This template encodes stack-specific conventions for projects using Bun. All-in-one JavaScript runtime with bundler, test runner, and TypeScript support.

The Complete Bun Cursor Rules

The full rule set in all three formats Cursor understands — copy the one your project uses. Project Rules (.mdc) load per-file via globs, AGENTS.md is portable across AI tools, and .cursorrules is the legacy single-file format.

Replacing a legacy file? Read the guide to migrate .cursorrules to Cursor Project Rules (.mdc) before copying this template into your project.

.cursor/rules/bun-runtime.mdc
---
description: "Bun Runtime Features"
alwaysApply: false
---
- Use Bun's built-in APIs: Bun.file(), Bun.write(), Bun.serve() instead of Node.js equivalents.
- Use Bun's native TypeScript support — no need for ts-node or separate compilation step.
- Use Bun's built-in test runner (bun test) instead of Jest or Vitest for new projects.
- Use Bun's native SQLite client (bun:sqlite) for embedded database needs.
- Use Bun's built-in environment variable support via Bun.env instead of process.env.
- Use Bun.password for password hashing and Bun.randomUUIDv7 for unique IDs.
- Leverage Bun's fetch() built-in — no need for node-fetch or axios for HTTP.
.cursor/rules/bun-performance.mdc
---
description: "Performance Patterns"
alwaysApply: false
---
- Use Bun's native file I/O (Bun.file, Bun.write) which is significantly faster than Node.js fs.
- Use Bun.spawn() for subprocess management — faster and simpler than child_process.
- Prefer Bun.serve() over Express or other Node HTTP frameworks for maximum throughput.
- Use Bun's built-in WebSocket support for real-time applications.
- Avoid blocking the event loop — use async/await and Bun's Promise-based APIs.
- Use Bun's bundler (Bun.build) for production builds with tree-shaking and minification.
- Leverage Bun's transpiler for JSX/TSX without additional Babel or TypeScript config.
.cursor/rules/bun-project-structure.mdc
---
description: "Project Structure & Configuration"
alwaysApply: false
---
- Use bunfig.toml for project-level Bun configuration (install settings, lockfile path).
- Use bun.lockb as the lockfile — commit it to version control for reproducible installs.
- Use    spaces for indentation in .ts/.tsx files.
- Use camelCase for variables and functions.
- Use {{QUOTES}} quotes for strings.
- Use ESM imports/exports — Bun is ESM-first.
- Organize code by feature: src/features/<feature>/ with index.ts barrel exports.
- Use bun add for package installation and bun remove for removal.

Customize These Rules

The generator below is preloaded with the Bun template. Adjust indentation, quotes, naming, add your own rules, then download — no need to start from scratch on the homepage.

What This Template Covers

Required guidance

  • - Bun Runtime Features
  • - Performance Patterns
  • - Project Structure & Configuration

Default style

  • - Indentation: 2 spaces
  • - Quotes: single
  • - Semicolons: enabled
  • - Naming: camelCase

Optional sections: Testing with Bun.

Frequently Asked Questions

What does the Bun Cursor rules template include?
It includes 4 rule sections covering bun runtime features, performance patterns, project structure & configuration and other Bun development conventions.
Can I generate Bun Project Rules and AGENTS.md from the same template?
Yes. The generator can export the same stack-specific guidance as modern Project Rules (.mdc), AGENTS.md, or a legacy .cursorrules file.
Should I combine Bun with other Cursor rules templates?
Yes. You can combine Bun with related templates such as TypeScript, Tailwind CSS, Docker, or backend frameworks when your project uses multiple technologies.