Token导航 LogoToken导航

Agent Skill · 开发

wxt-framework-patterns(wxt 框架模式)

wxt-framework-patterns 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

wxt-framework-patterns 是开发类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为操作浏览器;许可证信息还不明确,第三方扫描有提醒项,按安装量在开发类的 21,746 个 Skill 里排第 19,470。

总安装 269周安装 11GitHub Stars 7下载 86核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:wxt-framework-patterns(wxt 框架模式)
来源仓库:https://github.com/arustydev/ai
仓库路径:skills/wxt-framework-patterns
安装命令:
npx skills add https://github.com/arustydev/ai --skill wxt-framework-patterns
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/arustydev/ai --skill wxt-framework-patterns

这个 Skill 是做什么的

开发类 Skill 面向写代码、改代码和排查问题,一般会读写仓库文件,部分还会执行构建或测试命令。

用于处理 GitHub 仓库协作信息,包括 Issue、Pull Request 和代码变更跟踪。适合在开发流程中辅助状态查询、变更整理和协作事项管理。通过 GitHub 安装,使用 npx 命令添加技能并关联目标仓库。建议提前确认权限范围、维护状态及是否触发文件读写或网络请求。

wxt-framework-patterns 属于开发类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/wxt-framework-patterns

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/arustydev/ai --skill wxt-framework-patterns;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要操作浏览器,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

wxt-framework-patterns 怎么安装?

在终端执行 npx skills add https://github.com/arustydev/ai --skill wxt-framework-patterns。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

wxt-framework-patterns 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

wxt-framework-patterns 需要什么权限?

权限级别是操作浏览器。该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

wxt-framework-patterns 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

wxt-framework-patterns 用的人多吗?

公开数据是累计安装 269 次,近一周安装 11 次,下载 86 次,GitHub 7 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

wxt-framework-patterns 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

开发类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
skill-vetter

技能审查员 · OpenClaw

8,779,018986操作浏览器MIT-0通过
ontology

本体论 · OpenClaw

6,636,960576只读MIT-0通过
entra-app-registration

内部应用程序注册 · Codex、Claude

6,631,872764接触敏感数据未明确通过
entra-app-registration

内部应用程序注册 · Codex、Claude

3,757,680201接触敏感数据未明确通过
nano-banana-pro

纳米香蕉专业版 · OpenClaw

3,526,898364接触敏感数据MIT-0有提醒
wxt-framework-patterns

wxt 框架模式 · 本页

2697操作浏览器未明确有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

WXT Framework Patterns

Comprehensive guide for building cross-browser extensions with WXT, including security hardening, Firefox/Safari specifics, and production patterns.

Overview

WXT is the leading framework for browser extension development, offering:

  • Cross-browser support: Chrome, Firefox, Edge, Safari
  • Manifest agnostic: MV2 and MV3 from single codebase
  • File-based entrypoints: Auto-generated manifest
  • Vite-powered: Fast HMR for all script types
  • Framework agnostic: React, Vue, Svelte, Solid, vanilla

This skill covers:

  • Project structure and entrypoint patterns
  • Configuration and manifest generation
  • Security hardening rules (49 rules)
  • Firefox-specific patterns
  • Safari-specific patterns
  • Testing and debugging

This skill does NOT cover:

  • General JavaScript/TypeScript patterns
  • Specific UI framework implementations
  • Store submission process (see store-submission skill)

Quick Reference

CLI Commands

CommandPurpose
wxtStart dev mode with HMR
wxt buildProduction build
wxt build -b firefoxFirefox-specific build
wxt zipPackage for distribution
wxt prepareGenerate TypeScript types
wxt cleanClean output directories
wxt submitPublish to stores

Entrypoint Types

