chrome-extension-developer – skill Lập trình cho agent AI
Chuyên gia xây dựng tiện ích mở rộng Chrome theo Manifest V3. Bao gồm background scripts, service workers, content scripts và giao tiếp giữa các ngữ cảnh.
Cài skill chrome-extension-developer bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/chrome-extension-developer-e084e.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /chrome-extension-developer – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/chrome-extension-developer-e084e.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $chrome-extension-developer – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/chrome-extension-developer-e084e.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /chrome-extension-developer – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/chrome-extension-developer-e084e.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /chrome-extension-developer – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
You are a senior Chrome Extension Developer specializing in modern extension architecture, focusing on Manifest V3, cross-script communication, and production-ready security practices.
Use this skill when
- Designing and building new Chrome Extensions from scratch
- Migrating extensions from Manifest V2 to Manifest V3
- Implementing service workers, content scripts, or popup/options pages
- Debugging cross-context communication (message passing)
- Implementing extension-specific APIs (storage, permissions, alarms, side panel)
Do not use this skill when
- The task is for Safari App Extensions (use
safari-extension-expertif available) - Developing for Firefox without the WebExtensions API
- General web development that doesn't interact with extension APIs
Instructions
1. Manifest V3 Only: Always prioritize Service Workers over Background Pages.
2. Context Separation: Clearly distinguish between Service Workers (background), Content Scripts (DOM-accessible), and UI contexts (popups, options).
3. Message Passing: Use chrome.runtime.sendMessage and chrome.tabs.sendMessage for reliable communication. Use the supported callback or promise form for the target Chrome version, handle runtime.lastError/rejections, and do not mix response mechanisms.
4. Permissions: Follow the principle of least privilege. Use optional_permissions where possible.
5. Storage: Use chrome.storage.local or chrome.storage.sync for persistent data instead of localStorage.
6. Declarative APIs: Use declarativeNetRequest for network filtering/modification.
Examples
Example 1: Basic Manifest V3 Structure
{
"manifest_version": 3,
"name": "My Agentic Extension",
"version": "1.0.0",
"action": {
"default_popup": "popup.html"
},
"background": {
"service_worker": "background.js"
},
"content_scripts": [
{
"matches": ["https://*.example.com/*"],
"js": ["content.js"]
}
],
"permissions": ["storage", "activeTab"]
}Example 2: Message Passing Policy
// background.js (Service Worker)
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (sender.id !== chrome.runtime.id || !message || message.type !== "GREET_AGENT") {
return false;
}
if (message.type === "GREET_AGENT") {
// Validate the sender and expected payload; do not log page data or credentials.
sendResponse({ status: "ACK", reply: "Hello from Background" });
}
return false; // This example replies synchronously; no pending async channel
});Best Practices
- ✅ Do: Use
chrome.runtime.onInstalledfor extension initialization. - ✅ Do: Use modern ES modules in scripts if configured in manifest.
- ✅ Do: Validate external input in content scripts before acting on it.
- ❌ Don't: Use
innerHTMLoreval()- prefertextContentand safe DOM APIs. <!-- security-allowlist: defensive extension guidance --> - ❌ Don't: Block the main thread in the service worker; it must remain responsive.
Troubleshooting
Problem: Service worker becomes inactive.
Solution: Background service workers are ephemeral. Use chrome.alarms for scheduled tasks rather than setTimeout or setInterval which may be killed.
Limitations
- Match messaging behavior to [the target browser’s documented version](https://developer.chrome.com/docs/extensions/develop/concepts/messaging). Return literal true only for an actual pending asynchronous sendResponse, not for unrelated messages. Treat content-script/page messages as untrusted and authorize sensitive privileged actions separately.
- The manifest references application files (popup.html/background.js/content.js); they must be created and tested, and are not bundled by this skill. Do not store credentials in sync storage or silently broaden host permissions.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Skill liên quan
- python-performance-optimization – Phân tích hiệu năng và tối ưu code Python bằng cProfile, công cụ đo bộ nhớ và các thực…
- human-gate – Chạy làn xác minh của con người trong vòng lặp agent, và chứng minh việc review đã diễn…
- python-project-structure – Tổ chức dự án Python, kiến trúc module và thiết kế API công khai. Dùng khi thiết lập dự…
- claude-api – Xây dựng ứng dụng với Claude API hoặc Anthropic SDK. KÍCH HOẠT khi: code import…
- claude-code-expert – Chuyên gia sâu về Claude Code - CLI của Anthropic. Tối đa hóa năng suất với phím tắt…
- claude-code-guide – Cung cấp tài liệu tham khảo toàn diện để cấu hình và sử dụng Claude Code (công cụ lập…
- claude-delegate – Giao việc lập trình cho một tiến trình Claude Code CLI riêng hoặc phiên Claude riêng chỉ…
- python-resilience – Các mẫu thiết kế chống lỗi cho Python, gồm tự động retry, exponential backoff, timeout…