Skip to content

Practical Bun worker guide covering Web Workers, worker_threads, and pooling for parallel and background tasks.

CCM score
54 of 100
skills.sh installs
425
GitHub stars
257
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers Bun Web Workers, Node.js worker_threads, and a reusable worker pool with queued task execution
  • Includes transferable buffers for zero-copy handoff, SharedArrayBuffer with Atomics for shared memory, and a parallel map helper
  • Documents error handling via onerror and onmessageerror, plus graceful shutdown with self.close() and forced terminate()
  • Designed for CPU-intensive processing and background tasks that must keep the main thread responsive

Install

$ npx -y skills add secondsky/claude-skills --skill bun-workers -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Bun Workers

Bun supports Web Workers and Node.js worker_threads for parallel execution.

Web Workers

Basic Usage

// main.ts
const worker = new Worker(new URL("./worker.ts", import.meta.url));

worker.postMessage({ type: "start", data: [1, 2, 3, 4, 5] });

worker.onmessage = (event) => {
  console.log("Result:", event.data);
};

worker.onerror = (error) => {
  console.error("Worker error:", error.message);
};

// worker.ts
self.onmessage = (event) => {
  const { type, data } = event.data;

  if (type === "start") {
    const result = data.map((x) => x * 2);
    self.postMessage(result);
  }
};

Worker with URL

// Import from file path
const worker = new Worker(new URL("./worker.ts", import.meta.url));

// Or with blob URL
const code = `
  self.onmessage = (e) => {
    self.postMessage(e.data * 2);
  };
`;
const blob = new Blob([code], { type: "application/javascript" });
const worker = new Worker(URL.createObjectURL(blob));

Transferable Objects

// main.ts
const buffer = new ArrayBuffer(1024 * 1024); // 1MB
const view = new Uint8Array(buffer);
view.fill(42);

Details

Repository
github.com/secondsky/claude-skills
Categories
Backend & APIs, CLI & Terminal
First seen
Jun 3, 2026

Questions

What does the bun-workers skill do?

The bun-workers skill covers Web Workers in Bun, Node.js worker_threads, parallel processing and background tasks. It shows how bun-workers sends messages between the main thread and a worker, and how it shares buffers or memory between them.

How do I install the bun-workers skill?

Run npx -y skills add secondsky/claude-skills --skill bun-workers -y in a project to install bun-workers. After that, the agent can use bun-workers to build a worker pool, run CPU-intensive tasks in parallel, or handle worker errors and termination.

Where does bun-workers sit in the Backend & APIs category?

bun-workers is listed in the Backend & APIs category on Claude Marketplaces, next to entra-app-registration, neon, firebase-basics, firebase-auth-basics and workers-best-practices. Those skills cover other backend topics, while bun-workers focuses only on parallel execution in Bun.

More from secondsky/claude-skills

All 116

Similar to Bun Workers

More Backend & APIs