@extension.dev/skill 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "extensiondev",
3
+ "owner": {
4
+ "name": "Cezar Augusto",
5
+ "email": "boss@cezaraugusto.net",
6
+ "url": "https://extension.dev"
7
+ },
8
+ "plugins": [
9
+ {
10
+ "name": "extension-dev",
11
+ "source": "./",
12
+ "description": "Build, debug, and publish cross-browser extensions (Chrome, Edge, Firefox): Manifest V3 gotchas, chromium:/firefox: manifest prefixes, live-browser verification playbooks, and store publishing checklists.",
13
+ "version": "0.3.0",
14
+ "category": "development",
15
+ "author": {
16
+ "name": "Cezar Augusto"
17
+ },
18
+ "homepage": "https://github.com/extensiondev/skill",
19
+ "skills": [
20
+ "./skills/extension-dev"
21
+ ],
22
+ "strict": false
23
+ }
24
+ ]
25
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "extension-dev",
3
+ "description": "Cross-browser extension development skill: Manifest V3 gotchas, chromium:/firefox: manifest prefixes, live-browser verification playbooks, and store publishing checklists for the extension.dev / Extension.js stack.",
4
+ "version": "0.3.0",
5
+ "author": {
6
+ "name": "Cezar Augusto",
7
+ "email": "boss@cezaraugusto.net",
8
+ "url": "https://cezaraugusto.com"
9
+ },
10
+ "homepage": "https://github.com/extensiondev/skill",
11
+ "repository": "https://github.com/extensiondev/skill",
12
+ "license": "MIT",
13
+ "keywords": [
14
+ "agent-skill",
15
+ "browser-extension",
16
+ "chrome-extension",
17
+ "firefox-addon",
18
+ "edge-extension",
19
+ "manifest-v3",
20
+ "webextension",
21
+ "cross-browser"
22
+ ]
23
+ }
package/CHANGELOG.md CHANGED
@@ -1,59 +1,36 @@
1
1
  # Changelog
2
2
 
3
- ## 0.2.1
4
-
5
- Accuracy pass against Extension.js 4.0.9 and the 28-tool MCP surface
6
- (@extension.dev/mcp 4.2.0).
7
-
8
- - Prefix semantics re-verified against the 4.0.9 resolver: precedence is
9
- now documented as deterministic plain < family prefix < exact-browser
10
- prefix, and Safari targets (safari, webkit-based) inherit the chromium
11
- family with safari:/webkit: prefixes winning on those targets. The
12
- conventions-sync suite pins the new source shape.
13
- - New MCP session lifecycle documented: extension_stop (kill the dev
14
- server plus its browser when verification is done) in the workflow,
15
- the verify table, and the debugging reference.
16
- - Previously unmentioned tools woven in where an agent needs them:
17
- extension_dev (workflow step 4), extension_add_feature (growing an
18
- existing project), extension_list_browsers (managed-browser inventory).
19
- - "MCP-only" claim for extension_release_promote tightened: no
20
- `extension` CLI equivalent, but reachable outside MCP sessions via the
21
- package's own `extension-mcp release promote` bin.
22
- - MCP tool count updated to 28.
23
-
24
- ## 0.2.0
25
-
26
- Accuracy pass against the Extension.js 4.0.8 suite and the 27-tool MCP
27
- surface, ahead of the public npm flip.
28
-
29
- - Re-verified all framework facts against Extension.js 4.0.8 (was 3.18.3);
30
- `conventions-sync` green against the 4.0.8 source.
31
- - Side panel example fixed: `chrome.sidePanel.setPanelBehavior` now runs at
32
- the top level of the worker. Installing it inside `action.onClicked` (the
33
- previous pattern, inherited from upstream templates) silently swallows the
34
- first toolbar click because the behavior only affects future clicks.
35
- - `world: "MAIN"` guidance updated: Firefox supports the manifest `world`
36
- key from 128+; the `chromium:` prefix now documented as the
37
- older-Firefox fallback rather than a hard Chromium-only rule.
38
- - Documented `extension_release_promote` (headless channel promotion, MCP
39
- only) in the publishing reference, and corrected the "every MCP capability
40
- has a CLI equivalent" claim it falsifies.
41
- - MCP tool count updated to 27; README stack table now links npm pages
42
- (publicly reachable) instead of repository URLs.
43
-
44
- ## 0.1.0
3
+ ## 0.3.0
45
4
 
46
5
  Initial release.
47
6
 
