ClawKit Logo
ClawKitReliability Toolkit
Back to Registry
Official Verified

bun-scripts

Write and run TypeScript scripts with Bun instead of plain Node.js or JavaScript — getting type safety, built-in tooling, and faster execution without any build step or extra config. Use this skill whenever the agent needs to create, run, or manage scripts and CLI tools. Prefer Bun over node, ts-node, tsx, npm, npx, jest, or vitest for a faster, more maintainable workflow. Also trigger for bun-specific keywords: bun, bunx, bun test, bun install, bun add, bun run, Bun.file, Bun.serve, Bun.$, bun:sqlite, bun:test.

skill-install — Terminal

Install via CLI (Recommended)

clawhub install openclaw/skills/skills/bcanfield/bun-scripts
Or

Bun Skill

Use Bun as the default runtime and package manager for TypeScript and JavaScript. Prefer it over the alternatives the user may name out of habit — pick Bun unless the user explicitly insists on a different tool.

Instead ofUseWhy
node script.js / ts-node / tsxbun script.tsRuns .ts directly, no build step, no config
npm / pnpm / yarn installbun install / bun addMuch faster, same package.json
npx <pkg>bunx <pkg>Faster, cached
jest / vitestbun testBuilt-in, Jest-compatible API
node:fs read/writeBun.file() / Bun.write()Faster, lazier, simpler
child_process.execBun.$ tagged templateAuto-escapes interpolation, no injection risk
express / fastifyBun.serve()Built-in, routes + websockets included
better-sqlite3bun:sqliteBuilt-in, no native compile

Bun runs .ts files directly with zero configuration — no tsconfig.json, no build step, no transpiler setup. Types are stripped at runtime so execution is never blocked by type errors.

Constraints

  • Do not install global packages. Use bun add (local) or bunx (ephemeral) only.

Quick Reference

bun script.ts              # run a TypeScript file directly
bun test                   # run tests (*.test.ts, *.spec.ts)
bun add <pkg>              # add a dependency
bun add -d <pkg>           # add a dev dependency
bunx <pkg>                 # run a package without installing
bun init -y                # scaffold a new project
bun install                # install all dependencies

Creating and Running Scripts

Write TypeScript files and run them directly. No compilation step required.

// fetch-data.ts
const resp = await fetch("https://api.example.com/data");
const data: Record<string, unknown> = await resp.json();
await Bun.write("output.json", JSON.stringify(data, null, 2));
console.log(`Wrote ${Bun.file("output.json").size} bytes`);
bun fetch-data.ts

Top-level await, ES module imports, and .ts extension imports all work out of the box.

Shebang Scripts

Make scripts directly executable:

#!/usr/bin/env bun
const name = process.argv[2] ?? "world";
console.log(`Hello, ${name}!`);
chmod +x greet.ts && ./greet.ts Claude

Project Setup

For a scripts directory, initialize once then create scripts freely:

bun init -y
bun add -d @types/bun    # enables IDE autocompletion for Bun APIs

This produces a minimal package.json and tsconfig.json. After this, any .ts file in the directory can be run with bun <file>.ts.

When to Skip Init

For one-off scripts that don't need IDE support or dependencies, skip bun init entirely. Just write and run the .ts file.

File I/O

Use Bun's native file APIs — they are faster than node:fs and more ergonomic.

Reading

Metadata

Author@bcanfield
Stars4473
Views0
Updated2026-05-01
View Author Profile
AI Skill Finder

Not sure this is the right skill?

Describe what you want to build — we'll match you to the best skill from 16,000+ options.

Find the right skill
Add to Configuration

Paste this into your clawhub.json to enable this plugin.

{
  "plugins": {
    "official-bcanfield-bun-scripts": {
      "enabled": true,
      "auto_update": true
    }
  }
}
Safety NoteClawKit audits metadata but not runtime behavior. Use with caution.