← ClaudeAtlas

mv3-doctorlisted

Use when building, modifying, migrating, or reviewing a Chrome extension — anything involving manifest.json, a background service worker, content scripts, or Manifest V3. Encodes the MV3 rules that models routinely get wrong, and ships a validator to check the result.
n0liu/mv3-doctor · ★ 1 · AI & Automation · score 65
Install: claude install-skill n0liu/mv3-doctor
# Building Chrome Manifest V3 Extensions Manifest V3 broke assumptions that a decade of extension tutorials — and most training data — still take for granted. Code that looks correct, passes review by eye, and even runs during a quick manual test will fail in production because the service worker was still warm when you tested it. Follow the rules below while writing, then **run the validator before you claim the work is done.** ## The one idea that explains most MV3 bugs **The background service worker is ephemeral.** Chrome starts it to deliver an event and terminates it after roughly 30 seconds of inactivity. It is not a long-running process. Every mistake below follows from forgetting this. MV2 mental model (wrong): a background page that stays alive, holds state in memory, keeps sockets open, and runs timers. MV3 mental model (right): a collection of stateless event handlers. Each one starts from nothing, reads what it needs from storage, does its work, and may be killed the moment it goes idle. ## Rules ### 1. Never keep state in module-level variables ```js // WRONG — resets to 0 without warning when the worker restarts let requestCount = 0; chrome.runtime.onMessage.addListener(() => { requestCount += 1; }); // RIGHT — state outlives the worker chrome.runtime.onMessage.addListener(async () => { const { requestCount = 0 } = await chrome.storage.session.get("requestCount"); await chrome.storage.session.set({ requestCount: requestCount + 1 }); }); ``` `chro