48
- - `extension-dev` Agent Skill (SKILL.md + six progressive-disclosure
49
- references): cross-browser rules, project structure, template catalog,
50
- runtime API gotchas, debugging playbook, publishing checklist.
51
- - Framework facts verified against Extension.js 3.18.3, with a
52
- `conventions-sync` test suite that re-verifies against an Extension.js
53
- checkout (prefix families, prefixed-over-plain override semantics,
54
- canonical content script output naming, special folders, env var prefix).
55
- - `skill-structure` test suite: frontmatter validity, reference link
56
- integrity, progressive-disclosure line budget, copy conventions.
57
- - Eval harness in `evals/`: three benchmark tasks (cross-browser sidebar
58
- scaffold, injection debugging, service worker state bugs) with fixtures
59
- and assertion sets.
7
+ - Accuracy pass from the with-the-skill stress exercise (developer agents vs
8
+ the real Extension.js 4.0.10 engine): production builds default the
9
+ cross-browser polyfill **off** (`browser.*` needs
10
+ `npm run build -- --polyfill`); `world: "MAIN"` must stay unprefixed
11
+ (`chromium:world` hard-fails the Chromium build; pair with
12
+ `firefox:world: "ISOLATED"`); content-script style imports are inlined as
13
+ base64 `data:text/css` rather than emitted as sibling `.css` files;
14
+ `_locales/` lives at the project root (with new i18n docs); TypeScript
15
+ entries require a root `tsconfig.json`; shared modules are duplicated per
16
+ content-script entry.
17
+
18
+ - `extension-dev` Agent Skill (SKILL.md plus six progressive-disclosure
19
+ references): cross-browser manifest rules, project structure, template
20
+ catalog, runtime API gotchas, live-browser debugging playbook, and store
21
+ publishing checklist.
22
+ - Framework facts verified against Extension.js 4.0.10, enforced by three
23
+ test suites: `skill-structure` (frontmatter, link integrity, line budget,
24
+ version sync, copy conventions), `conventions-sync` (asserts documented
25
+ conventions against an Extension.js checkout), and `templates-sync`
26
+ (asserts every recommended template slug against the nightly
27
+ templates-meta.json catalog).
28
+ - Spec compliance checked in CI with `skills-ref validate`.
29
+ - Eval harness in `evals/` with graded assertion sets: three benchmark
30
+ tasks (cross-browser sidebar scaffold, injection debugging, service
31
+ worker state bugs), benchmarked at 15/15 assertions with the skill vs
32
+ 10/15 for a no-skill baseline.
33
+ - Distribution surfaces: Agent Skills layout consumable by `npx skills add`
34
+ and `gh skill install`, Claude Code plugin manifests in `.claude-plugin/`
35
+ (marketplace + plugin), and the npm package with the `agents.skills`
36
+ discovery field for version-locked installs.
package/README.md CHANGED
@@ -1,16 +1,40 @@
1
- # @extension.dev/skill
1
+ [npm-version-image]: https://img.shields.io/npm/v/@extension.dev/skill.svg?color=0971fe
2
+ [npm-version-url]: https://www.npmjs.com/package/@extension.dev/skill
3
+ [npm-downloads-image]: https://img.shields.io/npm/dm/@extension.dev/skill.svg?color=0971fe
4
+ [npm-downloads-url]: https://www.npmjs.com/package/@extension.dev/skill
5
+ [stars-image]: https://img.shields.io/github/stars/extensiondev/skill?style=flat&color=0971fe
6
+ [stars-url]: https://github.com/extensiondev/skill/stargazers
7
+ [action-image]: https://github.com/extensiondev/skill/actions/workflows/ci.yml/badge.svg?branch=main&color=0971fe
8
+ [action-url]: https://github.com/extensiondev/skill/actions
9
+ [discord-image]: https://img.shields.io/discord/1253608412890271755?label=Discord&logo=discord&style=flat&color=0971fe
10
+ [discord-url]: https://discord.gg/v9h2RgeTSN
11
+
12
+ # @extension.dev/skill [![Version][npm-version-image]][npm-version-url] [![Downloads][npm-downloads-image]][npm-downloads-url] [![Discord][discord-image]][discord-url]
13
+ <!-- once the repo is public, add to the title line:
14
+ [![Stars][stars-image]][stars-url] [![CI][action-image]][action-url]
15
+ and the skills.sh directory badge:
16
+ [![skills.sh](https://skills.sh/b/extensiondev/skill)](https://skills.sh/extensiondev/skill) -->
17
+
18
+ > The Agent Skill for cross-browser extension development. Teaches your coding agent to build, debug, and publish for Chrome, Edge, and Firefox.
19
+
20
+ <img alt="Logo" align="right" src="https://media.extension.land/brand/extension-dev/logo.png" width="20.25%" />
2
21
 
3
- [![npm version](https://img.shields.io/npm/v/@extension.dev/skill.svg)](https://www.npmjs.com/package/@extension.dev/skill)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)
22
+ ```bash
23
+ npx skills add extensiondev/skill
24
+ ```
25
+
26
+ Works with Claude Code, Cursor, GitHub Copilot, Codex, Windsurf, and any agent that supports the open [Agent Skills](https://agentskills.io) format.
5
27
 
6
- Agent Skill for building, debugging, and publishing cross-browser extensions
7
- with [extension.dev](https://extension.dev), powered by the open-source
8
- [Extension.js](https://extension.js.org) framework.
28
+ [Documentation](https://extension.dev) · [MCP server](https://www.npmjs.com/package/@extension.dev/mcp) · [Extension.js](https://extension.js.org) · [Discord](https://discord.gg/v9h2RgeTSN)
9
29
 
10
- This is the knowledge half of the extension.dev agent stack:
30
+ ## Why @extension.dev/skill
31
+
32
+ Powered by [extension.dev](https://extension.dev) and the open-source
33
+ [Extension.js](https://extension.js.org) framework, this is the knowledge
34
+ half of the extension.dev agent stack:
11
35
 
12
36
  - **[@extension.dev/mcp](https://www.npmjs.com/package/@extension.dev/mcp)**
13
- gives agents *hands*: 28 MCP tools for scaffolding, building, live DOM
37
+ gives agents *hands*: 28+ MCP tools for scaffolding, building, live DOM
14
38
  inspection, log streaming, publishing, and headless release promotion.
15
39
  - **@extension.dev/skill** gives agents *judgment*: when to use which tool,
16
40
  the cross-browser rules, the silent-failure gotchas, and the publish
@@ -22,34 +46,63 @@ path. It shines when the MCP server is connected, because the skill tells the
22
46
  agent to verify against the live browser instead of guessing, and the MCP
23
47
  tools make that a one-call operation.
24
48
 
49
+ In the shipped benchmark, a skill-equipped agent passed **15/15** graded
50
+ assertions; the no-skill baseline passed 10/15. Details and reproduction in
51
+ [Why a skill on top of an MCP server](#why-a-skill-on-top-of-an-mcp-server).
52
+
25
53
  ## Install
26
54
 
27
- ### Claude Code, current project
55
+ The skill is plain markdown in the open Agent Skills format. Every lane
56
+ below installs the same skill; pick the one that fits your setup.
57
+
58
+ ### Any agent, one command
28
59
 
29
60
  ```bash
30
- npm i -D @extension.dev/skill
31
- mkdir -p .claude/skills
32
- cp -R node_modules/@extension.dev/skill/skills/extension-dev .claude/skills/
61
+ npx skills add extensiondev/skill
62
+ ```
63
+
64
+ Installs into every agent detected on your machine. Use `-g` for user scope
65
+ instead of project scope, or `-a claude-code` (or `-a cursor`, `-a copilot`,
66
+ ...) to target one agent.
67
+
68
+ ### Claude Code, native plugin flow
69
+
70
+ ```
71
+ /plugin marketplace add extensiondev/skill
72
+ /plugin install extension-dev@extensiondev
73
+ ```
74
+
75
+ ### GitHub CLI
76
+
77
+ ```bash
78
+ gh skill install extensiondev/skill extension-dev
33
79
  ```
34
80
 
35
- ### Claude Code, personal (all projects)
81
+ ### npm, version-locked
82
+
83
+ The same skill ships inside the npm package, pinned to the package version,
84
+ so it can ride your dependency tree and update with `npm update`:
36
85
 
37
86
  ```bash
38
- npm i -g @extension.dev/skill
39
- mkdir -p ~/.claude/skills
40
- cp -R "$(npm root -g)/@extension.dev/skill/skills/extension-dev" ~/.claude/skills/
87
+ npm i -D @extension.dev/skill
41
88
  ```
42
89
 
43
- ### Without npm
90
+ The package declares the `agents.skills` field, so npm-aware skill
91
+ installers (for example [skills-npm](https://github.com/antfu/skills-npm),
92
+ via a `"prepare": "skills-npm"` script) link it into your agents
93
+ automatically on install. Manual fallback for Claude Code:
44
94
 
45
- Copy the `skills/extension-dev/` directory from this repository into your
46
- agent's skills location. The skill is plain markdown with no build step.
95
+ ```bash
96
+ cp -R node_modules/@extension.dev/skill/skills/extension-dev .claude/skills/
97
+ ```
47
98
 
48
- ### Other agents
99
+ ### Agents without skills support
49
100
 
50
- Any runtime that supports the Agent Skills format can load
51
- `skills/extension-dev/` directly. The SKILL.md frontmatter carries the
52
- triggering description; reference files load on demand.
101
+ Add one line to your `AGENTS.md` (or `CLAUDE.md`):
102
+
103
+ ```
104
+ For any browser-extension work, read .agents/skills/extension-dev/SKILL.md before writing code.
105
+ ```
53
106
 
54
107
  ### Pair with the MCP server
55
108
 
@@ -57,6 +110,20 @@ triggering description; reference files load on demand.
57
110
  claude mcp add extension-dev npx @extension.dev/mcp
58
111
  ```
59
112
 
113
+ ## Your first prompt
114
+
115
+ After installing, try:
116
+
117
+ ```
118
+ Create a browser extension that highlights every external link on a page.
119
+ It must work on Chrome and Firefox from a single codebase, and I want proof
120
+ it actually injects: inspect the live browser, do not just tell me it works.
121
+ ```
122
+
123
+ A skill-equipped agent will scaffold from a template, write one prefixed
124
+ manifest instead of two, and verify injection with `--source-probe` or the
125
+ MCP inspection tools instead of declaring victory.
126
+
60
127
  ## What's inside
61
128
 
62
129
  ```
@@ -64,7 +131,7 @@ skills/
64
131
  extension-dev/
65
132
  SKILL.md Triggering metadata + workflow + core rules
66
133
  references/
67
- templates.md 60+ template catalog as a pattern library
134
+ templates.md 50+ template catalog as a pattern library
68
135
  project-structure.md Layout, entry wiring, special folders, env vars
69
136
  cross-browser.md chromium:/firefox: prefixes, API namespaces
70
137
  api-gotchas.md Service worker lifetime, gestures, messaging
@@ -79,50 +146,44 @@ agent reads only the reference file that matches the task at hand.
79
146
 
80
147
  An MCP server can expose a live-DOM probe, but nothing makes an agent think
81
148
  to call it when a content script silently fails to inject. Skills shape
82
- behavior before any tool is called. In benchmark runs of this skill against
83
- a no-skill baseline on identical tasks, the skill run produced idiomatic
84
- single-manifest cross-browser projects and evidence-driven debugging plans,
85
- while the baseline hand-rolled per-browser manifests with custom build
86
- scripts and debugged by opening four consoles manually. The benchmark
87
- harness ships in `evals/`.
149
+ behavior before any tool is called.
150
+
151
+ In the shipped benchmark (three tasks, five graded assertions each,
152
+ identical prompts), the skill run passed **15/15** assertions against 10/15
153
+ for a no-skill baseline. The baseline hand-rolled per-browser manifests with
154
+ custom build scripts and debugged by opening four consoles manually; the
155
+ skill run produced a single prefixed manifest and an evidence-driven
156
+ debugging plan. The harness, fixtures, and assertion sets ship in `evals/`,
157
+ so the numbers are reproducible.
88
158
 
89
159
  ## Accuracy and versioning
90
160
 
91
161
  Framework facts in the references (prefix families, override semantics,
92
162
  canonical output naming, special folders, env prefix) are verified against
93
163
  the Extension.js source and carry a "verified against Extension.js x.y.z"
94
- pin. Two test suites enforce this:
164
+ pin. Three test suites plus a spec check enforce this:
95
165
 
96
166
  ```bash
97
167
  npm test
168
+ npx skills-ref validate skills/extension-dev
98
169
  ```
99
170
 
100
171
  - `skill-structure` validates frontmatter, reference links, the
101
- progressive-disclosure line budget, and copy conventions.
172
+ progressive-disclosure line budget, version sync across the plugin
173
+ manifests, and copy conventions.
102
174
  - `conventions-sync` asserts the documented conventions against an
103
175
  Extension.js checkout (`EXTENSION_JS_REPO` env var, or a sibling
104
176
  `extension.js` directory) and skips when none is present. CI should check
105
177
  out [extension-js/extension.js](https://github.com/extension-js/extension.js)
106
178
  alongside this repo so the suite never silently skips.
179
+ - `templates-sync` asserts every template slug the skill recommends against
180
+ the nightly templates-meta.json release asset, and skips offline.
181
+ - `skills-ref validate` checks the skill against the open Agent Skills
182
+ specification.
107
183
 
108
184
  When Extension.js changes a documented convention, the sync test fails and
109
185
  names the reference file to update. Bump the version pin when re-verifying.
110
186
 
111
- ## Related
112
-
113
- - [Extension.js](https://github.com/extension-js/extension.js): the
114
- cross-browser extension framework these conventions come from
115
- - [extension-js/examples](https://github.com/extension-js/examples): the
116
- template catalog the skill treats as a pattern library
117
- - [@extension.dev/mcp](https://www.npmjs.com/package/@extension.dev/mcp):
118
- the MCP server companion
119
- - [GoogleChrome chrome-extensions skill](https://github.com/GoogleChrome/modern-web-guidance-src/tree/main/skills-src/chrome-extensions):
120
- Google's Chrome-only counterpart. This skill differs in three deliberate
121
- ways: cross-browser by construction (one source tree for Chrome, Edge,
122
- Firefox via manifest prefixes), a live CI-tested pattern library instead of
123
- static snippets, and a closed verification loop where every "did it work"
124
- question maps to a concrete tool call.
125
-
126
187
  ## Contributing
127
188
 
128
189
  The skill content is plain markdown; edit, run `npm test`, and open a pull
@@ -141,6 +202,10 @@ the eval metadata files for the assertion sets.
141
202
 
142
203
  All of it rides on [Extension.js](https://github.com/extension-js/extension.js), the open-source cross-browser extension framework.
143
204
 
205
+ If the skill saves your agent a debugging session, a
206
+ [star on GitHub](https://github.com/extensiondev/skill) helps other
207
+ extension developers find it.
208
+
144
209
  ## License
145
210
 
146
211
  MIT
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@extension.dev/skill",
3
3
  "type": "module",
4
- "version": "0.2.1",
5
- "description": "Agent Skill for cross-browser extension development. Teaches AI agents the Manifest V3 gotchas, cross-browser manifest rules, and live-browser verification playbooks behind extension.dev and Extension.js.",
4
+ "version": "0.3.0",
5
+ "description": "Agent Skill that teaches AI coding agents (Claude Code, Cursor, Copilot, Codex) to build, debug, and publish browser extensions for Chrome, Edge, and Firefox: Manifest V3 gotchas, cross-browser manifest rules, and live-browser verification playbooks. Powered by extension.dev and Extension.js.",
6
6
  "license": "MIT",
7
7
  "author": {
8
8
  "name": "Cezar Augusto",
@@ -16,37 +16,50 @@
16
16
  "bugs": {
17
17
  "url": "https://github.com/extensiondev/skill/issues"
18
18
  },
19
- "homepage": "https://github.com/extensiondev/skill#readme",
19
+ "homepage": "https://extension.dev",
20
20
  "engines": {
21
21
  "node": ">=20.18"
22
22
  },
23
+ "packageManager": "pnpm@10.19.0",
23
24
  "files": [
24
25
  "skills",
26
+ ".claude-plugin",
25
27
  "README.md",
26
28
  "CHANGELOG.md",
27
29
  "LICENSE"
28
30
  ],
31
+ "agents": {
32
+ "skills": [
33
+ "./skills/extension-dev"
34
+ ]
35
+ },
36
+ "scripts": {
37
+ "test": "node --test test/*.test.mjs"
38
+ },
29
39
  "publishConfig": {
30
40
  "access": "public",
31
41
  "registry": "https://registry.npmjs.org"
32
42
  },
33
43
  "keywords": [
34
44
  "agent-skill",
45
+ "agent-skills",
35
46
  "claude-skill",
36
47
  "skills",
37
48
  "anthropic",
38
49
  "claude",
39
50
  "claude-code",
51
+ "cursor",
52
+ "github-copilot",
53
+ "codex",
40
54
  "ai-agent",
41
55
  "browser-extension",
42
56
  "chrome-extension",
43
57
  "firefox-addon",
58
+ "edge-extension",
44
59
  "manifest-v3",
45
60
  "webextension",
46
61
  "cross-browser",
47
- "extension.dev"
48
- ],
49
- "scripts": {
50
- "test": "node --test test/*.test.mjs"
51
- }
52
- }
62
+ "extension.dev",
63
+ "extension.js"
64
+ ]
65
+ }
@@ -1,6 +1,10 @@
1
1
  ---
2
2
  name: extension-dev
3
3
  description: Build, debug, and publish cross-browser extensions (Chrome, Edge, Firefox) with the extension.dev framework. Use this skill whenever the user mentions browser extensions, Chrome extensions, Firefox add-ons, WebExtensions, Manifest V3, manifest.json, content scripts, service workers, side panels, popups, options pages, chrome.* or browser.* APIs, or publishing to the Chrome Web Store or Firefox Add-ons, even if they never name extension.dev or Extension.js explicitly. Also use it when debugging why an extension does not load, inject, or update.
4
+ license: MIT
5
+ metadata:
6
+ author: Cezar Augusto
7
+ version: 0.3.0
4
8
  ---
5
9
 
6
10
  # Cross-Browser Extension Development
@@ -13,7 +17,7 @@ publish.
13
17
 
14
18
  Two companions do the heavy lifting. Prefer them over guessing:
15
19
 
16
- - **`@extension.dev/mcp`** (MCP server): 28 tools for scaffolding, building,
20
+ - **`@extension.dev/mcp`** (MCP server): 28+ tools for scaffolding, building,
17
21
  live DOM inspection, log streaming, storage access, publishing, and headless
18
22
  release promotion. If its `extension_*` tools are available in the session,
19
23
  use them.
@@ -25,7 +29,7 @@ Two companions do the heavy lifting. Prefer them over guessing:
25
29
 
26
30
  ## Workflow
27
31
 
28
- 1. **Start from a template, not a blank file.** The catalog has 60+ working
32
+ 1. **Start from a template, not a blank file.** The catalog has 50+ working
29
33
  examples (React, Vue, Svelte, Preact, vanilla; every surface). Match the
30
34
  user's surface + framework, then scaffold:
31
35
  `npx extension@latest create my-ext --template=<slug>`
@@ -46,9 +50,12 @@ Two companions do the heavy lifting. Prefer them over guessing:
46
50
  popup, or content script from catalog patterns instead of hand-rolling one.
47
51
  See [references/debugging.md](references/debugging.md).
48
52
  5. **Build and verify per browser.** `npm run build -- --browser=chrome,firefox`
49
- then `npm run start` to test the production build before shipping. When a
50
- verification session is done, shut it down (MCP: `extension_stop`) so dev
51
- servers and browsers do not pile up.
53
+ then `npm run preview` to test the production build before shipping.
54
+ Prefer `preview` over `start` here: `start` runs its own build with the
55
+ polyfill on by default, so it can pass while the artifact from
56
+ `npm run build --zip` throws (core rule 5). When a verification session is
57
+ done, shut it down (MCP: `extension_stop`) so dev servers and browsers do
58
+ not pile up.
52
59
  6. **Publish deliberately.** Zip with `--zip`, check the store-readiness rules,
53
60
  then submit (or publish to extension.dev via `extension_publish`). See
54
61
  [references/publishing.md](references/publishing.md).
@@ -60,7 +67,10 @@ platform fails silently when you get it wrong.
60
67
 
61
68
  1. **Manifest first, schema always.** Start every project at `manifest.json`
62
69
  with `"$schema": "https://json.schemastore.org/chrome-manifest.json"`. All
63
- paths in the manifest are relative to `src/`.
70
+ paths in the manifest are relative to `src/`, with one exception:
71
+ `_locales/` belongs at the **project root** (next to `package.json`).
72
+ `src/_locales` builds with a deprecation warning; `public/_locales` fails
73
+ the build.
64
74
  2. **Manifest V3 on Chromium.** No `background.scripts`, no
65
75
  `chrome.browserAction`, no inline scripts, no remote code. Firefox may stay
66
76
  on MV2 via `firefox:manifest_version: 2`.
@@ -68,20 +78,29 @@ platform fails silently when you get it wrong.
68
78
  `firefox:browser_action`, `chromium:side_panel` vs `firefox:sidebar_action`,
69
79
  `chromium:service_worker` (string) vs `firefox:scripts` (array). Unprefixed
70
80
  fields apply everywhere; a matching prefixed key overrides the plain key,
71
- and prefixes resolve at any nesting depth (so `chromium:world` works inside
72
- a `content_scripts` entry).
81
+ and prefixes resolve at any nesting depth (so `firefox:world` works inside
82
+ a `content_scripts` entry). Exception: never prefix `world` as
83
+ `chromium:world` (see rule 6).
73
84
  4. **Side panels need an open trigger and the right permission.** Chromium
74
85
  requires the `sidePanel` permission plus explicit open behavior
75
86
  (`chrome.sidePanel.setPanelBehavior` or `open()` from a gesture). Firefox's
76
87
  `sidebar_action` needs neither. Declaring the panel in the manifest alone
77
88
  shows nothing.
78
- 5. **Prefer `browser.*` over `chrome.*`.** The framework polyfills `browser.*`
79
- on Chromium, so cross-browser code reads one way. Reach for `chrome.*` only
80
- for Chromium-only APIs like `chrome.sidePanel`.
81
- 6. **Prefix `world: "MAIN"` as `chromium:world`.** Firefox only understands
82
- the manifest `world` key from 128+, so the prefix keeps older Firefox on
83
- the isolated-world fallback. Branch in code if the feature truly needs
84
- main-world access there.
89
+ 5. **`browser.*` needs the polyfill, and production builds skip it.** The
90
+ polyfill is on by default for `dev` and `start` but **off by default for
91
+ `build`**, so `browser.*` throws in a production Chrome service worker even
92
+ though the same code worked all through development (and `npm run start`
93
+ masks it, because `start` rebuilds with the polyfill on). If you write
94
+ `browser.*`, ship with `npm run build -- --polyfill`. Otherwise write
95
+ `chrome.*` (promise-based on MV3) and reserve `browser.*` for
96
+ Firefox-specific branches.
97
+ 6. **Write `world: "MAIN"` unprefixed, never `chromium:world`.** The build
98
+ inserts a main-world bridge keyed off the literal `world` key; the prefixed
99
+ form hard-fails the Chromium build. Firefox keeps the unprefixed key
100
+ verbatim (understood from Firefox 128+), so pair it with
101
+ `firefox:world: "ISOLATED"` when older Firefox must stay on the isolated
102
+ world, and branch in code if the feature truly needs main-world access
103
+ there.
85
104
  7. **Service workers hold no state.** Chromium kills the worker after ~30s
86
105
  idle. Module-level variables vanish; persist everything to
87
106
  `chrome.storage.local` and re-read on wake. Register event listeners at the
@@ -95,7 +114,7 @@ platform fails silently when you get it wrong.
95
114
  10. **`chrome.action` needs an `"action"` key in the manifest**, even an empty
96
115
  object, or the API is undefined. And `chrome.windows` has no `query()`;
97
116
  use `getAll()`, `getCurrent()`, or `getLastFocused()`.
98
- 11. **Icons must be real files at real sizes.** Provide 16, 32, 48, 64, 128 or
117
+ 11. **Icons must be real files at real sizes.** Provide 16, 32, 48, 128 or
99
118
  omit the block entirely. The same goes for notification icons: reference a
100
119
  bundled file or a generated data URL, never a path that does not exist.
101
120
  12. **Use `async`/`await` with the promise-based APIs.** No `.then()` chains,
@@ -19,11 +19,15 @@ inactivity and restarted on the next event. Consequences:
19
19
  long-lived context is genuinely required.
20
20
  - Firefox MV2 background scripts are persistent, which can mask these bugs
21
21
  during cross-browser testing. Test state loss on Chromium specifically.
22
+ - `ReferenceError: browser is not defined` in a **production** Chrome build
23
+ (but not in dev) means the build ran without the polyfill: it defaults on
24
+ for `dev`/`start` but off for `build`. Rebuild with
25
+ `npm run build -- --polyfill` or switch the code to `chrome.*`.
22
26
 
23
27
  ## Storage
24
28
 
25
29
  - `chrome.storage.local` is the default for persistent data and works
26
- cross-browser under the polyfill.
30
+ cross-browser (Firefox supports the `chrome.*` namespace natively).
27
31
  - `chrome.storage.session` survives worker restarts but not browser restarts;
28
32
  good for tokens and ephemeral state.
29
33
  - `chrome.storage.sync` has small quotas and per-minute write limits; never
@@ -92,9 +96,12 @@ inactivity and restarted on the next event. Consequences:
92
96
 
93
97
  ## Code execution and CSP
94
98
 
95
- - MV3 forbids remote code and `eval()` in extension pages. For dynamic code,
96
- use a sandboxed iframe (`"sandbox"` manifest key), `srcdoc`, or blob URLs,
97
- and message results across the boundary.
99
+ - MV3 forbids remote code and `eval()` in extension pages, and the
100
+ extension-pages CSP (`script-src 'self'`) also blocks `blob:` script URLs
101
+ and inline scripts. `srcdoc` iframes inherit the embedding page's CSP, so
102
+ they are not an escape hatch either. The supported path for dynamic code
103
+ is a sandboxed page (`"sandbox"` manifest key), which may use `eval()`;
104
+ embed it as an iframe and message results across the boundary.
98
105
  - User-visible feedback matters for background actions: after a context menu
99
106
  click or command, confirm with a badge, notification, or toast. Silent
100
107
  success is indistinguishable from silent failure, for users and for tests.
@@ -7,7 +7,7 @@ so one source tree ships to Chrome, Edge, and Firefox.
7
7
  ## Prefix semantics
8
8
 
9
9
  These rules come from Extension.js's `filterKeysForThisBrowser` resolver
10
- (verified against Extension.js 4.0.9):
10
+ (verified against Extension.js 4.0.10):
11
11
 
12
12
  - Unprefixed fields apply to every browser.
13
13
  - `chromium:` fields apply to Chrome, Edge, and other Chromium-based browsers.
@@ -17,7 +17,9 @@ These rules come from Extension.js's `filterKeysForThisBrowser` resolver
17
17
  non-matching siblings (an `edge:` field also applies to a Chrome build), so
18
18
  write `chromium:` and `firefox:` for family-wide fields.
19
19
  - Prefixes resolve at **any nesting depth**: inside `background`, inside a
20
- `content_scripts` entry (`chromium:world`), anywhere an object key appears.
20
+ `content_scripts` entry (`firefox:world`), anywhere an object key appears.
21
+ One exception: never write `chromium:world`; see the `world: "MAIN"`
22
+ section below.
21
23
  - Precedence is deterministic and independent of declaration order:
22
24
  **plain key < family prefix < exact-browser prefix**. A non-matching
23
25
  prefixed key is dropped and the plain key survives. So
@@ -91,9 +93,17 @@ gesture handler.)
91
93
 
92
94
  ## Content scripts with `world: "MAIN"`
93
95
 
94
- Firefox only understands the manifest `world` key from 128 onward, so prefix
95
- the field: Chromium gets main-world injection and older Firefox falls back to
96
- the default isolated world instead of failing to load:
96
+ Write the `world` key **unprefixed**. Main-world content scripts need a
97
+ companion bridge script that the build inserts automatically, and that
98
+ insertion keys off the literal `world` key in the source manifest. A
99
+ `chromium:world` prefix hides the key from the bridge step and **hard-fails
100
+ the Chromium build** (the emitted manifest references bridge bundles that
101
+ were never compiled).
102
+
103
+ The build strips `world` from the bridge entry it emits, and Firefox keeps
104
+ the unprefixed key verbatim (Firefox understands manifest `world` from 128
105
+ onward). If older Firefox must stay on the isolated world, say so explicitly
106
+ with an exact-prefix override:
97
107
 
98
108
  ```json
99
109
  {
@@ -101,7 +111,8 @@ the default isolated world instead of failing to load:
101
111
  {
102
112
  "matches": ["<all_urls>"],
103
113
  "js": ["content/scripts.ts"],
104
- "chromium:world": "MAIN"
114
+ "world": "MAIN",
115
+ "firefox:world": "ISOLATED"
105
116
  }
106
117
  ]
107
118
  }
@@ -113,9 +124,18 @@ code path.
113
124
 
114
125
  ## API namespaces
115
126
 
116
- - Write `browser.*` for cross-browser code. The framework's polyfill maps it to
117
- `chrome.*` on Chromium, so promises work identically everywhere.
118
- - Use `chrome.*` only for Chromium-only surfaces (`chrome.sidePanel`,
127
+ - `browser.*` on Chromium only exists through the webextension-polyfill, and
128
+ the polyfill is applied **per command**: on by default for `dev` and
129
+ `start`, **off by default for `build`**. A `browser.*` call that worked all
130
+ through development throws (`browser is not defined`) in the production
131
+ Chrome build unless you build with `npm run build -- --polyfill`.
132
+ - `npm run start` cannot catch this: it runs its own build with the polyfill
133
+ on, so it tests a different artifact than the `npm run build --zip` you
134
+ ship. Verify the real artifact with `npm run preview` after a plain build.
135
+ - If you do not want to manage the flag, write `chrome.*` (promise-based on
136
+ Chromium MV3) and reserve `browser.*` for Firefox code paths; Firefox
137
+ ships `browser.*` natively, no polyfill involved.
138
+ - Use `chrome.*` always for Chromium-only surfaces (`chrome.sidePanel`,
119
139
  `chrome.offscreen`, `chrome.declarativeNetRequest` specifics).
120
140
  - Branch at runtime with `import.meta.env.EXTENSION_PUBLIC_BROWSER`.
121
141
 
@@ -141,9 +161,18 @@ the dist manifests will not match the source manifest verbatim:
141
161
  | --- | --- |
142
162
  | `background.chromium:service_worker: "background.ts"` | `background/service_worker.js` |
143
163
  | `background.firefox:scripts: ["background.ts"]` | `background/scripts.js` |
144
- | `content_scripts[0].js: ["content/scripts.tsx"]` | `content_scripts/content-0.js` (plus `content-0.css` when styles are imported) |
164
+ | `content_scripts[0].js: ["content/scripts.tsx"]` | `content_scripts/content-0.js` |
165
+ | `content_scripts[0].css: ["content/styles.css"]` | `content_scripts/content-0.css` |
145
166
  | `side_panel.default_path: "sidebar/index.html"` | `sidebar/index.html` |
146
167
 
168
+ Styles **imported from a content script** (`import "./styles.css"`) do not
169
+ become a sibling `.css` file: they are inlined into the JS bundle as base64
170
+ `data:text/css` and injected at runtime, and the dist manifest shows
171
+ `css: []`. Only stylesheets listed in the manifest `css` array compile to
172
+ `content_scripts/content-<index>.css`. A `world: "MAIN"` entry additionally
173
+ appends an auto-generated bridge entry (`content_scripts/content-<N>.js`
174
+ past your last index) to the dist manifest; leave it alone.
175
+
147
176
  In development builds, content script assets carry a content hash
148
177
  (`content-0.<hash>.js`) so Chrome does not serve stale cached resources after
149
178
  a live reinjection.
@@ -24,6 +24,7 @@ my-extension/
24
24
  pages/ Special folder: HTML pages not in the manifest
25
25
  scripts/ Special folder: scripts not in the manifest
26
26
  public/ Special folder: static files copied verbatim
27
+ _locales/ i18n messages at project root, NOT src/ (see below)
27
28
  extension.config.js Optional build config
28
29
  extension-env.d.ts Auto-generated types
29
30
  package.json
@@ -34,8 +35,21 @@ Manifest paths (icons, HTML, scripts) are relative to `src/`. Manifest script
34
35
  entries point at **source files** (`.ts`, `.tsx`, `.vue`, `.svelte` all
35
36
  work); the build compiles them and rewrites the dist manifest to the compiled
36
37
  output paths. Content scripts compile to canonical entries
37
- (`content_scripts/content-<index>.js`, with a sibling `.css` when the script
38
- imports styles), so never hand-reference those output names from source.
38
+ (`content_scripts/content-<index>.js`), so never hand-reference those output
39
+ names from source. Styles the script imports are **inlined into that JS
40
+ bundle** as base64 `data:text/css` (no sibling `.css` file; the dist manifest
41
+ shows `css: []`); only stylesheets listed in the manifest `css` array emit
42
+ `content_scripts/content-<index>.css`.
43
+
44
+ Two more bundling facts that surprise people:
45
+
46
+ - TypeScript entries need a `tsconfig.json` at the project root. Without it,
47
+ `.ts`/`.tsx` manifest entries do not compile as expected. Add it whenever
48
+ any entry is TypeScript, not "only if needed".
49
+ - Each content-script entry is bundled standalone: a module imported by three
50
+ entries is duplicated into all three bundles, and module-level state is
51
+ per-bundle. Share state through `chrome.storage` or the background script,
52
+ never through a shared import.
39
53
 
40
54
  ### Special folders
41
55
 
@@ -49,6 +63,29 @@ Three folders get build treatment without manifest references:
49
63
  build refuses files in `public/` that would overwrite generated assets, and
50
64
  a manifest.json inside `public/` is an error.
51
65
 
66
+ ## i18n and `_locales`
67
+
68
+ `_locales/` is the one manifest-adjacent folder that does **not** live in
69
+ `src/`: put it at the project root, next to `package.json` and `public/`.
70
+
71
+ - `<root>/_locales/<locale>/messages.json` is the canonical location.
72
+ - `src/_locales/` still builds, but emits a deprecation warning.
73
+ - `public/_locales/` **fails the build** (it collides with the generated
74
+ `_locales` output).
75
+
76
+ Wire it up as usual for WebExtensions: `"default_locale": "en"` in the
77
+ manifest, `__MSG_key__` placeholders in manifest strings, and
78
+ `chrome.i18n.getMessage("key")` in code.
79
+
80
+ ```
81
+ my-extension/
82
+ _locales/
83
+ en/messages.json
84
+ pt_BR/messages.json
85
+ src/
86
+ manifest.json "default_locale": "en"
87
+ ```
88
+
52
89
  ## File creation order
53
90
 
54
91
  Create files in dependency order so the manifest never references something
@@ -60,8 +97,8 @@ that does not exist:
60
97
  4. UI scripts mounted into those HTML files
61
98
  5. Styles imported by the scripts
62
99
  6. `package.json` with the dependencies actually used above
63
- 7. Config files (`tsconfig.json`, `postcss.config.js`, `extension.config.js`)
64
- only if needed
100
+ 7. `tsconfig.json` whenever any entry is TypeScript; other config files
101
+ (`postcss.config.js`, `extension.config.js`) only if needed
65
102
 
66
103
  ## HTML page pattern
67
104
 
@@ -30,7 +30,8 @@ Run through this before any submission; each item is a common rejection:
30
30
 
31
31
  1. Manifest version, name, description, and `version` are final and match the
32
32
  listing.
33
- 2. Icons exist as real files at 16, 32, 48, 64, 128 with correct dimensions.
33
+ 2. Icons exist as real files at 16, 32, 48, and 128 with correct dimensions
34
+ (the store listing keys on 128).
34
35
  3. Every permission in the manifest has a specific, plain-English
35
36
  justification. "Needed for the extension to work" fails review. Good shape:
36
37
  "`tabs`: reads the current tab's URL to show per-site settings."
@@ -1,7 +1,7 @@
1
1
  # Template Catalog
2
2
 
3
3
  The [examples repo](https://github.com/extension-js/examples) is a living
4
- pattern library: 60+ working extensions, each buildable and tested in CI.
4
+ pattern library: 50+ working extensions, each buildable and tested in CI.
5
5
  Treat it as the canonical answer to "how do I implement X in an extension"
6
6
  before writing anything from scratch.
7
7
 
@@ -35,8 +35,8 @@ the SPA HTML. Use the GitHub release asset or raw.githubusercontent.com.
35
35
  | Surface | Vanilla | React | Vue | Svelte | AI |
36
36
  | --- | --- | --- | --- | --- | --- |
37
37
  | Content script | `content` | `content-react` | `content-vue` | `content-svelte` | |
38
- | Sidebar | `sidebar` | `sidebar-shadcn` | | | `sidebar-claude` |
39
- | Action popup | `action` | | | | `action-chatgpt` |
38
+ | Sidebar | `sidebar` | `sidebar-shadcn` | | | `ai-claude` |
39
+ | Action popup | `action` | | | | `ai-chatgpt` |
40
40
  | New tab | `new` | `new-react` | `new-vue` | `new-svelte` | |
41
41
  | Full framework | `javascript` | `react` | `vue` | `svelte` | |
42
42
 
@@ -49,7 +49,8 @@ and `content-main-world`.
49
49
  1. Match the surface the user wants (sidebar, content script, popup, newtab).
50
50
  2. Match their framework preference.
51
51
  3. Prefer `featured: true` templates for common use cases.
52
- 4. For AI-powered extensions, start from `sidebar-claude` or `action-chatgpt`.
52
+ 4. For AI-powered extensions, start from `ai-claude` or `ai-chatgpt`
53
+ (`ai-gemini` and `ai-perplexity` cover the other providers).
53
54
 
54
55
  ## Scaffolding
55
56