wxt
БесплатноБез исполняемых скриптовНе проверенWXT is a Vite-based framework that builds browser extensions for Chrome, Firefox, Safari, and Edge from one codebase. Use when someone asks to "build a…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
WXT
Overview
WXT is a Vite-based framework for building browser extensions — its own tagline is "like Nuxt, but for web extensions." File-based entrypoints, hot reload, TypeScript-first, auto-imports. One codebase produces a separate build per browser: Manifest V3 for Chrome and Edge, Manifest V2 by default for Firefox and Safari (pass --mv3 to override). There is no manifest.json in the source tree — WXT generates it from wxt.config.ts and the entrypoint files.
WXT is still pre-1.0, so a change in the second digit (0.20 → 0.21) is a breaking release. This skill matches 0.21, which needs Node.js 22+, and makes vite a required peer dependency and web-ext an optional one (without web-ext the dev command no longer opens a browser).
When to Use
- Building a browser extension for Chrome, Firefox, or all browsers
- Want hot reload during development (not manual reload)
- Need TypeScript + React/Vue/Svelte in your extension
- Migrating from Manifest V2 to V3
- Want one codebase that targets multiple browsers
Instructions
Setup
npx wxt@latest init code-explainer -t react --pm npm # templates: vanilla, vue, react, svelte, solid
cd code-explainer
npm install # postinstall runs `wxt prepare`, which generates .wxt/ (types, tsconfig)
npm run dev # Opens Chrome with the extension loaded and hot reload
Without -t and --pm the init command asks for the template and package manager. To add WXT to an existing project: npm i -D wxt vite typescript, plus web-ext if the dev command should open a browser.
Project Structure
code-explainer/
├── entrypoints/
│ ├── popup/ # Popup UI (click extension icon)
│ │ ├── index.html
│ │ ├── main.tsx
│ │ └── App.tsx
│ ├── content.ts # Content script (runs on web pages)
│ └── background.ts # Service worker (background logic)
├── utils/ # Auto-imported helpers (also components/, hooks/, composables/)
├── public/
│ └── icon/ # 16.png, 32.png, 48.png, 96.png, 128.png — found automatically
├── .env # WXT_* and VITE_* variables, exposed on import.meta.env
├── wxt.config.ts
└── package.json
More content scripts go in files named {name}.content.ts. Other recognised entrypoint names include options, sidepanel, newtab and devtools (each a folder with an index.html).
Config and Permissions
WXT does not add permissions for you. Every API used below has to be declared, or it is undefined at runtime (storage throws):
// wxt.config.ts
import { defineConfig } from "wxt";
export default defineConfig({
modules: ["@wxt-dev/module-react"],
manifest: {
name: "Code Explainer",
permissions: ["storage", "alarms"],
host_permissions: ["https://api.openai.com/*"],
},
});
Write manifest keys in MV3 form (action, host_permissions); WXT converts them for MV2 builds. The manifest name and version default to the values in package.json, which also name the zip files — the template ships as wxt-react-starter 0.0.0, so edit both.
// utils/storage.ts — typed storage items, auto-imported everywhere
export const explainCount = storage.defineItem<number>("local:explainCount", { fallback: 0 });
Content Script
// entrypoints/content.ts — Runs on matched web pages; createShadowRootUi isolates the button's styles.
// DOM and extension API calls must stay inside main(): WXT imports this file in Node at build time.
export default defineContentScript({
matches: ["https://github.com/*"],
cssInjectionMode: "ui",
async main(ctx) {
const ui = await createShadowRootUi(ctx, {
name: "code-explainer",
position: "inline",
anchor: "body",
onMount(container) {
const btn = document.createElement("button");
btn.textContent = "Explain selection";
btn.style.cssText = "position:fixed;right:16px;bottom:16px;z-index:9999";
btn.onclick = async () => {
const code = window.getSelection()?.toString().slice(0, 5000);
if (!code) return;
// Send to background for the API call
const reply = await browser.runtime.sendMessage({ type: "EXPLAIN", code });
alert(reply.error ?? reply.summary);
};
container.append(btn);
},
});
ui.mount();
},
});
Background Service Worker
// entrypoints/background.ts — Service worker: API calls, alarms, message routing. No DOM access.
// The main function cannot be async.
export default defineBackground(() => {
// Since WXT 0.20 `browser` is the native API, not webextension-polyfill:
// answer with sendResponse and return true instead of returning a promise.
browser.runtime.onMessage.addListener((msg, _sender, sendResponse) => {
if (msg.type !== "EXPLAIN") return;
explain(msg.code)
.then((summary) => sendResponse({ summary }))
.catch((err) => sendResponse({ error: String(err)
Установить wxt в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл wxt?
WXT is a Vite-based framework that builds browser extensions for Chrome, Firefox, Safari, and Edge from one codebase. Use when someone asks to "build a browser extension", "Chrome extension with React", "WXT framework", "cross- browser extension", "manifest v3 extension", "build Firefox extension", or "browser extension with TypeScript". Covers content scripts, background workers, popup/options pages, storage, messaging, and publishing.
Как установить скилл wxt?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл wxt запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic