用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/secondsky/claude-skills --skill bun-runtime命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Use when reworking a change to prevent tech debt, or auditing existing debt to categorize, score, and prioritize the refactor backlog.
Discover and reduce task unknowns — blindspots, missing context, and unknown unknowns — before committing to a plan, implementation, review, or merge.
MUI Base UI unstyled React components with Floating UI. Use for accessible components, Radix UI migration, render props API, or encountering positioning, popup, v1.0 rc / pre-GA issues.
基于 SOC 职业分类
正在显示 SKILL.md
| name | bun-runtime |
| description | Use for Bun runtime, bunfig.toml, watch/hot modes, env vars, CLI flags, and module resolution. |
| metadata | {"version":"1.0.0"} |
| license | MIT |
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.
# 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
| Flag | Purpose |
|---|---|
--watch | Restart on file changes |
--hot | Hot module replacement (preserves state) |
--smol | Reduce memory usage (slower GC) |
--inspect | Enable debugger |
--preload | Load modules before execution |
--env-file | Load specific .env file |
-e, --eval | Evaluate code string |
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
# 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.).
| Mode | Flag | Behavior |
|---|---|---|
| Watch | --watch | Full process restart on changes |
| Hot | --hot | Replace modules, preserve state |
# Watch mode - full restart
bun --watch run server.ts
# Hot reloading - preserves connections/state
bun --hot run server.ts
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;
| Global | Source | Notes |
|---|---|---|
Bun | Bun | Main API object |
Buffer | Node.js | Binary data |
process | Node.js | Process info |
fetch | Web | HTTP requests |
Request/Response | Web | HTTP types |
WebSocket | Web | WebSocket client |
crypto | Web | Cryptography |
console | Web | Logging |
__dirname | Node.js | Current directory |
__filename | Node.js | Current file |
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.
# Pipe code to Bun
echo "console.log('Hello')" | bun run -
# Redirect file
bun run - < script.js
# Run script in specific packages
bun run --filter 'pkg-*' build
# Run in all workspaces
bun run --filter '*' test
# 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.
| Error | Cause | Fix |
|---|---|---|
Cannot find module | Missing dependency | Run bun install |
Top-level await | Using await outside async | Wrap in async function or use .mts |
--watch not working | Flag in wrong position | Put flag before run |
Load references/bunfig.md when:
Load references/cli-flags.md when:
Load references/module-resolution.md when: