后端安装
- 作者仓库星标 0
- 作者更新于 实时读取
- 作者仓库 skills-registry
- 领域
- 通用
- 兼容 Agent
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- 信任分
- 83 / 100 · 社区维护
- 作者 / 版本 / 许可
- @tomevault-io · 未声明 license
- Token 消耗评级
- 低消耗
- 接入复杂程度
- 需手动接入
- 是否需要外部 API Key
- 需要 · Vendor-specific
- 兼容的系统
- Docker
- 底层运行要求
- Node.js · Bun · Docker
- 文件与系统权限
-
- 只读
- 允许写入 / 修改
- Shell 执行
- 读取环境变量
- 网络行为
- 允许外网请求
- 安装命令数
- 26 条
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。;检出高风险片段:pipe_curl_to_shell
---
name: bun
description: | Use when this capability is needed. curl -fsSL https://bun.sh/install | bash bun run index.ts…
category: 通用
runtime: Node.js / Bun / Docker
---
# bun 输出预览
## PART A: 任务判断
- 适用问题:通用任务拆解、检查和交付。
- 输入要求:目标材料、限制条件、期望输出和验收方式。
- 证据边界:围绕“When to Use This Skill / Setup / Package Manager”读取原文规则,不把推断写成作者承诺。
## PART B: 执行结果
- **01** 任务判断:确认你的需求是否属于通用任务拆解、检查和交付,并标出输入、限制和预期结果。
- **02** 执行计划:优先按“When to Use This Skill / Setup / Package Manager”拆成步骤,说明每一步会读取什么、修改什么、产出什么。
- **03** 交付结果:给出可复制的命令、文件改动、检查清单或内容草稿,并说明如何继续迭代。
- **04** 风险边界:结合 读取文件、写入/修改文件、执行终端命令、读取环境变量、会按任务需要访问外部网络、需要准备 Vendor-specific API Key 给出执行前确认项。
## Running Rules
- 读取文件、写入/修改文件、执行终端命令、读取环境变量;会按任务需要访问外部网络;需要准备 Vendor-specific API Key。
- 先小样例验证,再放大到真实任务。
- 交付时同时给结果、检查口径和下一步迭代建议。 原文出现了 `/app` 这类斜杠命令;如果你的 Agent 支持命令触发,优先用命令开场,再补充目标和边界。
告诉 Agent 目标文件或材料、期望结果、不可改范围、是否允许联网或执行命令。本 Skill 的权限画像是:读取文件、写入/修改文件、执行终端命令、读取环境变量。
先用一个小任务确认它会围绕“When to Use This Skill / Setup / Package Manager”工作;涉及文件或命令时,先看 diff、日志、预览或测试结果。
检查最终产物是否包含明确结果、必要证据和下一步动作;如果输出泛泛而谈,就补充输入、边界和验收标准后重跑。
---
name: bun
description: | Use when this capability is needed. curl -fsSL https://bun.sh/install | bash bun run index.ts…
category: 通用
source: tomevault-io/skills-registry
---
# bun
## 什么时候使用
- 把通用方向的常用动作沉淀成 Agent 可调用的技能 适合处理通用任务拆解、检查、交付和复盘,核心价值是把输入、判断、执行、验证和交付边界固定下来,避免 Agent 泛泛回答。 把任务拆成可执行、可检查、可继续迭代的步骤;使用前要准备…
- 面向通用任务拆解、检查和交付,优先处理能明确输入、步骤和验收标准的工作。
## 需要提供什么
- 目标材料、目录范围、期望结果和不可改动内容。
- 是否允许联网、执行命令、读写文件或调用外部服务。
## 执行规则
- 围绕「When to Use This Skill / Setup / Package Manager」组织步骤,不把推断写成作者事实。
- 读取文件、写入/修改文件、执行终端命令、读取环境变量;会按任务需要访问外部网络;需要准备 Vendor-specific API Key。
- 先跑小样例,确认结果可检查后再扩大任务范围。
## 输出要求
- 给出最终产物、关键证据、验证方式和下一步动作。
- 信息不足时标记 unknown,不编造命令、平台或依赖。 作者原文负责流程事实;仓库文件负责来源和命令;流狐只补充适用场景、限制和质量判断。
skill "bun" {
输入层 -> 用户目标 + 目标文件 + 禁止范围 + 验收标准
上下文层 -> When to Use This Skill / Setup / Package Manager
规则层 -> SKILL.md 触发条件 / 执行顺序 / 输出格式
运行层 -> Node.js / Bun / Docker | 读取文件、写入/修改文件、执行终端命令、读取环境变量 | 会按任务需要访问外部网络
安全层 -> 需要准备 Vendor-specific API Key + 小任务验证 + diff / 日志复核
输出层 -> 可复制结果 + 检查清单 + 下一步迭代
} Bun - Quick Reference
Deep Knowledge: Use
mcp__documentation__fetch_docswith technology:bunfor comprehensive documentation.
When to Use This Skill
- Projects requiring high performance
- Replacement for Node.js + npm + bundler
- Fast test runner alternative to Vitest/Jest
- Quick scripts with native TypeScript
Setup
# Install Bun
curl -fsSL https://bun.sh/install | bash
# Create project
bun init
# Run TypeScript directly (no compilation needed!)
bun run index.ts
# Run with watch mode
bun --watch run index.ts
Package Manager
# Install dependencies (faster than npm/pnpm)
bun install
# Add packages
bun add express zod
bun add -d typescript @types/node
# Remove
bun remove package-name
# Update
bun update
# Run scripts
bun run build
bun run dev
# Execute binary
bunx prisma generate
Workspaces
// package.json
{
"workspaces": ["packages/*"]
}
# Install all workspace deps
bun install
# Run in specific workspace
bun run --filter @myorg/api build
Bundler
// Build for production
await Bun.build({
entrypoints: ['./src/index.ts'],
outdir: './dist',
target: 'node', // 'browser' | 'bun'
minify: true,
sourcemap: 'external',
splitting: true, // Code splitting
format: 'esm', // 'cjs' | 'esm'
});
// CLI
bun build ./src/index.ts --outdir ./dist --minify
Build Config
// bunfig.toml alternative - build.ts
const result = await Bun.build({
entrypoints: ['./src/index.tsx'],
outdir: './dist',
target: 'browser',
minify: {
whitespace: true,
identifiers: true,
syntax: true,
},
define: {
'process.env.NODE_ENV': '"production"',
},
external: ['react', 'react-dom'],
loader: {
'.png': 'file',
'.svg': 'text',
},
});
if (!result.success) {
console.error('Build failed:', result.logs);
process.exit(1);
}
Test Runner
// math.test.ts
import { describe, it, expect, beforeAll, mock } from 'bun:test';
describe('math', () => {
it('adds numbers', () => {
expect(1 + 2).toBe(3);
});
it('handles async', async () => {
const result = await fetchData();
expect(result).toBeDefined();
});
});
// Mocking
const mockFn = mock(() => 42);
mockFn();
expect(mockFn).toHaveBeenCalled();
// Module mocking
mock.module('./config', () => ({
apiUrl: 'http://test.local',
}));
# Run tests
bun test
# Watch mode
bun test --watch
# Coverage
bun test --coverage
# Filter
bun test --filter "user"
HTTP Server
// Native Bun server (fastest)
Bun.serve({
port: 3000,
fetch(req) {
const url = new URL(req.url);
if (url.pathname === '/api/health') {
return Response.json({ status: 'ok' });
}
if (url.pathname === '/api/users' && req.method === 'POST') {
const body = await req.json();
return Response.json({ id: 1, ...body }, { status: 201 });
}
return new Response('Not Found', { status: 404 });
},
error(error) {
return new Response(`Error: ${error.message}`, { status: 500 });
},
});
console.log('Server running on http://localhost:3000');
With Hono (recommended for APIs)
import { Hono } from 'hono';
import { cors } from 'hono/cors';
import { logger } from 'hono/logger';
const app = new Hono();
app.use('*', logger());
app.use('/api/*', cors());
app.get('/api/users', (c) => {
return c.json([{ id: 1, name: 'John' }]);
});
app.post('/api/users', async (c) => {
const body = await c.req.json();
return c.json({ id: 1, ...body }, 201);
});
export default app;
File I/O
// Read file (returns string or ArrayBuffer)
const text = await Bun.file('data.txt').text();
const json = await Bun.file('data.json').json();
const buffer = await Bun.file('image.png').arrayBuffer();
// Write file
await Bun.write('output.txt', 'Hello World');
await Bun.write('data.json', JSON.stringify(data));
// Stream large files
const file = Bun.file('large.csv');
const stream = file.stream();
for await (const chunk of stream) {
process.stdout.write(chunk);
}
// File metadata
const file = Bun.file('data.txt');
console.log(file.size); // bytes
console.log(file.type); // MIME type
SQLite (Built-in)
import { Database } from 'bun:sqlite';
const db = new Database('app.db');
// Create table
db.run(`
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
email TEXT UNIQUE
)
`);
// Prepared statements (recommended)
const insert = db.prepare('INSERT INTO users (name, email) VALUES (?, ?)');
insert.run('John', 'john@example.com');
const select = db.prepare('SELECT * FROM users WHERE id = ?');
const user = select.get(1);
// Query all
const all = db.prepare('SELECT * FROM users').all();
// Transaction
db.transaction(() => {
insert.run('Alice', 'alice@example.com');
insert.run('Bob', 'bob@example.com');
})();
Environment Variables
// .env file loaded automatically
const apiKey = Bun.env.API_KEY;
const port = Bun.env.PORT ?? '3000';
// process.env also works
const nodeEnv = process.env.NODE_ENV;
Shell Commands
import { $ } from 'bun';
// Simple command
const result = await $`ls -la`;
console.log(result.stdout.toString());
// With variables (auto-escaped)
const filename = 'my file.txt';
await $`cat ${filename}`;
// Piping
const files = await $`ls`.text();
const count = await $`echo ${files} | wc -l`.text();
// Error handling
try {
await $`exit 1`;
} catch (error) {
console.error('Command failed:', error.exitCode);
}
Configuration (bunfig.toml)
# bunfig.toml
[install]
# Registry
registry = "https://registry.npmjs.org"
# Frozen lockfile in CI
frozenLockfile = true
[run]
# Shell for scripts
shell = "bash"
[test]
# Test configuration
coverage = true
coverageDir = "coverage"
Node.js Compatibility
// Most Node.js APIs work
import { readFile } from 'fs/promises';
import { createServer } from 'http';
import path from 'path';
// Some differences
import.meta.dir; // __dirname equivalent
import.meta.file; // __filename equivalent
// Check runtime
const isBun = typeof Bun !== 'undefined';
When NOT to Use This Skill
| Scenario | Use Instead |
|---|---|
| Node.js runtime specifics | nodejs skill |
| Hono framework | Framework-specific skill |
| Elysia framework | Framework-specific skill |
| TypeScript syntax | typescript skill |
| Testing strategies | testing-vitest skill |
Anti-Patterns
| Anti-Pattern | Why It's Bad | Correct Approach |
|---|---|---|
| Using node_modules/.bin | Not optimized for Bun | Use bunx instead |
| Ignoring compatibility | Some npm packages fail | Test compatibility |
| Complex routing in Bun.serve | Hard to maintain | Use Hono or Elysia |
| Not pinning versions | Breaking changes | Use bun.lockb |
| Mixing package managers | Inconsistent deps | Stick to bun |
| Not using built-in SQLite | Extra dependency | Use bun:sqlite |
| Blocking operations | Defeats performance | Use async APIs |
| Not using watch mode | Slow dev loop | Use --watch flag |
Quick Troubleshooting
| Issue | Cause | Solution |
|---|---|---|
| "Module not found" | npm compatibility issue | Check Bun compatibility list |
| "bun: command not found" | Not installed | Install Bun or add to PATH |
| Tests fail in Bun but not Jest | Different runtime | Check Bun-specific APIs |
| Slow install | Network/cache issue | Clear cache with bun pm cache |
| "Cannot find package" | Wrong specifier | Use npm: prefix for npm packages |
| Type errors with .ts files | tsconfig mismatch | Check Bun's default config |
| Build output incorrect | Wrong target | Set target in Bun.build |
| SQLite errors | Database locked | Close connections properly |
Performance Comparison
| Task | Bun | Node.js |
|---|---|---|
| Install deps | ~2s | ~15s |
| Run TS file | <100ms | ~500ms (tsx) |
| HTTP requests/sec | ~100k | ~40k |
| Test execution | ~200ms | ~2s |
Production Readiness
# Dockerfile
FROM oven/bun:1 AS base
WORKDIR /app
# Install deps
FROM base AS deps
COPY package.json bun.lockb ./
RUN bun install --frozen-lockfile
# Build
FROM base AS build
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN bun run build
# Production
FROM base AS production
COPY --from=build /app/dist ./dist
COPY --from=build /app/package.json ./
USER bun
EXPOSE 3000
CMD ["bun", "run", "dist/index.js"]
Checklist
- Bun installed (v1.0+)
- bunfig.toml configured
- Test suite with bun:test
- Build script configured
- Docker multi-stage for production
- npm package compatibility verified
Reference Documentation
Deep Knowledge: Use
mcp__documentation__fetch_docswith technology:bunfor comprehensive documentation.
Source: claude-dev-suite/claude-dev-suite — distributed by TomeVault.
先判断是否适合
作者设计意图
作者的方法与取舍
边界和复核