Guide · Agent skill
How to use the Transformers.js ML agent skill in JavaScript
Updated · written with AI from the project's own documentation and checked against our catalogue data
The transformers-js skill teaches an AI agent how to use the Transformers.js library to run pretrained machine learning models directly inside JavaScript or TypeScript, in browsers and on server runtimes such as Node.js, Bun and Deno. It is useful if you want features like sentiment analysis, translation, summarization or speech recognition without setting up a separate Python backend. This guide explains what the skill does, how to install it, how to ask for it in plain language, and what to watch for.
Quick start
- 1Download and unzip the skill. Download the ZIP from this page and unzip it into ~/.claude/skills/ or your project's .claude/skills/ folder.
- 2Confirm your runtime. Use Node.js 18+, Bun, Deno or a modern browser with ES module support.
- 3Install the library. Run npm install @huggingface/transformers in your project.
- 4Ask for the feature in plain language. Describe the task, such as sentiment analysis or speech recognition, and name JavaScript or Node.js.
- 5Review the generated pipeline. Check the model ID, device and dtype the agent chose, and confirm it calls dispose().
- 6Run and test. Run the code and check the output shape against the examples in the skill.
What does the transformers-js skill make the agent do?
An agent skill is a folder of instructions that an AI agent loads when a task matches it. This skill covers the Transformers.js library. When you ask for a machine learning feature in JavaScript, the agent knows the pipeline API calls, how to pick a model from the Hugging Face Hub, how to choose CPU or WebGPU, how to use quantized dtypes, and how to free memory with dispose().
- Text tasks: text classification, named entity recognition, question answering, text generation, translation, summarization and zero-shot classification.
- Vision tasks: image classification, object detection, image segmentation and depth estimation.
- Audio tasks: automatic speech recognition, audio classification and text-to-speech.
- Multimodal tasks: image-to-text captioning and document question answering.
How do you install the transformers-js skill?
Download the skill ZIP from this page and unzip it into one of these locations. Use ~/.claude/skills/ to make it available across your projects, or a project's .claude/skills/ folder to limit it to that project.
You can also upload the skill in the Claude apps under Settings → Capabilities → Skills.
- Personal install: unzip into ~/.claude/skills/
- Project install: unzip into the project's .claude/skills/ folder
- Claude apps: Settings → Capabilities → Skills, then upload the skill
How do you trigger the skill with a natural request?
You do not need to name the skill. Describe the task and mention JavaScript, Node.js, the browser or the library. The skill's description covers NLP, computer vision, audio and multimodal tasks, so requests that match those areas are the most likely to load it.
- Add a sentiment feature to my Express app using a local model, no Python.
- Summarize long article text in the browser with a Transformers.js pipeline.
- Transcribe a WAV file in Node.js with automatic speech recognition.
- Classify product photos in a Bun script and show the top label for each.
What does a basic Transformers.js example look like?
Install the npm package, then create a pipeline for a task. The skill uses this pattern: create the pipeline, call it, and dispose of it when finished. The source notes that pipelines should always be disposed to prevent memory leaks.
npm install @huggingface/transformers
import { pipeline } from '@huggingface/transformers';
const pipe = await pipeline('sentiment-analysis');
const result = await pipe('I love transformers!');
await pipe.dispose();How do you choose a model, device and dtype?
Pass a model ID from the Hugging Face Hub as the second argument to pipeline(). Use the device option to run on WebGPU instead of the default WASM CPU path, and the dtype option to choose precision. The source lists fp32, fp16, q8 and q4 as options, where quantized models are generally smaller and faster.
- Browse Transformers.js models on the Hugging Face Hub, filtered by task.
- device: 'webgpu' runs on the GPU when your browser and hardware support it.
- dtype: 'q4' trades some precision for a smaller, faster model.
const pipe = await pipeline('sentiment-analysis', 'model-id', {
device: 'webgpu',
dtype: 'q4',
});What are the safety and network notes?
The skill does not run scripts. It does use the network: the first time a model is loaded, Transformers.js downloads it from the Hugging Face Hub, and the source describes a cache so later loads are faster. In browsers the cache uses the Cache API, and in Node.js it uses ~/.cache/huggingface/. Models can range from a few MB to several GB, so check disk space and bandwidth before you deploy.
- Internet access is needed to download models unless you use local models.
- Model files come from third parties on the Hub; review the model card before relying on one.
- Always call dispose() on pipelines when finished.
What people use it for
- Adding sentiment analysis to a web form without sending text to a Python server.
- Summarizing or translating text in a Node.js backend job.
- Running object detection on images in a browser-based tool.
- Transcribing short audio clips in a Bun or Node.js script.
Frequently asked questions
Is the transformers-js skill free to use?
The skill is licensed under Apache-2.0, as stated on this page. Check the license file in the downloaded skill for the full terms before you redistribute it.
What do I need to use it?
You need Node.js 18+ or a compatible Bun or Deno runtime, or a modern browser with ES module support, plus the @huggingface/transformers npm package. Internet access is needed to download models unless you use local ones.
Do I need a GPU?
No. The default path runs on WASM, which is the broad fallback. WebGPU gives GPU acceleration when your browser and hardware support it.
Can this skill train or fine-tune models?
No. The skill focuses on running existing pretrained models for inference. For training, a Python tool such as the Python transformers library is the more appropriate choice.
Why does my script keep using memory?
Pipelines must be disposed with pipe.dispose() when you finish. Without it, memory may not be released.
How does this compare with the Python transformers library?
Transformers.js runs models inside JavaScript without a Python backend. The skill itself notes that for Python projects, the Python transformers library is the better tool.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Use this skill if you are a JavaScript or TypeScript developer who wants to add small-to-medium ML features to a web app or a Node.js, Bun or Deno backend without a Python server. Pick something else if you need to train or fine-tune models, work in Python, or serve large language models that need heavy GPU hardware.
Download the skill