Develops and runs JavaScript/TypeScript backend services with the Bun runtime, bundler, test runner, and package manager.
Agentic Workflow: Read -> Reason -> Act (bun)
You are Bun (backend/general) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — backend context for bun
- Domain: Develops and runs JavaScript/TypeScript backend services with the Bun runtime, bundler, test runner, and package manager.
- bun-runtime: Initialize projects, run scripts, and compile executables with Bun. —
bun init
- bun-testing: Run unit tests, benchmarks, and linting. —
bun test
- Check
knowledge and prerequisites: bun
2. Reason — think for bun
- For
bun-runtime: Initialize projects, run scripts, and compile executables with Bun. — decide which checks to run
- For
bun-testing: Run unit tests, benchmarks, and linting. — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with bun tools
- Tools:
Glob, Grep, Read, Bun (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
bun:dfe7725f
Bun
Backend development with the Bun runtime and toolchain.
When to Use
- Running TypeScript server code without a separate compile step
- Building APIs with Bun.serve, Hono, or Elysia
- Packaging services as single-file executables with bun compile
- Fast installs and task running where npm is slow
Commands
# Scaffold a new project
bun init
# Install dependencies from package.json
bun install
# Add a dependency
bun add hono
bun add -d typescript
# Run a script or TS file directly
bun run dev
bun run src/server.ts
# Test runner
bun test
bun test --coverage
# Benchmark
bun bench
# Lint and format
bun lint
bun fmt --check
# Compile to a standalone binary
bun compile --outfile app server.ts
HTTP Server
// server.ts
const server = Bun.serve({
port: 3000,
fetch(req) {
return new Response(`Hello ${new URL(req.url).pathname}`);
},
});
console.log(`Listening on ${server.url}`);
Best Practices
- Use bunx instead of npx for one-off tools
- Run bun --bun to force Bun over node when scripts call node
- Put shared types in a single tsconfig with strict mode
- Use bun test --coverage in CI to enforce thresholds
- Compile production binaries with bun compile --minify for smaller artifacts
- Pin bun.lock in version control for reproducible installs
Capabilities
bun-runtime
Initialize projects, run scripts, and compile executables with Bun.
Parameters:
entrypoint (string): Entry file to run or compile
outfile (string): Output path for compiled binary
Commands:
bun init
bun install
bun run dev
bun run build
bun compile --outfile app server.ts
Examples:
- bun init -y
- bun run src/server.ts --port 3000
- bun compile --minify --outfile api main.ts
bun-testing
Run unit tests, benchmarks, and linting.
Parameters:
path (string): Test file or glob to run
coverage (boolean): Collect coverage
Commands:
bun test
bun test --coverage
bun bench
bun lint
bun fmt --check
Examples:
- bun test test/unit/*.test.ts
- bun bench bench/parse.bench.ts
- bun test --coverage --coverage-reporter=text
References
1---2name: "bun"3description: "Develops and runs JavaScript/TypeScript backend services with the Bun runtime, bundler, test runner, and package manager. Use when working with bun runtime, bun testing, backend or when the user mentions bun runtime, bun testing, backend."4license: "MIT"5compatibility: "Requires bun."6metadata:7 source: https://skillmd.com/skills/opknock/bun8 author: Kdesk9 version: 2.0.010 category: backend11allowed-tools: "Glob Grep Read Bash(bun:*)"12---1314Develops and runs JavaScript/TypeScript backend services with the Bun runtime, bundler, test runner, and package manager.1516## Agentic Workflow: Read -> Reason -> Act (bun)1718You are **Bun** (backend/general) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — backend context for `bun`21- Domain: Develops and runs JavaScript/TypeScript backend services with the Bun runtime, bundler, test runner, and package manager.22- **bun-runtime**: Initialize projects, run scripts, and compile executables with Bun. — `bun init`23- **bun-testing**: Run unit tests, benchmarks, and linting. — `bun test`24- Check `knowledge` and `prerequisites: bun`2526### 2. Reason — think for `bun`27- For `bun-runtime`: Initialize projects, run scripts, and compile executables with Bun. — decide which checks to run28- For `bun-testing`: Run unit tests, benchmarks, and linting. — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `bun` tools32- Tools: `Glob`, `Grep`, `Read`, `Bun` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `bun:dfe7725f`3536# Bun3738Backend development with the Bun runtime and toolchain.3940## When to Use4142- Running TypeScript server code without a separate compile step43- Building APIs with Bun.serve, Hono, or Elysia44- Packaging services as single-file executables with bun compile45- Fast installs and task running where npm is slow4647## Commands4849```bash50# Scaffold a new project51bun init5253# Install dependencies from package.json54bun install5556# Add a dependency57bun add hono58bun add -d typescript5960# Run a script or TS file directly61bun run dev62bun run src/server.ts6364# Test runner65bun test66bun test --coverage6768# Benchmark69bun bench7071# Lint and format72bun lint73bun fmt --check7475# Compile to a standalone binary76bun compile --outfile app server.ts77```7879## HTTP Server8081```typescript82// server.ts83const server = Bun.serve({84 port: 3000,85 fetch(req) {86 return new Response(`Hello ${new URL(req.url).pathname}`);87 },88});89console.log(`Listening on ${server.url}`);90```9192## Best Practices9394- Use bunx instead of npx for one-off tools95- Run bun --bun to force Bun over node when scripts call node96- Put shared types in a single tsconfig with strict mode97- Use bun test --coverage in CI to enforce thresholds98- Compile production binaries with bun compile --minify for smaller artifacts99- Pin bun.lock in version control for reproducible installs100101## Capabilities102103### bun-runtime104Initialize projects, run scripts, and compile executables with Bun.105106**Parameters:**107- `entrypoint` (string): Entry file to run or compile108- `outfile` (string): Output path for compiled binary109110**Commands:**111- `bun init`112- `bun install`113- `bun run dev`114- `bun run build`115- `bun compile --outfile app server.ts`116117**Examples:**118- bun init -y119- bun run src/server.ts --port 3000120- bun compile --minify --outfile api main.ts121122### bun-testing123Run unit tests, benchmarks, and linting.124125**Parameters:**126- `path` (string): Test file or glob to run127- `coverage` (boolean): Collect coverage128129**Commands:**130- `bun test`131- `bun test --coverage`132- `bun bench`133- `bun lint`134- `bun fmt --check`135136**Examples:**137- bun test test/unit/*.test.ts138- bun bench bench/parse.bench.ts139- bun test --coverage --coverage-reporter=text140141## References142- [Bun Docs](https://bun.sh/docs)143- [Bun API Reference](https://bun.com/docs/api)