{"name":"build-chrome-extension","description":"Builds a Manifest V3 browser extension in JavaScript or TypeScript - manifest, service worker, content script, popup, message passing and storage, with the smallest permission set. Use when the user wants a Chrome extension, a browser add-on, or a popup that talks to a content script.","category":"frontend","tags":["extension","typescript"],"models":["any"],"proven":false,"passing_families":0,"model_testing":"Not yet model-tested; testing Jan 2027","url":"https://theskillvault.ai/skills/build-chrome-extension","api_url":"https://theskillvault.ai/api/skills/build-chrome-extension","raw_url":"https://theskillvault.ai/api/skills/build-chrome-extension/raw","body":"# Build a browser extension\n\nA Manifest V3 extension is a small package. It has a manifest, a service worker, optional content scripts and a popup.\n\n## When to use\n- You want a Chrome or Chromium extension with a toolbar popup.\n- A page needs a content script that messages the extension.\n- You are moving an old Manifest V2 extension to V3.\n\n## When not to use\n- You want to inspect a page you did not write. Use debug-with-chrome-devtools.\n- You want an automated test of a website. Use test-web-app-with-playwright.\n\n## Steps\n1. Start with `manifest.json`. Set `manifest_version` to 3 and name the extension.\n2. Put background work in a service worker (`background.service_worker`). It wakes for events. It does not stay running.\n3. Add a popup (`action.default_popup`) for the toolbar UI. Keep that page small.\n4. Add a content script only for the sites that need it. List those hosts in `matches`. Do not use `<all_urls>` unless you must.\n5. Ask for the smallest permissions. Prefer optional permissions for anything you can request later.\n6. Pass messages with `chrome.runtime.sendMessage`. Give each message a TypeScript interface.\n7. Store settings with `chrome.storage`. Do not put passwords or tokens in the package.\n8. Schedule work with `chrome.alarms`, not `setInterval`. The worker can stop at any time.\n9. Load the unpacked folder from the browser extensions page. When a message fails, read the worker error.\n\n```ts\ntype SaveNote = { type: \"save-note\"; text: string };\n\nchrome.runtime.onMessage.addListener((message: SaveNote, _sender, sendResponse) => {\n  if (message.type !== \"save-note\") return;\n  chrome.storage.local.set({ note: message.text }).then(() => sendResponse({ ok: true }));\n  return true;\n});\n```\n\n## Gotchas\n- Manifest V2 background pages are gone. A timer in the worker will not keep running.\n- A content script does not share the page's JavaScript world. Pass data with messages.\n- A wide host pattern will scare users and the store review. Narrow `matches`.\n- Set a content security policy. Load scripts from the package. Do not run remote code. Use HTTPS for network calls.\n- Treat page text and user input as untrusted. Escape anything you insert into the page.\n- Never ship an API key or a password inside the extension folder.\n\n## Portability\nThe same package works in Chrome and other Chromium browsers. Firefox and Safari speak the WebExtensions API, with small differences. If you are using another browser, check that your calls exist on both `chrome` and `browser`. This is not a desktop editor app.\n\n## Example prompt\n\"Build a Manifest V3 Chrome extension with a popup that saves a note and a content script that reads the page title.\"\n\n## Done when\n- The manifest is version 3 and lists only the permissions you use.\n- The popup, the worker and the content script pass typed messages.\n- No secret is stored in the package, and the unpacked extension loads.\n\n---\nBased on the Chrome extension JavaScript and TypeScript rules file in PatrickJS/awesome-cursorrules (CC0 1.0, public domain). See LICENSE.txt.","files":["LICENSE.txt"],"license":"CC0-1.0","license_name":"CC0 1.0","license_url":"https://creativecommons.org/publicdomain/zero/1.0/","attribution":"Based on work by awesome-cursorrules contributors (chrome-extension-dev rules) (Public domain (CC0 1.0) - rules contributed to PatrickJS/awesome-cursorrules, CC0 1.0), https://github.com/PatrickJS/awesome-cursorrules/blob/b044f956f021b6e8877f16781bcfc466a6a120e9/rules/chrome-extension-dev-js-typescript-cursorrules-pro.mdc; adapted by TheSkillVault, https://theskillvault.ai","install":{"claude_code":"curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-chrome-extension/raw' -o ~/'.claude/skills/build-chrome-extension/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-chrome-extension/files/LICENSE.txt' -o ~/'.claude/skills/build-chrome-extension/LICENSE.txt'","cursor":"curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-chrome-extension/raw' -o '.cursor/skills/build-chrome-extension/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-chrome-extension/files/LICENSE.txt' -o '.cursor/skills/build-chrome-extension/LICENSE.txt'","agents":"curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-chrome-extension/raw' -o '.agents/skills/build-chrome-extension/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-chrome-extension/files/LICENSE.txt' -o '.agents/skills/build-chrome-extension/LICENSE.txt'","mcp_url":"https://theskillvault.ai/mcp","cursor_mcp_deeplink":"cursor://anysphere.cursor-deeplink/mcp/install?name=theskillvault&config=eyJ1cmwiOiJodHRwczovL3RoZXNraWxsdmF1bHQuYWkvbWNwIn0%3D","mcp_config":{"mcpServers":{"theskillvault":{"url":"https://theskillvault.ai/mcp"}}}},"bundles":[],"tested_on":[{"family":"chatgpt","name":"ChatGPT","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"claude","name":"Claude","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"gemini","name":"Gemini","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"grok","name":"Grok","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"llama","name":"Llama","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"deepseek","name":"DeepSeek","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"mistral","name":"Mistral","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"qwen","name":"Qwen","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"kimi","name":"Kimi K","outcome":null,"date":null,"source":null,"counts":false,"stale":false}],"proven_rule":{"threshold":5,"window_days":365,"computed_at":"2026-11-29T03:42:30.374Z"}}