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.
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/bcanfield/bun-scriptsBun 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 of | Use | Why |
|---|---|---|
node script.js / ts-node / tsx | bun script.ts | Runs .ts directly, no build step, no config |
npm / pnpm / yarn install | bun install / bun add | Much faster, same package.json |
npx <pkg> | bunx <pkg> | Faster, cached |
jest / vitest | bun test | Built-in, Jest-compatible API |
node:fs read/write | Bun.file() / Bun.write() | Faster, lazier, simpler |
child_process.exec | Bun.$ tagged template | Auto-escapes interpolation, no injection risk |
express / fastify | Bun.serve() | Built-in, routes + websockets included |
better-sqlite3 | bun:sqlite | Built-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) orbunx(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
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 skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-bcanfield-bun-scripts": {
"enabled": true,
"auto_update": true
}
}
}