skillZs
★ LIVE SKILL TAGS ★
>>> LIVE SKILLS INDEX <<<
* OPEN SOURCE *
NO LOGIN, NO TRACKING
※ REAL INSTALL DATA ※
← back to all skills
secondsky/claude-skills314 installs

bun-runtime

Use for Bun runtime, bunfig.toml, watch/hot modes, env vars, CLI flags, and module resolution.

How do I install this agent skill?

npx skills add https://github.com/secondsky/claude-skills --skill bun-runtime
view source ↗

Is this agent skill safe to install?

  • Gen Agent Trust Hubpass

    This skill provides comprehensive documentation and reference materials for the Bun JavaScript runtime, including CLI flags, configuration settings, and module resolution guidelines. No security issues or malicious patterns were detected.

  • Socketpass

    No alerts

  • Snykpass

    Risk: LOW · No issues

  • Runlayerwarn

    3/4 files flagged

  • ZeroLeakspass

    Score: 93/100 · 2 sections analyzed

What does this agent skill do?

Bun Runtime

Bun is a fast all-in-one JavaScript runtime built on JavaScriptCore (Safari's engine). It provides 4x faster startup than Node.js on Linux.

Quick Start

# Run a file
bun run index.ts
bun index.ts  # shorthand

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

# Run package.json script
bun run dev

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

Core CLI Flags

FlagPurpose
--watchRestart on file changes
--hotHot module replacement (preserves state)
--smolReduce memory usage (slower GC)
--inspectEnable debugger
--preloadLoad modules before execution
--env-fileLoad specific .env file
-e, --evalEvaluate code string

Running Files

Bun transpiles TypeScript and JSX on-the-fly:

bun run index.js
bun run index.ts
bun run index.jsx
bun run index.tsx

Important: Put Bun flags immediately after bun:

bun --watch run dev    # Correct
bun run dev --watch    # Wrong - flag passed to script

Package.json Scripts

# Run script
bun run dev
bun dev  # shorthand (if no Bun command conflicts)

# List available scripts
bun run

# Run with Bun instead of Node
bun run --bun vite

Bun respects lifecycle hooks (preclean, postclean, etc.).

Watch Mode vs Hot Reloading

ModeFlagBehavior
Watch--watchFull process restart on changes
Hot--hotReplace modules, preserve state
# Watch mode - full restart
bun --watch run server.ts

# Hot reloading - preserves connections/state
bun --hot run server.ts

Environment Variables

Bun automatically loads .env files:

# Loads automatically: .env, .env.local, .env.development
bun run index.ts

# Specify env file
bun --env-file .env.production run index.ts

# Disable auto-loading
# In bunfig.toml: env = false

Access in code:

const apiKey = process.env.API_KEY;
const bunEnv = Bun.env.NODE_ENV;

Globals Available

GlobalSourceNotes
BunBunMain API object
BufferNode.jsBinary data
processNode.jsProcess info
fetchWebHTTP requests
Request/ResponseWebHTTP types
WebSocketWebWebSocket client
cryptoWebCryptography
consoleWebLogging
__dirnameNode.jsCurrent directory
__filenameNode.jsCurrent file

Preload Scripts

Load modules before your main script:

bun --preload ./setup.ts run index.ts

Or in bunfig.toml:

preload = ["./setup.ts"]

Use cases: polyfills, global setup, instrumentation.

Stdin Execution

# Pipe code to Bun
echo "console.log('Hello')" | bun run -

# Redirect file
bun run - < script.js

Workspaces & Monorepos

# Run script in specific packages
bun run --filter 'pkg-*' build

# Run in all workspaces
bun run --filter '*' test

Debugging

# Start debugger
bun --inspect run index.ts

# Wait for debugger connection
bun --inspect-wait run index.ts

# Break on first line
bun --inspect-brk run index.ts

Connect via Chrome DevTools or VS Code.

Common Errors

ErrorCauseFix
Cannot find moduleMissing dependencyRun bun install
Top-level awaitUsing await outside asyncWrap in async function or use .mts
--watch not workingFlag in wrong positionPut flag before run

When to Load References

Load references/bunfig.md when:

  • Configuring bunfig.toml
  • Setting up test configuration
  • Configuring package manager behavior
  • Setting JSX options

Load references/cli-flags.md when:

  • Need complete CLI flag reference
  • Configuring advanced runtime options
  • Setting up debugging

Load references/module-resolution.md when:

  • Troubleshooting import errors
  • Configuring path aliases
  • Understanding Bun's resolution algorithm

Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.

<a href="https://skillzs.dev/skills/secondsky/claude-skills/bun-runtime">View bun-runtime on skillZs</a>