kmaruthi2002/universal-llm-skills/browser-extension-development
Claude Code and agent skill by kmaruthi2002/universal-llm-skills
- community
- ext:[{"type":"plugin","description":"Custom plugin integration"}]
Checking that the SKILL.md file is still in the repository.
Design, build, test and publish browser extensions (Chrome, Edge, Firefox, Safari and other WebExtensions-based browsers): manifest and permissions, background service workers, content scripts, popups, side panels and options pages, message passing, storage, cross-browser differences, store review and extension security. Use when someone asks to make a browser extension, add-on or plugin, a Chrome/Firefox extension, a content script that modifies pages, a toolbar popup, migrate to Manifest V3, fix an extension that stopped working, or get an extension through store review.
Install
npx vskill@latest install kmaruthi2002/universal-llm-skills/browser-extension-developmentSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as kmaruthi2002/universal-llm-skills/browser-extension-development.
Browser Extension Development
A browser extension is a small distributed system that lives inside someone else's application. It has several isolated execution contexts that cannot share memory, a background process the browser may kill at any moment, code injected into pages it does not control, and a permission model that users and store reviewers scrutinise. Most extension bugs come from forgetting one of those facts. This skill is about building extensions that work reliably across those boundaries, ask for as little power as possible, and pass review.
Scope
Covers: WebExtensions-style extensions (the shared model used by Chromium browsers, Firefox and, with adaptations, Safari), Manifest V3 as the current baseline, architecture, messaging, storage, permissions, cross-browser packaging, testing, store submission and security.
Does not cover: the UI design of the popup itself (see interaction-design, ui-design-fundamentals), general frontend framework practice (frontend-development), automating a browser from outside (browser-automation), or extracting data from sites at scale (web-scraping — and note that an extension scraping on the user's behalf still inherits that skill's legal and ethical concerns).
Core principles
- Each context is a separate program. The background worker, each content script instance, the popup, the options page and any extension pages run in different JavaScript realms. They communicate only by messages and shared storage. Design the extension as cooperating processes with an explicit protocol, not as one app with globals. Why: a global set in the popup is gone when the popup closes; a variable in the service worker is gone when it is suspended.
- The background is ephemeral. In Manifest V3 the background is a service worker (an event page in some Firefox configurations) that the browser terminates after a short idle period and restarts on the next event. Any in-memory state can vanish between two events. Persist state you need in
storage, register listeners synchronously at the top level, and treat each event handler as if it were a fresh start. Why: listeners registered asynchronously (after anawait) may not be attached when the browser wakes the worker to deliver an event, so the event is silently dropped.
- Least privilege is a feature, not a chore. Every permission broadens what an attacker gets if your extension or its dependencies are compromised, increases install-time warnings (which cut install rates), and lengthens review. Prefer
activeTaband optional permissions requested at the moment of need over blanket host access. Why: users and reviewers read "Read and change all your data on all websites" as a red flag, correctly.
- Pages are hostile territory. Content scripts run alongside arbitrary page code. The page can read and alter the DOM you inject into, spoof events, and send you crafted messages via
window.postMessage. Never trust data from the page, never pass privileged capabilities into it, and validate every message's sender.
- The store is part of the runtime. Store policies (single purpose, data disclosure, remote code bans, permission justification) constrain architecture. Discover them before designing, not after rejection. Why: "load logic from my server" is a reasonable web pattern and a review failure for extensions.
- The browser APIs are the platform; frameworks are optional. Many good extensions are a few hundred lines of plain scripts. Reach for a bundler or UI framework when the popup or options UI is genuinely complex or the team already uses one — not by default.
Architecture: the parts and what each is for
| Part | Lives | Can do | Cannot do | Use it for | |
|---|---|---|---|---|---|
| Manifest | manifest.json | Declares everything: permissions, entry points, icons, matches, CSP | Run code | The contract with the browser and the store | |
| Background service worker | One per extension, ephemeral | Most chrome.*/browser.* APIs, network, alarms, context menus, cross-tab coordination | Touch the DOM; hold state across suspension; use window | Central coordinator, event handling, API calls, privileged work | |
| Content scripts | Injected into matching pages, one instance per frame | Read/modify page DOM, a limited subset of extension APIs (messaging, storage, i18n) | Access page JS variables directly (isolated world); call most privileged APIs | Reading or changing pages | |
| Popup | Opens from toolbar action; destroyed when closed | Full extension APIs, DOM of its own page | Persist anything in memory after closing | Quick interactions, status, toggles | |
| Side panel / sidebar | Persistent panel (browser-dependent) | Like an extension page, survives navigation | Exist on every browser in the same form | Long-lived tools alongside browsing | |
| Options page | Extension page | Full extension APIs | — | Settings that change rarely | |
| Offscreen document (Chromium) | Hidden extension page created on demand | DOM APIs (audio, clipboard, DOM parsing) the worker lacks | Be permanent; be used for arbitrary reasons | Work that needs a DOM but not a visible page | |
| Injected page-world script | Page's own JS realm | See and patch page variables | Use extension APIs; be trusted | Only when you must interact with page JS — minimise it |
Isolated vs main world. Content scripts run in an isolated world: they share the DOM with the page but not the JavaScript globals. If you need to read a page variable or hook a page function, you must inject into the main world (via scripting.executeScript with a world option where supported, or a <script> element), and that code has no extension privileges and is visible to the page. Bridge the two with DOM events or postMessage, and validate on the isolated side.
Process
1. Pin down the job and the minimum capability
Before writing a manifest, write one sentence: "When the user does X on Y pages, the extension does Z." Then derive the minimum capability:
- Which pages? All sites, a known list of domains, or only the page the user is on when they click? "Only when clicked" means
activeTaband no host permissions. - Triggered how? Toolbar click, context menu, keyboard command, page load, a schedule? Page-load triggers require declared content scripts or host permissions; user-gesture triggers can often use
activeTab. - What data leaves the browser? None, to your server, to a third party? This decides privacy disclosures and possibly the whole design.
- Which browsers? Chromium only, plus Firefox, plus Safari? Safari requires an Xcode/macOS packaging step and a developer account; confirm before promising it.
Ask the user when these are unclear — they change the permission set, which changes the warning users see.
2. Discover context
If extending an existing extension:
- Read
manifest.jsonfirst: manifest version, permissions, host permissions, content script matches, background type, CSP,browser_specific_settings. - Find the build: is the manifest generated (by a bundler plugin or framework) or hand-written? Edit the source of truth, not the build output.
- Identify the message protocol already in use (message
typenames, a router, a typed schema) and extend it rather than adding a parallel one. - Check storage keys and any migration logic; changing a key shape without migration breaks existing users.
- Look for a polyfill or wrapper (
browsernamespace polyfill, a project-specific API wrapper) and use it consistently.
3. Choose the shape
Decide the minimum set of contexts. Common shapes:
- Action-only: popup +
activeTab+scripting.executeScripton click. No background at all, or a trivial one. Smallest permission footprint; great for "do something to this page". - Page enhancer: declared content scripts on specific matches, little or no background. Good for "always tweak site X".
- Coordinator: background worker owns state, network and API calls; content scripts and UI are thin clients that message it. Good when multiple tabs share state or when calls need credentials.
- Request modifier: declarative network rules (
declarativeNetRequestin Chromium MV3; Firefox also retains blockingwebRequest). Prefer declarative rules — they are faster, need fewer permissions and are what MV3 expects.
4. Write the manifest deliberately
- Start from the smallest permission set and add only with a stated reason. Keep a short note (in the repo or PR) of why each permission exists — reviewers ask, and future you will forget.
- Put rarely needed permissions in
optional_permissions/optional_host_permissionsand request them from a user gesture when the feature is first used. - Scope content script
matchesas narrowly as the job allows.<all_urls>is a decision to defend, not a default. - Set
run_atintentionally:document_idle(default, safest),document_end, ordocument_start(only when you must act before page scripts, and then expect a partially built DOM). - Consider
all_framesexplicitly: iframes are where many "works on some pages" bugs live. - Declare
web_accessible_resourcesonly for resources pages genuinely need, withmatchesrestricted; these resources let sites fingerprint that your extension is installed. - Do not loosen the extension CSP to allow remote scripts or
eval; MV3 forbids remote code and stores reject it.
5. Design the message protocol
Treat messages like a small API:
- Every message has a
type(or equivalent discriminator) and a payload with a known shape. Validate shape on receipt. - Decide request/response vs fire-and-forget per message. For responses, either return a Promise from the listener (where the browser supports it) or call
sendResponseand returntrueto keep the channel open. Mixing these is a classic source ofundefinedresponses. - Check
sender: for messages from content scripts,sender.tabandsender.url/origintell you which page asked. For external messages (externally_connectable), allow-list origins and extension IDs. - Use long-lived ports (
runtime.connect) for streams or chatty exchanges; use one-off messages otherwise. Ports also keep a worker alive while open in some browsers, which is useful and also a way to accidentally burn resources. - Handle "receiving end does not exist": the content script may not be injected yet (tab loaded before install, restricted page, wrong frame). Catch this, and inject on demand if appropriate.
6. Design storage
| Store | Scope | Survives | Typical use | Watch out for | |
|---|---|---|---|---|---|
storage.local | Device | Restarts, worker suspension | Caches, larger data, state | Quotas (generous but finite; unlimitedStorage if justified) | |
storage.sync | User's signed-in browsers | Across devices | Small preferences | Tight per-item and total quotas, write-rate limits; never secrets | |
storage.session | Browser session, memory-backed | Worker suspension, not restart | Ephemeral state the worker needs between events, tokens you do not want on disk | Not exposed to content scripts by default; small quota | |
storage.managed | Set by enterprise policy | — | Admin-configured settings | Read-only | |
| IndexedDB (extension origin) | Device | Restarts | Large structured data | Not reachable from content scripts' extension origin directly — go via messages | |
localStorage | Extension page origin | Restarts | Avoid | Unavailable in service workers; synchronous |
Rules: version your stored schema (schemaVersion key) and migrate on runtime.onInstalled with reason update. Use storage.onChanged to keep UIs in sync instead of polling. Batch writes; storage.sync especially throttles.
7. Build the background for suspension
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/browser-extension-development/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Extension points
pluginCustom plugin integration
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/kmaruthi2002/universal-llm-skills/browser-extension-development)