bun

bun is a cursor rule for coding agents from heyAyushh/stacc. It costs 0 tokens per session (2,455 once invoked), scanned A, a copy of bun, MIT.

A set of coding rules for Bun, a JavaScript and TypeScript runtime with built-in tools for installing packages, running code, testing, and building applications.

In plain words
What is it for?
Use it when building or maintaining JavaScript or TypeScript backend services with Bun, including dependency management, tests, and deployment builds.
Why use it?
It gives Bun projects consistent guidance on tooling, backend services, and maintainable code instead of mixing unrelated tools or practices.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/heyayushh/stacc/bun
Clone the repo
git clone --depth 1 https://github.com/heyAyushh/stacc

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for bun

README.md
[![agentmods](https://agentmods.dev/badge/rules/heyayushh/stacc/bun.svg)](https://agentmods.dev/rules/heyayushh/stacc/bun)
Your own site
<a href="https://agentmods.dev/rules/heyayushh/stacc/bun"><img src="https://agentmods.dev/badge/rules/heyayushh/stacc/bun.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 2,455 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin 100% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.02455
Opus 5 $0.00000 $0.01228
Sonnet 5 $0.00000 $0.00491
Haiku 4.5 $0.00000 $0.00246

Measured yesterday against content hash 607e3bab475c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

bun scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

const response = await fetch(url);
Origin

This is a copy

100% identical to bun — 2 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

configs/stacks/bun/bun.mdc · 333 lines

How it starts

The opening of the file, as written. The whole thing — 333 lines — stays where its author put it; the contents beside it link to each section on GitHub.

bun Best Practices

Bun is our go-to runtime for high-performance JavaScript/TypeScript backend services. It's an all-in-one toolkit designed for speed and developer experience. Adhere to these guidelines to maximize Bun's potential and maintain code quality.

1. Embrace Bun's Integrated Toolchain

Bun's strength lies in its unified toolchain. Always default to Bun's built-in features over external alternatives unless a specific project requirement dictates otherwise.

✅ GOOD: Use Bun's native tools

  • Package Management: bun install for dependencies, bun add for new packages.
  • Bundling: bun build for zero-config bundling and standalone executables.
  • Testing: bun test for Jest-compatible testing, including watch mode and coverage.
  • Runtime: bun run or bun <file> for execution.
# Install dependencies (faster than npm/yarn)
bun install

# Add a new package
bun add zod

# Run tests
bun test --coverage

# Build for deployment (e.g., a serverless function)
bun build ./src/index.ts --target=bun --outfile=./dist/server

❌ BAD: Mixing package managers or external bundlers unnecessarily

Avoid npm install or yarn add in Bun projects. Don't use Webpack or Rollup if bun build suffices.

2. Modern JavaScript Language Features

Always use current ECMAScript features (ES2015+). This improves readability, reduces bugs, and aligns with modern development.

✅ GOOD: Modern JS syntax

// 1. Prefer `const` and `let` over `var`
const API_URL = 'https://api.example.com';
let retryCount = 0;

// 2. Use ES Modules for all imports/exports
import { serve } from 'bun'; // Bun's native HTTP server
import { z } from 'zod';

// 3. Use Classes for object-oriented patterns
class UserService {
  #users = new Map(); // 4. Private class fields for true encapsulation

  constructor() {
    this.#users.set('1', { id: '1', name: 'Alice' });
  }

  // 5. Arrow functions for methods to preserve `this` context
  getUser = (id) => {
    return this.#users.get(id);
  };
}

// 6. Nullish coalescing (??) for default values
const user = new UserService().getUser('2');
const userName = user?.name ?? 'Guest'; // 7. Optional chaining (?.) for safe property access

// 8. Async/await for asynchronous operations
async function fetchData(url) {
  try {
    const response = await fetch(url);
    if (!response.ok) {
      throw new Error(`HTTP error! Status: ${response.status}`);
    }
    return await response.json();
  } catch (error) {
    console.error('Failed to fetch:', error);
    return null;
  }
}

// 9. Use `Map` for key-value pairs where keys aren't always strings or order matters
const configMap = new Map([
  ['port', 3000],
  ['debugMode', true],
]);

// 10. Reliable Array checks
const data = [];
if (Array.isArray(data)) {
  console.log('Data is an array.');
}

Read the full file on GitHub · 333 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 333 lines · 0 tokens per session scan A 607e3bab475c

Subscribe to this mod's changes

bun is a cursor rule published in the GitHub repository heyAyushh/stacc (3 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,455 tokens. A static security scan graded it A with 1 finding (makes network calls). It is 100% identical to bun, differing in 2 lines, and is treated as a copy.