chrome-extension by pproenca/dot-skills
npx skills add https://github.com/pproenca/dot-skills --skill chrome-extension面向 Chrome 扩展(Manifest V3)的全面性能和代码质量指南。包含 12 个类别下的 67 条规则,按影响程度排序,以指导自动化重构和代码生成。
在以下情况下参考这些指南:
| 优先级 | 类别 | 影响程度 | 前缀 |
|---|---|---|---|
| 1 | Service Worker 生命周期 | 关键 | sw- |
| 2 | 内容脚本优化 | 关键 | content- |
| 3 | 消息传递效率 | 高 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
msg-| 4 | 存储操作 | 高 | storage- |
| 5 | 网络与权限 | 中高 | net- |
| 6 | 内存管理 | 中 | mem- |
| 7 | UI 性能 | 中 | ui- |
| 8 | API 使用模式 | 低中 | api- |
| 9 | 代码风格与命名 | 中 | style- |
| 10 | 组件模式 | 中 | comp- |
| 11 | 错误处理 | 高 | err- |
| 12 | 测试模式 | 中 | test- |
sw-persist-state-storage - 使用 chrome.storage 持久化状态,而非全局变量sw-avoid-keepalive - 避免人为的 Service Worker 保活模式sw-use-alarms-api - 使用 chrome.alarms 替代 setTimeout/setIntervalsw-return-true-async - 从消息监听器返回 true 以支持异步响应sw-register-listeners-toplevel - 在顶层注册事件监听器sw-use-offscreen-for-dom - 使用离屏文档处理 DOM APIcontent-use-specific-matches - 使用特定的 URL 匹配模式content-use-document-idle - 使用 document_idle 注入内容脚本content-programmatic-injection - 优先使用编程式注入而非清单声明content-minimize-script-size - 最小化内容脚本包大小content-batch-dom-operations - 批量处理 DOM 操作以减少重排content-use-mutation-observer - 使用 MutationObserver 替代轮询msg-use-ports-for-frequent - 为频繁的消息交换使用端口连接msg-minimize-payload-size - 最小化消息负载大小msg-debounce-frequent-events - 在消息传递前对高频事件进行防抖处理msg-check-lasterror - 始终检查 chrome.runtime.lastErrormsg-avoid-broadcast-to-all-tabs - 避免向所有标签页广播消息storage-batch-operations - 批量处理存储操作,而非单独调用storage-choose-correct-type - 根据用例选择正确的存储类型storage-cache-frequently-accessed - 缓存频繁访问的存储值storage-use-session-for-temp - 使用 storage.session 存储临时运行时数据storage-avoid-storing-large-blobs - 避免存储大型二进制数据块net-use-declarativenetrequest - 使用 declarativeNetRequest 替代 webRequestnet-request-minimal-permissions - 请求最小必要权限net-use-activetab - 使用 activeTab 权限替代宽泛的主机权限net-limit-csp-modifications - 避免修改内容安全策略(CSP)头部mem-cleanup-event-listeners - 在内容脚本卸载时清理事件监听器mem-avoid-detached-dom - 避免持有对已分离 DOM 节点的引用mem-avoid-closure-leaks - 避免意外的闭包内存泄漏mem-clear-intervals-timeouts - 在清理时清除定时器和超时mem-use-weak-collections - 使用 WeakMap 和 WeakSet 引用 DOM 元素ui-minimize-popup-bundle - 最小化弹出窗口包大小以实现快速启动ui-render-with-cached-data - 首先使用缓存数据渲染弹出窗口 UIui-batch-badge-updates - 批量更新徽章以避免闪烁ui-use-options-page-lazy - 懒加载选项页面部分api-use-promises-over-callbacks - 使用基于 Promise 的 API 调用替代回调api-query-tabs-efficiently - 使用特定过滤器查询标签页api-avoid-redundant-api-calls - 避免在循环中进行冗余的 API 调用api-use-alarms-minperiod - 遵守 alarms API 的最小周期限制api-handle-context-invalidated - 处理扩展上下文失效错误api-use-declarative-content - 使用 declarative content API 处理页面操作style-boolean-naming - 布尔变量使用 is/has/should 前缀style-cache-naming - 使用一致的缓存变量命名style-constants - 为魔法值定义常量style-directory-structure - 按功能/层次组织代码style-file-naming - 使用一致的文件命名约定style-function-naming - 使用描述性的函数名style-import-type - 对类型使用仅类型导入style-index-entry-points - 使用 index 文件作为模块入口点style-message-enums - 对消息类型使用枚举style-type-naming - 对类型和接口使用 PascalCasecomp-adapter-interface - 对浏览器 API 使用适配器模式comp-content-script-structure - 以一致的方式组织内容脚本结构comp-css-class-patterns - 使用 BEM 或带前缀的 CSS 类comp-manager-class - 对复杂状态使用管理器类comp-type-guards - 使用类型守卫进行运行时验证comp-ui-components - 创建可复用的 UI 组件err-context-invalidation - 处理扩展上下文失效err-early-return - 使用提前返回进行错误处理err-null-coalescing - 使用空值合并运算符设置默认值err-promise-barrier - 使用 Promise 屏障进行协调err-storage-operations - 处理存储操作失败err-url-parsing - 使用 try/catch 安全地解析 URLerr-validation-pattern - 在边界处验证输入test-browser-api-mocking - 在测试中模拟 chrome APItest-organization - 按功能组织测试test-validation-functions - 彻底测试验证函数阅读各个参考文件以获取详细说明和代码示例:
如需包含所有规则的完整指南(单文档),请参阅 AGENTS.md。
| 文件 | 描述 |
|---|---|
| AGENTS.md | 包含所有规则的完整编译指南 |
| references/_sections.md | 类别定义和排序 |
| assets/templates/_template.md | 新规则模板 |
| metadata.json | 版本和参考信息 |
每周安装数
239
代码仓库
GitHub 星标数
85
首次出现
2026年1月29日
安全审计
安装于
opencode185
gemini-cli181
codex180
github-copilot171
claude-code166
cursor164
Comprehensive performance and code quality guide for Chrome Extensions (Manifest V3). Contains 67 rules across 12 categories, prioritized by impact to guide automated refactoring and code generation.
Reference these guidelines when:
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Service Worker Lifecycle | CRITICAL | sw- |
| 2 | Content Script Optimization | CRITICAL | content- |
| 3 | Message Passing Efficiency | HIGH | msg- |
| 4 | Storage Operations | HIGH | storage- |
| 5 | Network & Permissions | MEDIUM-HIGH | net- |
| 6 | Memory Management | MEDIUM | mem- |
| 7 | UI Performance | MEDIUM | ui- |
| 8 | API Usage Patterns | LOW-MEDIUM | api- |
| 9 | Code Style & Naming | MEDIUM | style- |
| 10 | Component Patterns | MEDIUM | comp- |
| 11 | Error Handling | HIGH | err- |
| 12 | Testing Patterns | MEDIUM | test- |
sw-persist-state-storage - Persist state with chrome.storage instead of global variablessw-avoid-keepalive - Avoid artificial service worker keep-alive patternssw-use-alarms-api - Use chrome.alarms instead of setTimeout/setIntervalsw-return-true-async - Return true from message listeners for async responsessw-register-listeners-toplevel - Register event listeners at top levelcontent-use-specific-matches - Use specific URL match patternscontent-use-document-idle - Use document_idle for content script injectioncontent-programmatic-injection - Prefer programmatic injection over manifest declarationcontent-minimize-script-size - Minimize content script bundle sizecontent-batch-dom-operations - Batch DOM operations to minimize reflowsmsg-use-ports-for-frequent - Use port connections for frequent message exchangemsg-minimize-payload-size - Minimize message payload sizemsg-debounce-frequent-events - Debounce high-frequency events before messagingmsg-check-lasterror - Always check chrome.runtime.lastErrormsg-avoid-broadcast-to-all-tabs - Avoid broadcasting messages to all tabsstorage-batch-operations - Batch storage operations instead of individual callsstorage-choose-correct-type - Choose the correct storage type for your use casestorage-cache-frequently-accessed - Cache frequently accessed storage valuesstorage-use-session-for-temp - Use storage.session for temporary runtime datastorage-avoid-storing-large-blobs - Avoid storing large binary blobsnet-use-declarativenetrequest - Use declarativeNetRequest instead of webRequestnet-request-minimal-permissions - Request minimal required permissionsnet-use-activetab - Use activeTab permission instead of broad host permissionsnet-limit-csp-modifications - Avoid modifying Content Security Policy headersmem-cleanup-event-listeners - Clean up event listeners when content script unloadsmem-avoid-detached-dom - Avoid holding references to detached DOM nodesmem-avoid-closure-leaks - Avoid accidental closure memory leaksmem-clear-intervals-timeouts - Clear intervals and timeouts on cleanupmem-use-weak-collections - Use WeakMap and WeakSet for DOM element referencesui-minimize-popup-bundle - Minimize popup bundle size for fast startupui-render-with-cached-data - Render popup UI with cached data firstui-batch-badge-updates - Batch badge updates to avoid flickerui-use-options-page-lazy - Lazy load options page sectionsapi-use-promises-over-callbacks - Use promise-based API calls over callbacksapi-query-tabs-efficiently - Query tabs with specific filtersapi-avoid-redundant-api-calls - Avoid redundant API calls in loopsapi-use-alarms-minperiod - Respect alarms API minimum periodapi-handle-context-invalidated - Handle extension context invalidated errorsstyle-boolean-naming - Use is/has/should prefixes for boolean variablesstyle-cache-naming - Use consistent cache variable namingstyle-constants - Define constants for magic valuesstyle-directory-structure - Organize code by feature/layerstyle-file-naming - Use consistent file naming conventionscomp-adapter-interface - Use adapter pattern for browser APIscomp-content-script-structure - Structure content scripts consistentlycomp-css-class-patterns - Use BEM or prefixed CSS classescomp-manager-class - Use manager classes for complex statecomp-type-guards - Use type guards for runtime validationerr-context-invalidation - Handle extension context invalidationerr-early-return - Use early returns for error handlingerr-null-coalescing - Use nullish coalescing for defaultserr-promise-barrier - Use promise barriers for coordinationerr-storage-operations - Handle storage operation failurestest-browser-api-mocking - Mock chrome APIs in teststest-organization - Organize tests by featuretest-validation-functions - Test validation functions thoroughlyRead individual reference files for detailed explanations and code examples:
For a complete guide with all rules in a single document, see AGENTS.md.
| File | Description |
|---|---|
| AGENTS.md | Complete compiled guide with all rules |
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |
Weekly Installs
239
Repository
GitHub Stars
85
First Seen
Jan 29, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
opencode185
gemini-cli181
codex180
github-copilot171
claude-code166
cursor164
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
106,200 周安装
sw-use-offscreen-for-domcontent-use-mutation-observerapi-use-declarative-contentstyle-function-namingstyle-import-type - Use type-only imports for typesstyle-index-entry-points - Use index files for module entry pointsstyle-message-enums - Use enums for message typesstyle-type-naming - Use PascalCase for types and interfacescomp-ui-componentserr-url-parsingerr-validation-pattern - Validate inputs at boundaries