Chrome Extension Manifest V3 Best Practices (2026) & Agent Skills
Manifest V3 service workers sleep between events, drop in-memory globals, and enforce strict content security policies. Use this checklist and the official Google Chrome Manifest V3 SKILL.md repo to keep coding agents off obsolete MV2 patterns.
Updated: 2026-11-21 · Works with Claude Code, Cursor, Codex, and Windsurf
Core Chrome Extensions Best Practices
Never keep durable state in background service worker globals
Manifest V3 service workers terminate after idle timeouts. Persist state in chrome.storage.session or chrome.storage.local and await writes before returning.
let activeTabs = new Map(); // wiped when SW sleepsawait chrome.storage.session.set({ activeTabs })Register all event listeners synchronously at top level
Attach chrome.runtime.onMessage, chrome.alarms, and action listeners during initial script evaluation so Chrome wakes the worker for incoming events.
init().then(() => chrome.runtime.onMessage.addListener(handler))chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => { ... return true; })Request minimal permissions and optional_host_permissions
Use activeTab instead of broad <all_urls> permissions whenever possible to speed up Chrome Web Store review and earn user trust.
"host_permissions": ["<all_urls>"] for a single-click tool"permissions": ["activeTab", "storage"]Isolate content-script UI inside a Shadow DOM root
Mount injected widgets inside a Shadow DOM so host page CSS never breaks your extension styles and your CSS never breaks the user's tab.
document.body.appendChild(unscopedDiv)const root = host.attachShadow({ mode: "open" }); // or WXT createShadowRootUiAvoid lost updates on chrome.storage read-modify-write
Serialize updates or store independent keys instead of racing read-then-write mutations across popup, options, and content scripts.
const s = await chrome.storage.local.get("all"); s.all.x = 1; await chrome.storage.local.set(s);Store per-feature keys or queue mutations through one background handlerNever inject remote executable code or inline scripts
Bundle all JavaScript inside the extension package to satisfy Manifest V3 CSP rules and pass Chrome Web Store automated security checks.
<script src="https://cdn.example.com/lib.js"></script>Bundle dependencies at build time with WXT or ViteOpen-Source Chrome Extensions Agent Skills (2)
| Skill & Publisher | Stars | Install |
|---|---|---|
Official Apache-2.0 skill from GoogleChrome/modern-web-guidance teaching coding agents Manifest V3 service worker lifecycles, least-privilege permissions, messaging, and Web Store safety. | ★ 24,407 | |
Audited MIT-licensed guide covering subtle Manifest V3 failure modes: awaiting side effects before worker teardown, preventing chrome.storage read-modify-write lost updates, and safe option validation. | ★ 117 |
Building with Chrome Extensions and an AI coding agent?
Builderthread pairs verified skills with a private GitHub starter repo, living PRD, and MCP task board for Claude Code, Cursor, and Codex.
Questions about Chrome Extensions Best Practices & Skills
Does Google Chrome publish an official Manifest V3 agent skill?
Yes. GoogleChrome/modern-web-guidance (Apache-2.0, 24,400+ stars) includes an official chrome-extensions SKILL.md covering Manifest V3 architecture, service workers, and Web Store compliance.
What breaks most AI-generated Chrome extensions?
Coding agents frequently generate obsolete Manifest V2 background pages, forget to return true from async onMessage listeners, or store state in memory globals that vanish when the MV3 service worker suspends.
Related Skill Guides
Manifest V3 starter
Ship your Chrome and Firefox extension faster
Get a private WXT Manifest V3 repo with typed messaging, synced settings, an options page, a living PRD, and ordered MCP tasks your agent checks off one by one.