bun-file

bun-file is a cursor rule for Cursor from PrinceGupta1999/graylog-mcp. It costs 2,169 tokens per session, scanned C, a copy of bun-file, MIT.

Reference documentation for Bun’s file APIs, where Bun is a JavaScript runtime. It covers reading files with `Bun.file`, writing them with `Bun.write`, and using Node’s file-system module for operations such as creating folders or listing files.

In plain words
What is it for?
Reading file contents as text, streams, bytes, or binary data; writing files; and understanding the limits of Bun’s file APIs.
Why use it?
It shows which file operations Bun provides directly and which ones require another API. This helps developers choose the right method when working with files.

Cursor rule for Cursor

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/princegupta1999/graylog-mcp/bun-file
Clone the repo
git clone --depth 1 https://github.com/PrinceGupta1999/graylog-mcp

Made for: Cursor.

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-file

README.md
[![agentmods](https://agentmods.dev/badge/rules/princegupta1999/graylog-mcp/bun-file.svg)](https://agentmods.dev/rules/princegupta1999/graylog-mcp/bun-file)
Your own site
<a href="https://agentmods.dev/rules/princegupta1999/graylog-mcp/bun-file"><img src="https://agentmods.dev/badge/rules/princegupta1999/graylog-mcp/bun-file.svg" alt="Measured on agentmods" height="20"></a>
Per session 2,169 This file is loaded in full into every session.
When invoked 2,169 The same file — it is already loaded in full.
Security scan C 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.02169 $0.02169
Opus 5 $0.01085 $0.01085
Sonnet 5 $0.00434 $0.00434
Haiku 4.5 $0.00217 $0.00217

Measured 5d ago against content hash 46bab1907fd6, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade C, and why

bun-file scanned grade C 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 5d ago.

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.

Hidden instructionshighPrompt injection

Directives inside HTML comments, invisible characters or bidirectional overrides are read by the model and not by the person reviewing the file.

<!-- **Note** — The `Bun.file` and `Bun.write` APIs documented on this page are heavily optimized and represent the recommended way to perform file-system tasks using Bun. Existing Node.js projects may use Bun's [nearly
Origin

This is a copy

100% identical to bun-file — 0 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.

.cursor/rules/bun-file.mdc · 369 lines

How it starts

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

Note — The Bun.file and Bun.write APIs documented on this page are heavily optimized and represent the recommended way to perform file-system tasks using Bun. For operations that are not yet available with Bun.file, such as mkdir or readdir, you can use Bun's nearly complete implementation of the node:fs module.

{% /callout %}

Bun provides a set of optimized APIs for reading and writing files.

Reading files (Bun.file())

Bun.file(path): BunFile

Create a BunFile instance with the Bun.file(path) function. A BunFile represents a lazily-loaded file; initializing it does not actually read the file from disk.

const foo = Bun.file("foo.txt"); // relative to cwd
foo.size; // number of bytes
foo.type; // MIME type

The reference conforms to the Blob interface, so the contents can be read in various formats.

const foo = Bun.file("foo.txt");

await foo.text(); // contents as a string
await foo.stream(); // contents as ReadableStream
await foo.arrayBuffer(); // contents as ArrayBuffer
await foo.bytes(); // contents as Uint8Array

File references can also be created using numerical file descriptors or file:// URLs.

Bun.file(1234);
Bun.file(new URL(import.meta.url)); // reference to the current file

A BunFile can point to a location on disk where a file does not exist.

const notreal = Bun.file("notreal.txt");
notreal.size; // 0
notreal.type; // "text/plain;charset=utf-8"
const exists = await notreal.exists(); // false

The default MIME type is text/plain;charset=utf-8, but it can be overridden by passing a second argument to Bun.file.

const notreal = Bun.file("notreal.json", { type: "application/json" });
notreal.type; // => "application/json;charset=utf-8"

For convenience, Bun exposes stdin, stdout and stderr as instances of BunFile.

Bun.stdin; // readonly
Bun.stdout;
Bun.stderr;

Read the full file on GitHub · 369 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. 5d ago First seen · 369 lines · 2,169 tokens per session scan C 46bab1907fd6

Subscribe to this mod's changes

bun-file is a cursor rule published in the GitHub repository PrinceGupta1999/graylog-mcp (1 stars, last pushed 2mo ago), licensed MIT. It adds 2,169 tokens to every session, about $0.0108 per session on Opus 5. A static security scan graded it C with 1 finding (hidden instructions). It is 100% identical to bun-file, differing in 0 lines, and is treated as a copy.