agentleFS
addiplusaddiplus/claude-skill-pack/skills/bun-toolkit/SKILL.md

bun-toolkit

Skill0 starsChanged 7 months agoMITView on GitHub

Execute JavaScript/TypeScript with Bun runtime. Use when user needs fast JS execution, package management, or cross-platform shell scripting. Keywords: bun, javascript, typescript, runtime, fast, npm alternative, package manager, shell script.

  • Pipes a download into a shell
  • Deletes or force-pushes
  • Installs packages

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use bun --hot run not bun run --hot

    line 251
  2. Distinctive:

    Ensure no syntax errors in code

    line 252

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Bun Toolkit

Bun is an all-in-one JavaScript runtime and toolkit designed for speed. This skill enables fast script execution, package management, and cross-platform shell scripting.

Variables

  • BUN_INSTALL_SCRIPT_WINDOWS: powershell -c "irm bun.sh/install.ps1|iex"
  • BUN_INSTALL_SCRIPT_UNIX: curl -fsSL https://bun.sh/install | bash
  • BUN_PATH_WINDOWS: $env:USERPROFILE\.bun\bin
  • BUN_PATH_UNIX: ~/.bun/bin

Prerequisites

Check Installation

# Check if Bun is installed
bun --version

Install Bun

Windows (PowerShell):

powershell -c "irm bun.sh/install.ps1|iex"
# Add to PATH if needed
$env:Path += ";$env:USERPROFILE\.bun\bin"

macOS/Linux:

curl -fsSL https://bun.sh/install | bash
source ~/.bashrc  # or ~/.zshrc

Via npm (cross-platform):

npm install -g bun

Core Capabilities

1. Run Scripts (Fastest JS Runtime)

# Run TypeScript directly (no config needed)
bun run script.ts

# Run with hot reloading
bun --hot run server.ts

# Run with watch mode
bun --watch run script.ts

2. Package Management (25x faster than npm)

# Install dependencies
bun install

# Add package
bun add package-name
bun add -d dev-package  # dev dependency
bun add -g global-pkg   # global

# Remove package
bun remove package-name

# Update packages
bun update

3. Shell Scripting (Cross-platform)

// Cross-platform shell with Bun.$
import { $ } from "bun";

// Template literal syntax
await $`echo "Hello from Bun shell!"`;

// Piping
const result = await $`cat file.txt | grep pattern`.text();

// Variable interpolation
const dir = "./src";
await $`ls -la ${dir}`;

// Error handling
const { exitCode, stdout, stderr } = await $`command`.quiet();

4. HTTP Server

Bun.serve({
  port: 3000,
  fetch(req) {
    return new Response("Hello from Bun!");
  },
});

5. File I/O

// Read file
const file = Bun.file("./data.json");
const content = await file.text();
const json = await file.json();

// Write file
await Bun.write("output.txt", "Hello World");
await Bun.write("data.json", JSON.stringify({ key: "value" }));

6. SQLite (Built-in)

import { Database } from "bun:sqlite";

const db = new Database("mydb.sqlite");
db.run("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT)");
db.run("INSERT INTO users (name) VALUES (?)", ["Alice"]);
const users = db.query("SELECT * FROM users").all();

Quick Commands Reference

TaskCommand
Run scriptbun run script.ts
Install depsbun install
Add packagebun add <pkg>
Dev serverbun --hot run server.ts
Run testsbun test
Bundlebun build ./src/index.ts --outdir ./dist
Create executablebun build --compile ./app.ts --outfile app
Init projectbun init
Create from templatebun create react-app my-app

Cookbook

Extended documentation for specific features.

FeatureWhen to ReadDocumentation
InstallationSetting up Bun on any platformcookbook/installation.md
Runtime APIsUsing Bun-specific APIscookbook/runtime-apis.md
Package ManagementAdvanced package operationscookbook/package-management.md
Shell ScriptingCross-platform automationcookbook/shell-scripting.md

Examples

Example 1: Run TypeScript Directly

# No tsconfig or compilation needed
echo 'console.log("Hello, TypeScript!")' > hello.ts
bun run hello.ts

Example 2: Quick HTTP Server

echo 'Bun.serve({ fetch: () => new Response("Hello!"), port: 3000 })' > server.ts
bun run server.ts
# Server running at http://localhost:3000

Example 3: Process JSON Files

// process.ts
const data = await Bun.file("./input.json").json();
data.processed = true;
data.timestamp = new Date().toISOString();
await Bun.write("./output.json", JSON.stringify(data, null, 2));
console.log("Processed!");

Workflow

Starting a New Project

  1. Initialize project:
    mkdir my-project && cd my-project
    bun init
  2. Add dependencies:
    bun add express zod
    bun add -d typescript @types/node
  3. Create entry point:
    // index.ts
    console.log("Hello, Bun!");
  4. Run:
    bun run index.ts

Converting npm Project to Bun

  1. Delete node_modules and lockfile:
    rm -rf node_modules package-lock.json yarn.lock pnpm-lock.yaml
  2. Install with Bun:
    bun install
  3. Run scripts:
    bun run dev
    bun run build

Node.js Compatibility

Bun is designed for Node.js compatibility:

  • Fully Supported: fs, path, crypto, http, https, net, url, stream, buffer, events
  • Mostly Supported: child_process, worker_threads, cluster
  • Not Supported: vm (use Workers), domain (deprecated)

Troubleshooting

"bun: command not found"

  • Windows: Add $env:USERPROFILE\.bun\bin to PATH
  • Unix: Run source ~/.bashrc or restart terminal

Package installation fails:

# Clear cache and reinstall
bun pm cache rm
rm -rf node_modules bun.lockb
bun install

TypeScript errors:

  • Bun uses its own TS transpiler - no tsc needed
  • For type-checking: bun x tsc --noEmit

Hot reload not working:

  • Use bun --hot run not bun run --hot
  • Ensure no syntax errors in code

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.