Automated summary
Guides use of the WXT Vite-based framework to build cross-browser extensions with hot reload and file-based entrypoints.
Strengths
- Covers the full WXT project layout: entrypoints, popup, options, content scripts, and service worker
- Provides concrete code samples for content scripts and background messaging
- Explains hot reload and targeting Chrome, Firefox, Safari, and Edge from one codebase
- Includes the init and dev-mode commands to get started quickly
Limitations
- The provided content cuts off mid-sentence in the periodic tasks section, so build and publishing steps are not actually documented
- Examples focus on TypeScript/React and assume familiarity with Vite and Manifest V3 extensions
- The service worker example reads an API key from extension storage without discussing secure secret handling
Use it when starting or migrating a browser extension to WXT and you need a project skeleton plus reference patterns for scripts and messaging.
Skip it if you need thorough store-publishing guidance for Chrome or Safari, or a framework-free setup with a hand-written manifest.json.
Security analysis
SafeThe skill is documentation-only and contains normal setup commands plus illustrative code. It does not instruct destructive actions, obfuscated payloads, credential exfiltration, or disabling safety controls; the only sensitive area is the transparent API-key/data-sending example, which is presented for legitimate extension development.
- •The example code handles an OpenAI API key in extension storage and sends PR diff text to api.openai.com; this is a legitimate extension-development pattern but would benefit from explicit privacy/user-consent guidance.
Examples
Scaffold a WXT browser extension in TypeScript with a React popup and a content script that runs on GitHub, and make it build for both Chrome and Firefox.Using WXT, add a background service worker that receives messages from my content script and calls an external API, then returns the result to the page.Help me migrate my existing Manifest V2 Chrome extension to WXT with Manifest V3 while keeping Firefox support.name: wxt description: >- Build cross-browser extensions with WXT — the modern framework for Chrome, Firefox, Safari, and Edge extensions. 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. license: Apache-2.0 compatibility: "Chrome, Firefox, Safari, Edge. Supports React, Vue, Svelte, Solid." metadata: author: terminal-skills version: "1.0.0" category: development tags: ["browser-extension", "chrome", "firefox", "wxt", "manifest-v3"]
WXT
Overview
WXT is a Vite-based framework for building browser extensions — think "Next.js for extensions." File-based entrypoints, hot reload, TypeScript-first, and it outputs a single extension that works on Chrome (MV3), Firefox (MV2/MV3), Safari, and Edge. No more manually editing manifest.json or reloading the extension after every change.
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 my-extension
cd my-extension
npm install
npm run dev # Opens Chrome with hot-reloading extension
Project Structure
my-extension/
├── entrypoints/
│ ├── popup/ # Popup UI (click extension icon)
│ │ ├── index.html
│ │ ├── main.tsx
│ │ └── App.tsx
│ ├── options/ # Options page
│ │ ├── index.html
│ │ └── main.tsx
│ ├── content.ts # Content script (runs on web pages)
│ └── background.ts # Service worker (background logic)
├── public/
│ └── icon/
│ ├── 16.png
│ ├── 48.png
│ └── 128.png
├── wxt.config.ts
└── package.json
Content Script
// entrypoints/content.ts — Runs on matched web pages
/**
* Content scripts have access to the DOM of the page.
* Define which URLs to match with the `matches` export.
*/
export default defineContentScript({
matches: ["*://*.github.com/*"], // Run on GitHub pages
main() {
// Add a custom button to every GitHub PR page
const prHeader = document.querySelector(".gh-header-actions");
if (prHeader) {
const btn = document.createElement("button");
btn.textContent = "🤖 AI Review";
btn.className = "btn btn-sm";
btn.onclick = async () => {
const diff = document.querySelector(".diff-view")?.textContent;
// Send to background for API call
const review = await browser.runtime.sendMessage({
type: "REVIEW_PR",
diff: diff?.slice(0, 5000),
});
alert(review.summary);
};
prHeader.prepend(btn);
}
},
});
Background Service Worker
// entrypoints/background.ts — Persistent background logic
/**
* Service worker handles API calls, alarms, and message routing.
* No DOM access here — communicate with content scripts via messaging.
*/
export default defineBackground(() => {
// Handle messages from content scripts
browser.runtime.onMessage.addListener(async (msg, sender) => {
if (msg.type === "REVIEW_PR") {
const response = await fetch("https://api.openai.com/v1/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${await storage.getItem("local:apiKey")}`,
},
body: JSON.stringify({
model: "gpt-4o",
messages: [{ role: "user", content: `Review this diff:\n${msg.diff}` }],
}),
});
const data = await response.json();
return { summary: data.choices[0].message.content };
}
});
// Periodic tasks with alarms
browser.alarms.create("check-notifications", { periodInMinutes: 5 });
browser.alarms.onAlarm.addListener(async (alarm) => {
if (alarm.name === "check-notifications") {
// Check for updates, show badge
const count = await checkNotifications();
if (count > 0) {
browser.action.setBadgeText({ text: String(count) });
}
}
});
});
Popup UI (React)
// entrypoints/popup/App.tsx — Extension popup with React
import { useState, useEffect } from "react";
export default function App() {
const [apiKey, setApiKey] = useState("");
const [saved, setSaved] = useState(false);
useEffect(() => {
storage.getItem<string>("local:apiKey").then((key) => {
if (key) setApiKey(key);
});
}, []);
const save = async () => {
await storage.setItem("local:apiKey", apiKey);
setSaved(true);
setTimeout(() => setSaved(false), 2000);
};
return (
<div style={{ width: 300, padding: 16 }}>
<h2>🤖 AI PR Reviewer</h2>
<input
type="password"
value={apiKey}
onChange={(e) => setApiKey(e.target.value)}
placeholder="OpenAI API Key"
style={{ width: "100%" }}
/>
<button onClick={save} style={{ marginTop: 8 }}>
{saved ? "✅ Saved!" : "Save Key"}
</button>
</div>
);
}
Build for Multiple Browsers
# Development (Chrome with hot reload)
npm run dev
# Development for Firefox
npm run dev:firefox
# Build for all browsers
npm run build # Chrome MV3
npm run build:firefox # Firefox MV2/MV3
# Zip for store submission
npm run zip
npm run zip:firefox
Examples
Example 1: Build a productivity extension
User prompt: "Build a Chrome extension that blocks distracting websites during focus time."
The agent will create a WXT extension with a popup for configuring blocked sites and focus timer, a content script that shows a block page on matched domains, and background alarms for timer management.
Example 2: Content enhancement extension
User prompt: "Build an extension that adds AI-powered summaries to any article page."
The agent will create a content script that detects article content, a floating sidebar UI, and background API calls to summarize text.
Guidelines
- File-based entrypoints — file name and location determine the extension component
browser.*API — WXT polyfills Chrome and Firefox differences automaticallystoragehelper — type-safe extension storage withstorage.getItem/setItem- Hot reload works —
npm run devreloads content scripts and popup on save - MV3 service workers — background scripts are service workers (no persistent state)
matchesfor content scripts — define URL patterns where scripts should inject- Message passing — content script ↔ background communication via
browser.runtime.sendMessage - One codebase, all browsers — build targets handle manifest differences
- Icons at 16/48/128px — required for Chrome Web Store
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/build-browser-extensions-with-wxt-msshyvpe/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/build-browser-extensions-with-wxt-msshyvpe' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/build-browser-extensions-with-wxt-msshyvpe/download' --output '.skill-downloads/build-browser-extensions-with-wxt-msshyvpe/SKILL.md.part' && mv '.skill-downloads/build-browser-extensions-with-wxt-msshyvpe/SKILL.md.part' '.skill-downloads/build-browser-extensions-with-wxt-msshyvpe/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
Environment declared by the author: Chrome, Firefox, Safari, Edge. Supports React, Vue, Svelte, Solid.
Original excerpt: Setup
npx wxt@latest init my-extension
cd my-extension
npm install
npm run dev # Opens Chrome with hot-reloading extension
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/build-browser-extensions-with-wxt-msshyvpe/SKILL.md' && test -s '.skill-downloads/build-browser-extensions-with-wxt-msshyvpe/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/wxt' && cp -R '.skill-downloads/build-browser-extensions-with-wxt-msshyvpe' '.claude/skills/wxt'Cursor
test -f '.skill-downloads/build-browser-extensions-with-wxt-msshyvpe/SKILL.md' && test -s '.skill-downloads/build-browser-extensions-with-wxt-msshyvpe/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/wxt' && cp -R '.skill-downloads/build-browser-extensions-with-wxt-msshyvpe' '.cursor/skills/wxt'Codex
test -f '.skill-downloads/build-browser-extensions-with-wxt-msshyvpe/SKILL.md' && test -s '.skill-downloads/build-browser-extensions-with-wxt-msshyvpe/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/wxt' && cp -R '.skill-downloads/build-browser-extensions-with-wxt-msshyvpe' '.agents/skills/wxt'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/build-browser-extensions-with-wxt-msshyvpe'openskills read 'build-browser-extensions-with-wxt-msshyvpe'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/build-browser-extensions-with-wxt-msshyvpe/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.