End-to-end workflow to build a Manifest V3 browser extension: decide which context owns each piece of logic (content script vs MV3 service worker vs injected page script vs popup/options), wire messaging between contexts, request the narrowest permissions (activeTab -> optional -> host -> all_urls), and pass Chrome/Edge/Firefox store review. Complements the manifest-permissions-audit and store-submission-readiness skills. The popup/options UI seams to frontend-engineering.
A browser extension is a multi-context distributed system: its UI is a frontend
app, but its execution model (ephemeral service worker, isolated content scripts,
a strict permission/store regime) is what makes it distinctive. This skill is the
end-to-end build workflow; pair it with the deeper audit/checklist skills it
references at each step. Traverse the decision trees in
../../knowledge/where-logic-lives.md and
../../knowledge/manifest-v3-architecture.mdbefore placing logic or requesting a permission.
1. Architecture — where does each piece of logic live?
Content script ↔ service worker ↔ popup/options → chrome.runtime.sendMessage
/ onMessage, or a long-lived chrome.runtime.connectPort; service worker →
a tab → chrome.tabs.sendMessage.
Content script (isolated) ↔ injected page script (main world) →
window.postMessage is the only bridge — validate origin, source, and
message shape; treat it as untrusted input.
Return true from an onMessage listener that responds asynchronously, and
remember the worker may have been asleep (don't rely on prior in-memory state).
Icons, screenshots, listing copy; single-purpose description that matches
behavior.
Tested on each target: Chrome, Edge (Chromium — usually drop-in),
Firefox (browser.*/Promise differences, webextension-polyfill,
browser_specific_settings.gecko.id, every version signed).
declarativeNetRequest rules (if any) validated; content-script match
patterns as narrow as the feature allows.
After publish: staged/percentage rollout where supported; monitor reviews +
error telemetry.
The popup / options UI is an ordinary frontend and routes to
frontend-engineering, not this skill: components/forms/accessibility, client
state (note chrome.storage + onChanged is the persistence/sync layer — don't
bolt a global store onto an already-transient popup), and popup open-speed/bundle
discipline (a popup must open fast, so bundle discipline matters more, not
less). See ../../CLAUDE.md §1 and §3.
This skill owns only the MV3-distinctive layer (context placement, service-worker
lifetime, messaging, permissions, store review). Full reference + the two Mermaid
decision trees:
../../knowledge/where-logic-lives.md
(where logic lives) and
../../knowledge/manifest-v3-architecture.md
(permissions-minimization). MV3 specifics are volatile — verify at use against the
Chrome/MDN/Firefox docs.
1---2name: build-browser-extension3description: "End-to-end workflow to build a Manifest V3 browser extension: decide which context owns each piece of logic (content script vs MV3 service worker vs injected page script vs popup/options), wire messaging between contexts, request the narrowest permissions (activeTab -> optional -> host -> all_urls), and pass Chrome/Edge/Firefox store review. Complements the manifest-permissions-audit and store-submission-readiness skills. The popup/options UI seams to frontend-engineering."4metadata:5 source: https://skillmd.com/skills/mcorbett51090/build-browser-extension6---78# Skill: Build a Browser Extension (Manifest V3)910A browser extension is a multi-context distributed system: its UI is a frontend11app, but its execution model (ephemeral service worker, isolated content scripts,12a strict permission/store regime) is what makes it distinctive. This skill is the13**end-to-end build workflow**; pair it with the deeper audit/checklist skills it14references at each step. Traverse the decision trees in15[`../../knowledge/where-logic-lives.md`](../../knowledge/where-logic-lives.md) and16[`../../knowledge/manifest-v3-architecture.md`](../../knowledge/manifest-v3-architecture.md)17**before** placing logic or requesting a permission.1819## 1. Architecture — where does each piece of logic live?2021Pick the **least-privileged context that works** (full tree:22[`../../knowledge/where-logic-lives.md`](../../knowledge/where-logic-lives.md)):2324| Need | Context |25|---|---|26| Read/modify a page's **DOM** (not its JS) | **Content script** (isolated world) |27| Reach the page's **own JS / window globals** | **Injected page script** (main world) — untrusted, bridge via `postMessage` |28| Privileged `chrome.*` APIs (tabs, alarms, network), background work | **Service worker** (MV3 background) — ephemeral, no DOM |29| Toolbar UI | **Popup** (`action.default_popup`) — transient |30| Settings / full page | **Options / extension page** |3132**Never assume two contexts share memory.** Cross-context state lives in33`chrome.storage` or is passed by message.3435## 2. Service worker discipline3637MV3's background is **event-driven and terminated when idle** — re-think any38"long-running/stateful" design:3940- Register **all** event listeners at the **top level**, synchronously, on every41 load — not inside an async callback, or the wake-up event is missed.42- Hold **no** in-memory state you can't lose; persist to `chrome.storage`,43 re-hydrate on wake.44- No DOM, no `localStorage` — it's a worker. (See45 [`../../best-practices/treat-the-background-as-ephemeral.md`](../../best-practices/treat-the-background-as-ephemeral.md).)4647## 3. Messaging4849- Content script ↔ service worker ↔ popup/options → `chrome.runtime.sendMessage`50 / `onMessage`, or a long-lived `chrome.runtime.connect` `Port`; service worker →51 a tab → `chrome.tabs.sendMessage`.52- Content script (isolated) ↔ injected page script (main world) →53 `window.postMessage` is the **only** bridge — **validate `origin`, `source`, and54 message shape**; treat it as untrusted input.55- Return `true` from an `onMessage` listener that responds asynchronously, and56 remember the worker may have been asleep (don't rely on prior in-memory state).5758See [`../../best-practices/message-pass-across-the-isolation-boundary.md`](../../best-practices/message-pass-across-the-isolation-boundary.md).5960## 4. Least-privilege permissions6162Walk the permissions tree narrowest-first — escalate only when a concrete feature63forces it, and justify each escalation in the listing:64651. **`activeTab`** — temporary current-tab access on a user gesture; no install66 warning. The default for user-initiated, current-tab actions.672. **Specific API perms** — exactly the `chrome.*` APIs you use (`storage`,68 `alarms`, `scripting`).693. **Narrow `host_permissions`** — specific match patterns70 (`https://api.example.com/*`), never `<all_urls>` reflexively.714. **`optional_permissions` / `optional_host_permissions`** — request broad access72 at runtime with `chrome.permissions.request()` on a user action.735. **`<all_urls>`** — only when running on arbitrary sites *is* the core function;74 expect stricter review.7576Re-audit at every release; drop unused permissions. Run the deeper audit with77[`../manifest-permissions-audit/SKILL.md`](../manifest-permissions-audit/SKILL.md)78(and see [`../../best-practices/request-least-privilege-permissions.md`](../../best-practices/request-least-privilege-permissions.md)).7980## 5. Store submission checklist8182- [ ] `manifest_version: 3`, version bumped.83- [ ] **No remotely-hosted code** — all executable JS ships in the package (fetch84 data, not code). (See85 [`../../best-practices/no-remotely-hosted-code.md`](../../best-practices/no-remotely-hosted-code.md).)86- [ ] Permissions minimized and **re-audited**; each (and any broad host access)87 justified.88- [ ] `web_accessible_resources` scoped to specific files + origins, never `*`.89 (See [`../../best-practices/scope-web-accessible-resources.md`](../../best-practices/scope-web-accessible-resources.md).)90- [ ] Privacy policy + accurate data-use disclosures.91- [ ] Icons, screenshots, listing copy; single-purpose description that matches92 behavior.93- [ ] Tested on each target: Chrome, **Edge** (Chromium — usually drop-in),94 **Firefox** (`browser.*`/Promise differences, `webextension-polyfill`,95 `browser_specific_settings.gecko.id`, every version signed).96- [ ] `declarativeNetRequest` rules (if any) validated; content-script match97 patterns as narrow as the feature allows.98- [ ] After publish: staged/percentage rollout where supported; monitor reviews +99 error telemetry.100101Run the full per-store readiness pass with102[`../store-submission-readiness/SKILL.md`](../store-submission-readiness/SKILL.md);103the cross-browser delta + the three pipelines live in104[`../../knowledge/cross-browser-and-stores.md`](../../knowledge/cross-browser-and-stores.md).105106## Seam — the UI is a frontend app107108The **popup / options UI** is an ordinary frontend and routes to109`frontend-engineering`, **not** this skill: components/forms/accessibility, client110state (note `chrome.storage` + `onChanged` is the persistence/sync layer — don't111bolt a global store onto an already-transient popup), and popup open-speed/bundle112discipline (a popup must open fast, so bundle discipline matters *more*, not113less). See [`../../CLAUDE.md`](../../CLAUDE.md) §1 and §3.114115This skill owns only the MV3-distinctive layer (context placement, service-worker116lifetime, messaging, permissions, store review). Full reference + the two Mermaid117decision trees:118[`../../knowledge/where-logic-lives.md`](../../knowledge/where-logic-lives.md)119(where logic lives) and120[`../../knowledge/manifest-v3-architecture.md`](../../knowledge/manifest-v3-architecture.md)121(permissions-minimization). MV3 specifics are volatile — verify at use against the122Chrome/MDN/Firefox docs.
Run npx get-skill add mcorbett51090/build-browser-extension in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
End-to-end workflow to build a Manifest V3 browser extension: decide which context owns each piece of logic (content script vs MV3 service worker vs injected page script vs popup/options), wire messaging between contexts, request the narrowest permissions (activeTab -> optional -> host -> all_urls), and pass Chrome/Edge/Firefox store review. Complements the manifest-permissions-audit and store-submission-readiness skills. The popup/options UI seams to frontend-engineering. It is listed under Web & Frontend on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: Skill Scanner: PASS. Capability flags: docs only. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
mcorbett51090 (@mcorbett51090) published this skill. Their other Agent Skills are listed on their SkillMD profile.