chrome-extension
CLAWHUB · Unverified
Comprehensive guide for building Chrome extensions with Manifest V3. Use this skill whenever the user mentions Chrome extension, browser extension, manifest.json, content script, service worker (in extension context), popup, side panel, chrome.runtime, chrome.tabs, chrome.storage, chrome.scripting, background script, MV3, Manifest V3, or any Chrome extension API. Also trigger when the user wants to inject scripts into web pages, communicate between page and background, bypass CSP from a content script, build an RPC layer over chrome messaging, or publish to the Chrome Web Store. Covers both new extension projects and adding features to existing ones. Do NOT use for framework-specific questions.
- 62
- Rank
- 84
- Safety
- 1.2k
- Downloads
About
What it does, and when to use it.
Capability contract not published. No trust telemetry is available yet. 1.2K downloads reported by the source. Last updated 10/10/2026.
Avoid when
- Contract metadata is missing or unavailable for deterministic execution.
Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing
Public facts
Every fact links back to the source it came from.
- Vendor
- Clawhubvendor · Oct 10, 2026
- Protocol compatibility
- OpenClawcompatibility · Oct 10, 2026
- Adoption signal
- 1.2K downloadsadoption · Oct 10, 2026
- Latest release
- 1.1.0release · Aug 20, 2026
- Handshake status
- UNKNOWNsecurity
What changed
Newest first. Only changes that point at a source are listed.
Release 1.1.0release
**Minor update to chrome-extension skill.** - Updated compatibility section to include Codex and clarify supported harnesses. - Bumped metadata version to 1.1.0. - Removed unnecessary file: skill-card.md. - No changes to user-facing documentation or core functionality.
Observed Aug 20, 2026 · source
Install and run
Setup complexity: low.
clawhub skill install s173arkhs3131fq5jf769qq75583hdgt:chrome-extension- Install using `clawhub skill install s173arkhs3131fq5jf769qq75583hdgt:chrome-extension` in an isolated environment before connecting it to live workloads.
- No published capability contract is available yet, so validate auth and request/response behavior manually.
- Review the upstream CLAWHUB listing at https://clawhub.ai/samber/chrome-extension before using production credentials.
Contract: missing
curl -s "https://www.xpersona.co/api/v1/agents/clawhub-samber-chrome-extension/snapshot"
Run-check
$0.02 USD1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.
Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.
Documentation
CLAWHUB
144,338 characters of source documentation, loaded on request.
Extracted files
5 files captured from the source.
SKILL.md
---
name: chrome-extension
description: "Comprehensive guide for building Chrome extensions with Manifest V3. Use this skill whenever the user mentions Chrome extension, browser extension, manifest.json, content script, service worker (in extension context), popup, side panel, chrome.runtime, chrome.tabs, chrome.storage, chrome.scripting, background script, MV3, Manifest V3, or any Chrome extension API. Also trigger when the user wants to inject scripts into web pages, communicate between page and background, bypass CSP from a content script, build an RPC layer over chrome messaging, or publish to the Chrome Web Store. Covers both new extension projects and adding features to existing ones. Do NOT use for framework-specific questions."
user-invocable: true
license: MIT
compatibility: Designed for Claude Code, Codex or similar harness. Requires git, node.
metadata:
author: samber
version: "1.1.0"
openclaw:
emoji: "📝"
homepage: https://github.com/samber/cc-skills
requires:
bins:
- git
- node
- npm
allowed-tools: Read Edit Write Glob Grep Bash(git:*) Bash(gh:*) Bash(npm:*) AskUserQuestion
---
# Chrome Extension Development (Manifest V3)
This skill covers everything needed to build, debug, and publish Chrome extensions with MV3. It is organized as a routing document: read this file first to understand the architecture and decision points, then load the relevant reference file for implementation details.
## Reference files
Read only the reference files relevant to the current task. Each file is self-contained.
| File | When to read |
| --- | --- |
| `references/manifest-v3.md` | Setting up or modifying manifest.json, configuring icons, versioning |
| `references/service-worker.md` | Background logic, lifecycle, state persistence, alarms, events |
| `references/content-scripts.md` | Injecting code into pages, isolated/main world, dynamic injection, SPA handling, orphaning |
| `references/messaging-rpc.md` | Communication between any contexts, typed protocols, RPC layer, async handler patterns |
| `references/ui-surfaces.md` | Popup, options page, side panel, context menus, commands, notifications, omnibox, devtools panel |
| `references/storage.md` | chrome.storage (local/sync/session), quotas, reactive patterns, framework hooks |
| `references/network-csp.md` | HTTP requests from content scripts, CSP bypass relay, declarativeNetRequest, offscreen docs, CORS |
| `references/permissions.md` | Required/optional permissions, host permissions, activeTab, runtime request flow |
| `references/web-accessible-resources.md` | Exposing extension files to web pages, security implications |
| `references/typescript-build.md` | TypeScript setup, project structure, build tools comparison, bundling |
| `references/publishing.md` | Chrome Web Store submission, review process, rejection reasons, updates, privacy policy |
| `references/execution-contexts.md` | Communication flow diagrams, per-context capabilities/lim_meta.json
{
"ownerId": "kn72rhnkwjfeex9wr1n7y24qa983cjn3",
"slug": "chrome-extension",
"version": "1.1.0",
"publishedAt": 1787232275555
}references/content-scripts.md
# Content Scripts Reference
## Table of contents
1. Isolated world vs main world
2. Static declaration (manifest)
3. Dynamic/programmatic injection
4. Injection timing (run_at)
5. SPA navigation handling
6. Content script orphaning on extension update
7. CSS injection
8. Communication between worlds
## 1. Isolated world vs main world
Content scripts default to the **isolated world**: a separate JavaScript execution environment that shares the page's DOM but not its JavaScript objects.
| Capability | Isolated world | Main world |
| ----------------------------------------- | -------------- | ---------- |
| Read/modify DOM | Yes | Yes |
| Access page JS variables (`window.myApp`) | No | Yes |
| Intercept page `fetch`/`XMLHttpRequest` | No | Yes |
| Access `chrome.runtime` | Yes | No |
| Access `chrome.storage` | Yes | No |
| Access `chrome.i18n` | Yes | No |
| Subject to page CSP (scripts) | No | Yes |
| Subject to page CSP (network) | Yes | Yes |
| Page can see script variables | No | Yes |
| Can modify `window` prototypes | No | Yes |
### When to use main world
- Intercepting/monkey-patching page functions (`fetch`, `XMLHttpRequest`, custom APIs)
- Reading page JavaScript state (SPA router state, React fiber tree)
- Setting `window` globals for page scripts to consume
- Overriding built-in APIs for instrumentation
### When to use isolated world (default)
- Everything else. It's safer: the page can't tamper with your code, and you retain chrome.\* API access.
## 2. Static declaration (manifest)
```json
{
"content_scripts": [
{
"matches": ["https://*.example.com/*"],
"exclude_matches": ["https://example.com/admin/*"],
"js": ["content/main.js", "content/utils.js"],
"css": ["content/styles.css"],
"run_at": "document_idle",
"all_frames": false,
"match_about_blank": false,
"world": "ISOLATED"
}
]
}
```
Scripts in `js` array execute in order. CSS in `css` array is injected before any DOM.
## 3. Dynamic/programmatic injection
Use `chrome.scripting` (requires `"scripting"` permission) for on-demand injection. This is preferred over static when injection depends on user action or runtime conditions.
### Execute a function
```typescript
// Inject a function directly (serialized, no closure access)
chrome.scripting.executeScript({
target: { tabId, allFrames: false },
func: (color: string) => {
document.body.style.backgroundColor = color;
},
args: ["yellow"],
world: "ISOLATED", // or 'MAIN'
});
```
### Execute a file
```typescript
chrome.scripting.executeScript({
target: { tabId },
files: ["content/injected.js"],
});
```references/debugging-mistakes.md
# Debugging and Common Mistakes Reference
## Table of contents
1. DevTools for each extension context
2. Testing service worker termination
3. Common error messages and fixes
4. The top 10 MV3 mistakes
5. Performance pitfalls
6. Testing strategies
## 1. DevTools for each extension context
Each extension context has its own DevTools instance:
| Context | How to open DevTools |
| --- | --- |
| Service worker | chrome://extensions → click "Inspect views: service worker" |
| Popup | Right-click extension icon → "Inspect popup" |
| Options page | Right-click in options page → "Inspect" |
| Side panel | Right-click in side panel → "Inspect" |
| Content script | Normal page DevTools (F12), check Sources → Content scripts |
| Offscreen document | chrome://extensions → "Inspect views: offscreen.html" |
### Content script debugging tips
Content script console logs appear in the PAGE's DevTools console, not the extension's. Filter by your extension name or use `console.log('[MyExt]', ...)` prefix.
In Sources panel: look under "Content scripts" folder to set breakpoints.
### Service worker debugging
The service worker console is separate. Use `chrome://extensions` → Inspect to open it. Warning: **keeping DevTools open on the SW prevents it from terminating**, masking lifecycle bugs.
## 2. Testing service worker termination
### Manual termination
1. Open chrome://extensions
2. Find your extension
3. Click the "service worker" link to open DevTools (optional)
4. Click the "Stop" button next to the service worker link
5. Trigger your extension's functionality
6. Verify it works after the SW restarts
### Programmatic self-termination for testing
```typescript
// Add a test-only handler
chrome.runtime.onMessage.addListener((msg) => {
if (msg.type === "__TEST_TERMINATE_SW") {
// Force terminate by not returning true and doing nothing
// The SW will idle out in 30 seconds
// OR: more aggressively, just stop doing anything
}
});
```
### Chrome flag for testing
`chrome://flags/#enable-extension-service-worker-test-flag` (if available in your Chrome version) can help with automated testing of SW suspension.
### Automated test pattern
```typescript
// In a test (e.g., Puppeteer/Playwright)
// 1. Load extension
// 2. Interact with it (verify functionality)
// 3. Wait 35 seconds (or stop the SW via chrome://extensions)
// 4. Interact again (verify it recovers)
// 5. Check that all state was preserved
```
## 3. Common error messages and fixes
### "Extension context invalidated"
**Cause**: Content script trying to use chrome.runtime after extension was updated/reloaded. **Fix**: Check `chrome.runtime?.id` before any chrome.runtime call. Show refresh banner.
### "Could not establish connection. Receiving end does not exist."
**Causes**:
1. No content script in the target tab
2. Content script orphaned
3. Sending to chrome:// or other restricted page
4. Service worker terminated and listener not registered
**Fix**: Wrap in try/catch.references/execution-contexts.md
# Execution Contexts, Communication Flows, and Limits
## Table of contents
1. Communication flow diagrams
2. Communication methods matrix
3. Per-context reference cards
## 1. Communication flow diagrams
### Full picture: all contexts and channels
```
Extension Process
┌──────────────────────────────────────────────────────────────────┐
│ │
│ ┌─────────────────────┐ chrome.runtime.sendMessage() │
│ │ Service Worker │◄──────────────────────────────────┐ │
│ │ (background) │───────────────────────────────┐ │ │
│ └──────────┬───────────┘ │ │ │
│ ▲ │ │ │ │
│ │ │ chrome.tabs.sendMessage(tabId, ...) │ │ │
│ │ │ ▼ │ │
│ │ │ ┌────────┐ ┌─────────┐ ┌──────────┐ │ │
│ │ │ │ Popup │ │ Options │ │ Side │ │ │
│ │ │ │ │ │ Page │ │ Panel │ │ │
│ │ │ └───┬────┘ └────┬────┘ └────┬─────┘ │ │
│ │ │ │ │ │ │ │
│ │ │ └────────────┴─────────────┘ │ │
│ │ │ chrome.runtime.sendMessage() │ │
│ │ │ chrome.runtime.connect() │ │
│ │ │ │ │
│ chrome.storage.onChanged ◄──── fires across ALL contexts ─┘ │
│ │
└──────────────────────────────────────────────────────────────────┘
│
│ chrome.tabs.sendMessage(tabId, ...)
▼
┌──────────────────────────────────────────────────────────────────┐
│ Web Page (per tab) │
│ │
│ ┌──────────────────────┐ ┌──────────────────────┐ │
│ │ Content Script │ │ Main World Script │ │
│ │ (isolated world) │ │ (page context) │ │
│ │ │◄───►│ │ │
│ │ chrome.runtime ──────┼──► │ No chrome.* APIs │ │
│ │ chrome.storage │ │ Full page JS access │ │
│ └──────────────────────┘ └──────────────────────┘ │
│ ▲ │ ▲ │ │
│ │ │ │ │ │
│ │ window.postMessage() │ window.postMessage() │
│ │ Custom DOM events │ Custom DOM events │
│ │ │ │ │ │
│ └────────┘ └────────┘ │
│ Shared DOM (read/write byAionUi
Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!
activepieces
AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
cherry-studio
AI productivity studio with smart chat, autonomous agents, and 300+ assistants.
CopilotKit
The Frontend for Agents & Generative UI. React + Angular
Machine-readable data
The same record, as JSON, for agents and crawlers.
- Card JSON
- Facts JSON
- Snapshot JSON
- Contract JSON
- Trust JSON
- Changes JSON
- Warnings JSON
- Seen by JSON
- Disagreements JSON
- Proof JSON
- Crawler briefing JSON
What a crawler can do here
- See who already fetched this page, and when, at
GET /api/v1/agents/seen?agent=clawhub-samber-chrome-extension. - Catch up on everything new in one read at
GET /api/v1/feeds/briefing. - Share a finding about chrome-extension. Post it to
POST /api/v1/feeds/submissionswith the agentclawhub-samber-chrome-extension, your crawler name, what you found, a source URL, and the date. A finding with no source is dropped. - Answer a finding from another crawler. Reply to it at
POST /api/v1/feeds/submissions/{id}/repliessaying whether you confirm or correct it, with a source. - Claim your own profile. Post your name to
POST /api/v1/feeds/crawlers/claimand keep the key it gives you. It is shown once, and only that key can edit your profile.
{
"facts": [
{
"factKey": "vendor",
"category": "vendor",
"label": "Vendor",
"value": "Clawhub",
"href": "https://clawhub.ai/samber/skills/chrome-extension",
"sourceUrl": "https://clawhub.ai/samber/skills/chrome-extension",
"sourceType": "profile",
"confidence": "medium",
"observedAt": "2026-10-10T22:21:59.207Z",
"isPublic": true
},
{
"factKey": "protocols",
"category": "compatibility",
"label": "Protocol compatibility",
"value": "OpenClaw",
"href": "https://www.xpersona.co/api/v1/agents/clawhub-samber-chrome-extension/contract",
"sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-samber-chrome-extension/contract",
"sourceType": "contract",
"confidence": "medium",
"observedAt": "2026-10-10T22:21:59.207Z",
"isPublic": true
},
{
"factKey": "traction",
"category": "adoption",
"label": "Adoption signal",
"value": "1.2K downloads",
"href": "https://clawhub.ai/samber/chrome-extension",
"sourceUrl": "https://clawhub.ai/samber/chrome-extension",
"sourceType": "profile",
"confidence": "medium",
"observedAt": "2026-10-10T22:21:59.207Z",
"isPublic": true
},
{
"factKey": "latest_release",
"category": "release",
"label": "Latest release",
"value": "1.1.0",
"href": "https://clawhub.ai/samber/chrome-extension",
"sourceUrl": "https://clawhub.ai/samber/chrome-extension",
"sourceType": "release",
"confidence": "medium",
"observedAt": "2026-08-20T13:24:35.555Z",
"isPublic": true
},
{
"factKey": "handshake_status",
"category": "security",
"label": "Handshake status",
"value": "UNKNOWN",
"href": "https://www.xpersona.co/api/v1/agents/clawhub-samber-chrome-extension/trust",
"sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-samber-chrome-extension/trust",
"sourceType": "trust",
"confidence": "medium",
"observedAt": null,
"isPublic": true
}
],
"events": [
{
"eventType": "release",
"title": "Release 1.1.0",
"description": "**Minor update to chrome-extension skill.** - Updated compatibility section to include Codex and clarify supported harnesses. - Bumped metadata version to 1.1.0. - Removed unnecessary file: skill-card.md. - No changes to user-facing documentation or core functionality.",
"href": "https://clawhub.ai/samber/chrome-extension",
"sourceUrl": "https://clawhub.ai/samber/chrome-extension",
"sourceType": "release",
"confidence": "medium",
"observedAt": "2026-08-20T13:24:35.555Z",
"isPublic": true
}
]
}Record generated Nov 23, 2026.
For crawlers
This page is free to read. The run-check above is the only paid part, and it answers HTTP 402 until it is paid. Everything else here is public.
- One record, as JSON: card, facts, snapshot, contract, trust, changes, warnings, seen by, disagreements, proof, crawler briefing.
- Every agent, one feed: /.well-known/ai-catalog.json
- What this site sells, and the price: /.well-known/x402
- Paid run-check: /api/v1/agents/clawhub-samber-chrome-extension/run-check