TypeFileManifest Key
Backgroundentrypoints/background.tsbackground.service_worker
Content Scriptentrypoints/content.tscontent_scripts
Popupentrypoints/popup/action.default_popup
Optionsentrypoints/options/options_page
Side Panelentrypoints/sidepanel/side_panel
Unlistedentrypoints/*.tsNot in manifest

Project Structure

my-extension/
├── entrypoints/
│   ├── background.ts           # Service worker
│   ├── content.ts              # Content script
│   ├── content/                # Multi-file content script
│   │   ├── index.ts
│   │   └── styles.css
│   ├── popup/
│   │   ├── index.html
│   │   ├── main.ts
│   │   └── App.vue
│   ├── options/
│   │   └── index.html
│   └── sidepanel/
│       └── index.html
├── public/
│   └── icon/
│       ├── 16.png
│       ├── 32.png
│       ├── 48.png
│       └── 128.png
├── utils/                      # Shared utilities
├── wxt.config.ts               # WXT configuration
├── tsconfig.json
└── package.json

Entrypoint Patterns

Background Script (Service Worker)

// entrypoints/background.ts
export default defineBackground(() => {
  console.log('Extension loaded', { id: browser.runtime.id });

  // Handle messages from content scripts
  browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
    if (message.type === 'getData') {
      handleGetData(message.payload).then(sendResponse);
      return true; // Keep channel open for async response
    }
  });

  // Use alarms for recurring tasks (MV3 service worker friendly)
  browser.alarms.create('sync', { periodInMinutes: 5 });
  browser.alarms.onAlarm.addListener((alarm) => {
    if (alarm.name === 'sync') {
      performSync();
    }
  });
});

Content Script

// entrypoints/content.ts
export default defineContentScript({
  matches: ['*://*.example.com/*'],
  runAt: 'document_idle',

  main(ctx) {
    console.log('Content script loaded');

    // Use context for lifecycle management
    ctx.onInvalidated(() => {
      console.log('Extension updated/disabled');
      cleanup();
    });

    // Create isolated UI
    const ui = createShadowRootUi(ctx, {
      name: 'my-extension-ui',
      position: 'inline',
      anchor: '#target-element',
      onMount(container) {
        // Mount your UI framework here
        return mount(App, { target: container });
      },
      onRemove(app) {
        app.$destroy();
      },
    });

    ui.mount();
  },
});

Content Script with Main World Access

// entrypoints/content.ts
export default defineContentScript({
  matches: ['*://*.example.com/*'],
  world: 'MAIN', // Access page's JavaScript context

  main() {
    // Can access page's window object
    window.myExtensionApi = {
      getData: () => { /* ... */ }
    };
  },
});

Popup with Framework

<!-- entrypoints/popup/index.html -->
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
  <div id="app"></div>
  <script type="module" src="./main.ts"></script>
</body>
</html>
// entrypoints/popup/main.ts
import { createApp } from 'vue';
import App from './App.vue';
import './style.css';

createApp(App).mount('#app');

Configuration

Basic Configuration

// wxt.config.ts
import { defineConfig } from 'wxt';

export default defineConfig({
  srcDir: 'src',
  entrypointsDir: 'src/entrypoints',
  outDir: 'dist',

  manifest: {
    name: 'My Extension',
    description: 'Extension description',
    version: '1.0.0',
    permissions: ['storage', 'activeTab'],
    host_permissions: ['*://*.example.com/*'],
  },
});

Cross-Browser Configuration

// wxt.config.ts
import { defineConfig } from 'wxt';

export default defineConfig({
  manifest: ({ browser }) => ({
    name: 'My Extension',
    description: 'Cross-browser extension',

    // Browser-specific settings
    ...(browser === 'firefox' && {
      browser_specific_settings: {
        gecko: {
          id: 'my-extension@example.com',
          strict_min_version: '109.0',
          data_collection_permissions: {
            required: [],
            optional: ['technicalAndInteraction'],
          },
        },
      },
    }),

    // Chrome-specific
    ...(browser === 'chrome' && {
      minimum_chrome_version: '116',
    }),
  }),
});

Per-Browser Entrypoint Options

// entrypoints/background.ts
export default defineBackground({
  // Different behavior per browser
  persistent: {
    firefox: true,  // Use persistent background in Firefox
    chrome: false,  // Service worker in Chrome
  },

  main() {
    // ...
  },
});

Security Hardening Rules

Manifest Security (Rules 1-10)

#RuleRationale
1Minimize permissionsRequest only what's needed
2Use optional_permissionsRequest sensitive permissions at runtime
3Scope host_permissionsNarrow to specific domains, never <all_urls>
4Set minimum_chrome_versionEnsure security features are available
5Avoid externally_connectable wildcardsLimit which sites can message extension
6Set strict CSPNo unsafe-eval, no external scripts
7Use web_accessible_resources sparinglyFingerprinting risk
8Never expose source mapsHide implementation details
9Remove debug permissions in productione.g., management, debugger
10Validate manifest with wxt build --analyzeCatch permission bloat

