Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

chrome-extension-wxt

БесплатноЗапускает вложенные скриптыНе проверен

Builds cross-browser extensions with WXT - entrypoints, content-script UI, storage, messaging, MV3 rules, testing, publishing. Use for Chrome or browser…

tenequmот tenequm1 853 установки в других каталогах

Об этом скилле

Browser Extensions with WXT

WXT is a Vite-based framework that builds one codebase for Chrome, Firefox, Edge and Safari. It generates the manifest from files in entrypoints/, so there is no manifest.json in the source tree.

Verified against [email protected]. WXT 0.21 needs Node >= 22, and vite (^6.3.4, ^7 or ^8) is a required peer dependency.

Before you start

  1. Confirm it is a WXT project: wxt.config.ts exists and wxt is in package.json. If not, do not migrate the project unasked; the WXT sections do not apply, but references/chrome-mv3.md still does.
  2. Check the installed wxt version. This skill targets 0.21. Below 0.20 the import paths and several APIs differ: follow the upgrade guide before applying these patterns.

Rules that prevent most failures

  1. WXT APIs are auto-imported globals. defineBackground, defineContentScript, defineUnlistedScript, createShadowRootUi, browser, storage, injectScript, MatchPattern and ContentScriptContext need no import line. Never "fix" them as missing imports.
  2. The old import paths are gone. wxt/sandbox, wxt/client, wxt/storage and wxt/match-pattern do not exist; using one fails with Missing "./sandbox" specifier in "wxt" package. For an explicit import use import { storage } from '#imports'. The per-utility paths are wxt/utils/* and wxt/browser.
  3. "Cannot find name defineBackground" means the generated types are missing. Run wxt prepare (wired as "postinstall": "wxt prepare"). It regenerates .wxt/, which tsconfig.json extends. Do not add imports to silence it.
  4. .wxt/ and .output/ are generated. Gitignore both, along with web-ext.config.ts.
  5. Runtime code goes inside main(). WXT imports every entrypoint in Node at build time, so top-level browser.* or document.* calls fail the build with document is not defined.
  6. Nothing loose in entrypoints/. Every file or folder directly inside it becomes an entrypoint. Put helper files inside the entrypoint's own folder (popup/, overlay.content/) or in components/ and utils/. Entrypoints cannot nest deeper than one level, and names must be unique across types: foo.ts and foo.content.ts clash.
  7. await createShadowRootUi(...). It returns a promise. createIntegratedUi and createIframeUi are synchronous.
  8. Write the manifest in MV3 form. WXT converts action, host_permissions and web_accessible_resources for MV2 targets. It does not convert runtime API calls: see Targeting browsers. The extension version comes from package.json.
  9. The MV3 service worker is stateless. See Background.

What WXT recommends

Each line restates a recommendation from WXT's or Chrome's own docs.

  • Storage: define items with storage.defineItem; it is WXT's recommended way to get type safety.
  • Messaging: use a library that wraps the raw API, such as @webext-core/messaging.
  • Page-context code: inject an unlisted script with injectScript rather than world: 'MAIN'.
  • Manifest: write every property in MV3 form; WXT converts for MV2 targets.
  • Entrypoints: one directory per entrypoint, holding its own files.
  • Extension APIs: use browser, and feature-detect APIs a browser may lack.
  • Routing in pages: hash mode (createHashRouter and equivalents), because extension pages are static files.
  • Tests: Vitest with WxtVitest for units; Playwright for end-to-end.
  • Translations: the built-in browser.i18n API or @wxt-dev/i18n.

Two platform facts from Chrome's docs shape most designs:

  • Content scripts are less trustworthy than the background. A compromised page can forge their messages. Validate every message they send, and derive the page's origin from sender.url, not from the payload.
  • A popup closes as soon as it loses focus and cannot be kept open. Keep its state in storage.

Quick start

npx wxt@latest init my-extension -t react --pm npm
cd my-extension
npm install

Templates are vanilla, vue, react, svelte and solid (all TypeScript). --pm takes npm, pnpm, yarn or bun. There is no create-wxt package, so npm create wxt fails. The templates do not list vite; npm and pnpm install the peer automatically, so nothing is needed. With Yarn, add vite to devDependencies.

For an existing project: npm i -D wxt vite, then add the scripts the templates use:

{
  "scripts": {
    "dev": "wxt",
    "dev:firefox": "wxt -b firefox",
    "build": "wxt build",
    "build:firefox": "wxt build -b firefox",
    "zip": "wxt zip",
    "zip:firefox": "wxt zip -b firefox",
    "compile": "tsc --noEmit",
    "postinstall": "wxt prepare"
  }
}

npm run dev opens a browser with the extension loaded only when the optional web-ext package is installed (npm i -D web-ext). Without it, load `.output/chr

Полный SKILL.md на ClawHub

Установить chrome-extension-wxt в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл chrome-extension-wxt?

Builds cross-browser extensions with WXT - entrypoints, content-script UI, storage, messaging, MV3 rules, testing, publishing. Use for Chrome or browser extension work, wxt.config.ts, Manifest V3, or WXT build and type errors.

Как установить скилл chrome-extension-wxt?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл chrome-extension-wxt запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить chrome-extension-wxt с