david-li0406/meta-skill-evloving/js-worker-multithreading
Claude Code and agent skill by david-li0406/meta-skill-evloving
- community
Checking that the SKILL.md file is still in the repository.
Implement, refactor, or review worker-based multithreading in TypeScript/JavaScript apps (browser or Node). Use when offloading CPU-heavy loops to Web Workers, setting up a worker pool, moving data across threads, or diagnosing worker crashes, slowdowns, or synchronization bugs.
Install
npx vskill@latest install david-li0406/meta-skill-evloving/js-worker-multithreadingSKILL.md
The same SKILL.md was published earlier as majiayu000/claude-skill-registry-data/js-worker-multithreading.
JS Worker Multithreading
Overview
Use this skill to move CPU-heavy work off the main thread with worker pools while keeping the main thread as the source of truth for UI, DOM, and physics APIs.
Workflow
- Identify the hot loop and define a pure worker kernel that takes plain data and returns plain data.
- Snapshot state into typed arrays or plain objects suitable for structured clone or transfer.
- Spawn a worker job, join for the result, and apply the result on the main thread.
- Gate jobs to avoid overlapping work and apply the latest completed result on the next tick.
- Add fallback behavior if workers or shared memory are not available.
Do
- Keep worker code pure (numeric math, no DOM, no Three.js, no physics APIs).
- Use typed arrays for bulk data and pass them with a transfer or move helper.
- Preallocate and reuse buffers to avoid per-frame allocations and GC spikes.
- Limit concurrent jobs; keep at most one in flight per simulation loop or queue with backpressure.
- Apply results on the main thread and keep authoritative state there.
- Catch worker failures, log them, and degrade gracefully (main-thread fallback).
- Detect SharedArrayBuffer and crossOriginIsolated before relying on shared memory.
- Initialize the worker runtime once; handle "already initialized" errors safely.
- Size the pool based on hardwareConcurrency and clamp to a safe range.
Do Not
- Do not call main-thread-only APIs (DOM, WebGL, Rapier, AudioContext) inside workers.
- Do not spawn a new worker per frame; reuse a pool or runtime.
- Do not pass class instances or engine objects across the worker boundary.
- Do not mutate shared state without explicit synchronization primitives.
- Do not launch overlapping jobs that race to apply results.
- Do not assume SharedArrayBuffer is available without COOP/COEP headers.
- Do not ignore failed worker results; disable or fallback to avoid infinite retries.
Minimal Template (multithreading package)
Troubleshooting Checklist
- Verify the worker kernel only uses serializable inputs and outputs.
- Confirm large arrays are transferred, not cloned.
- Ensure the main thread applies results in a deterministic order.
- Log worker failures and guard against repeated crashes.
- Validate crossOriginIsolated and SharedArrayBuffer before enabling shared memory.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskill-flow/data/skills-refined-agentskillos-36k/skillsmp/js-worker-multithreading/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/david-li0406/meta-skill-evloving/js-worker-multithreading)