Content Script Security (Rules 11-20)

#RuleRationale
11Use Shadow DOM for injected UIStyle isolation, DOM encapsulation
12Never use innerHTML with untrusted dataXSS prevention
13Validate all messages from pageDon't trust window.postMessage
14Use ContentScriptContext for cleanupPrevent memory leaks
15Avoid storing sensitive data in DOMPage scripts can read it
16Use document_idle over document_startLess intrusive, more stable
17Scope CSS selectors narrowlyAvoid page conflicts
18Never inject into banking/payment pagesHigh-risk surfaces
19Use MutationObserver over pollingPerformance
20Validate URL before injectingPrevent injection on wrong pages

Background Script Security (Rules 21-30)

#RuleRationale
21Persist state to chrome.storageService worker terminates
22Use chrome.alarms over setIntervalSurvives worker restart
23Validate all incoming messagesDon't trust content scripts
24Never store secrets in codeUse secure storage
25Use HTTPS for all fetch requestsData in transit security
26Implement rate limitingPrevent abuse
27Log security eventsAudit trail
28Handle extension update gracefullyReconnect content scripts
29Use webRequest carefullyPerformance impact
30Avoid long-running operationsService worker termination

Storage Security (Rules 31-40)

#RuleRationale
31Use storage.local for sensitive dataNot synced to cloud
32Encrypt sensitive valuesDefense in depth
33Implement storage quotasPrevent unbounded growth
34Validate data before storingType safety
35Use versioned schema migrationsData integrity
36Clear storage on uninstallUser privacy
37Don't store PII without consentGDPR/CCPA compliance
38Use storage.session for temporary dataAuto-cleared
39Implement backup/restoreData recovery
40Audit storage accessSecurity logging

Communication Security (Rules 41-49)

#RuleRationale
41Use runtime.sendMessage over postMessageType-safe, scoped
42Validate sender in message handlersPrevent spoofing
43Never pass functions in messagesSerialization issues
44Chunk large data transfersMemory efficiency
45Use typed message protocolsMaintainability
46Implement request timeoutsPrevent hanging
47Handle disconnection gracefullyTab closed, extension disabled
48Don't expose internal APIs externallyUse separate handlers
49Log and monitor message patternsDetect anomalies

Firefox-Specific Patterns

Required Gecko Settings

// wxt.config.ts
manifest: {
  browser_specific_settings: {
    gecko: {
      // Required for AMO submission
      id: 'my-extension@example.com',

      // Version constraints
      strict_min_version: '109.0',

      // Data collection (required since Nov 2025)
      data_collection_permissions: {
        required: [],
        optional: ['technicalAndInteraction'],
      },
    },

    // Firefox for Android
    gecko_android: {
      strict_min_version: '120.0',
    },
  },
}

Firefox MV3 Differences

FeatureChrome MV3Firefox MV3
BackgroundService worker onlyEvent page supported
PersistentNoOptional with persistent: true
browser APIPromisified polyfill neededNative promises
DNRFull supportPartial support
Side PanelSupportedNot supported

Firefox-Specific Build

# Build for Firefox only
wxt build -b firefox

# Build MV2 for Firefox (if needed)
wxt build -b firefox --mv2

Handling Firefox Differences

// utils/browser-detect.ts
export const isFirefox = navigator.userAgent.includes('Firefox');

// entrypoints/background.ts
export default defineBackground({
  persistent: isFirefox, // Keep background alive in Firefox

  main() {
    if (isFirefox) {
      // Firefox-specific initialization
    }
  },
});

Safari-Specific Patterns

Xcode Project Requirements

Safari extensions require an Xcode host app:

# Convert existing extension to Safari
xcrun safari-web-extension-converter /path/to/extension \
  --project-location /path/to/output \
  --app-name "My Extension" \
  --bundle-identifier com.example.myextension

Privacy Manifest (Required)

Every Safari extension host app needs PrivacyInfo.xcprivacy:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>NSPrivacyTracking</key>
  <false/>
  <key>NSPrivacyTrackingDomains</key>
  <array/>
  <key>NSPrivacyCollectedDataTypes</key>
  <array/>
  <key>NSPrivacyAccessedAPITypes</key>
  <array/>
</dict>
</plist>

Safari Limitations

FeatureStatusWorkaround
Side PanelNot supportedUse popup
declarativeNetRequestLimitedUse webRequest
offscreen APINot supportedUse content script
Persistent backgroundNot supportedState persistence
chrome.scripting.executeScriptLimitedDeclare in manifest

Safari Build Workflow

# 1. Build extension
wxt build -b safari

# 2. Convert to Xcode project
xcrun safari-web-extension-converter dist/safari-mv3 \
  --project-location safari-app

# 3. Open in Xcode
open safari-app/MyExtension.xcodeproj

# 4. Add PrivacyInfo.xcprivacy to host app target

# 5. Archive and submit to App Store

TestFlight Distribution

As of 2025, Safari extensions can be submitted as ZIP files to App Store Connect for TestFlight testing without needing Xcode locally.

Storage Patterns

Using WXT Storage Utility

// utils/storage.ts
import { storage } from 'wxt/storage';

// Define typed storage items
export const userSettings = storage.defineItem<{
  theme: 'light' | 'dark';
  notifications: boolean;
}>('local:settings', {
  defaultValue: {
    theme: 'light',
    notifications: true,
  },
});

export const sessionData = storage.defineItem<string[]>(
  'session:recentTabs',
  { defaultValue: [] }
);

// Usage
const settings = await userSettings.getValue();
await userSettings.setValue({ ...settings, theme: 'dark' });

// Watch for changes
userSettings.watch((newValue, oldValue) => {
  console.log('Settings changed:', newValue);
});

Storage Migrations

// utils/storage.ts
import { storage } from 'wxt/storage';

export const userPrefs = storage.defineItem('local:prefs', {
  defaultValue: { version: 2, theme: 'system' },

  migrations: [
    // v1 -> v2: renamed 'darkMode' to 'theme'
    {
      version: 2,
      migrate(oldValue: { darkMode?: boolean }) {
        return {
          version: 2,
          theme: oldValue.darkMode ? 'dark' : 'light',
        };
      },
    },
  ],
});

Testing Patterns

Unit Testing with Vitest

// tests/background.test.ts
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { fakeBrowser } from 'wxt/testing';

describe('background script', () => {
  beforeEach(() => {
    fakeBrowser.reset();
  });

  it('handles getData message', async () => {
    // Setup fake response
    fakeBrowser.storage.local.get.mockResolvedValue({ data: 'test' });

    // Import and run background script
    await import('../entrypoints/background');

    // Simulate message
    const [listener] = fakeBrowser.runtime.onMessage.addListener.mock.calls[0];
    const response = await new Promise((resolve) => {
      listener({ type: 'getData' }, {}, resolve);
    });

    expect(response).toEqual({ data: 'test' });
  });
});

E2E Testing

// tests/e2e/extension.test.ts
import { test, expect, chromium } from '@playwright/test';
import path from 'path';

test('popup shows correct UI', async () => {
  const extensionPath = path.join(__dirname, '../../dist/chrome-mv3');

  const context = await chromium.launchPersistentContext('', {
    headless: false,
    args: [
      `--disable-extensions-except=${extensionPath}`,
      `--load-extension=${extensionPath}`,
    ],
  });

  // Get extension ID
  const [background] = context.serviceWorkers();
  const extensionId = background.url().split('/')[2];

  // Open popup
  const popup = await context.newPage();
  await popup.goto(`chrome-extension://${extensionId}/popup.html`);

  await expect(popup.locator('h1')).toHaveText('My Extension');
});

Production Checklist

Before Build

  • Remove console.log statements
  • Set production environment variables
  • Verify all permissions are necessary
  • Test on all target browsers
  • Run security audit (npm audit)
  • Check bundle size (wxt build --analyze)

Manifest Validation

  • Extension name and description are accurate
  • Icons in all required sizes (16, 32, 48, 128)
  • Version follows semver
  • Gecko ID set for Firefox
  • Privacy manifest for Safari
  • CSP is strict (no unsafe-eval)

Cross-Browser Build

# Build all browsers
wxt build -b chrome
wxt build -b firefox
wxt build -b safari
wxt build -b edge

# Package for submission
wxt zip -b chrome
wxt zip -b firefox

References

平台分布

Codex

37.15%
按下载量换算32

Claude

31.52%
按下载量换算27

Cursor

17.34%
按下载量换算15

Gemini CLI

10%
按下载量换算9

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills