Token导航 LogoToken导航

Agent Skill · 开发

web-pwa-service-workers(Web PWA 服务人员)

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

web-pwa-service-workers 是开发类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为操作浏览器;许可证信息还不明确,第三方扫描已通过,按安装量在开发类的 21,746 个 Skill 里排第 18,732。

总安装 318周安装 13GitHub Stars 5下载 103核验 2026-05-01

安装说明

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

安装方式

通过对话安装

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

请帮我安装这个 Agent Skill:web-pwa-service-workers(Web PWA 服务人员)
来源仓库:https://github.com/agents-inc/skills
仓库路径:skills/web-pwa-service-workers
安装命令:
npx skills add https://github.com/agents-inc/skills --skill web-pwa-service-workers
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/agents-inc/skills --skill web-pwa-service-workers

这个 Skill 是做什么的

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

用于处理 GitHub 仓库、Issue、Pull Request 等协作信息,支持服务工作者相关开发。适合在需要围绕代码变更、协作流程或技术讨论进行整理时使用。通过 GitHub 安装,建议查阅原始 README 获取详细用法。注意确认其是否涉及网络请求、文件读写或系统级操作权限。

web-pwa-service-workers 属于开发类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/web-pwa-service-workers

上手步骤

4 步
  1. 1

    确认自己的宿主工具

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

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/agents-inc/skills --skill web-pwa-service-work…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

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

  4. 4

    按最小权限试用

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

常见问题

6 条

web-pwa-service-workers 怎么安装?

在终端执行 npx skills add https://github.com/agents-inc/skills --skill web-pwa-service-workers。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

web-pwa-service-workers 支持哪些 AI 工具?

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

web-pwa-service-workers 需要什么权限?

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

web-pwa-service-workers 是免费的吗?

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

web-pwa-service-workers 用的人多吗?

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

web-pwa-service-workers 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

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

值得选的地方

  • 同时适配 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有提醒
web-pwa-service-workers

Web PWA 服务人员 · 本页

3185操作浏览器未明确通过

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

SKILL.md 原文

Service Worker Patterns

Quick Guide: Use Service Workers for offline-first applications with sophisticated caching. Implement cache-first for static assets, network-first for HTML, and stale-while-revalidate for API data. Always handle the install/activate/fetch lifecycle properly, version your caches, and provide user control over updates. Clone responses before caching (body can only be consumed once).

<critical_requirements>

CRITICAL: Before Using This Skill

All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering, import type, named constants)

(You MUST call event.waitUntil() in install and activate handlers to signal completion)

(You MUST version your caches and clean up old versions during activation)

(You MUST clone responses before caching - cache.put(request, response.clone()) - response body can only be consumed once)

(You MUST implement proper update detection and give users control over when updates apply)

(You MUST handle all fetch failures with appropriate offline fallbacks)

</critical_requirements>


Auto-detection: Service Worker, serviceWorker, sw.js, sw.ts, navigator.serviceWorker, caches, Cache API, CacheStorage, skipWaiting, clients.claim, precache, offline-first, PWA

When to use:

  • Building Progressive Web Apps (PWAs) with offline support
  • Implementing sophisticated caching strategies beyond browser defaults
  • Providing offline fallback pages or cached content
  • Controlling how network requests are handled and cached

When NOT to use:

  • Simple websites without offline requirements
  • When browser HTTP caching is sufficient
  • For real-time data that must always be fresh (use network-only)

Detailed Resources:

  • examples/core.md - Registration, lifecycle template, caching strategy implementations, types
  • examples/caching.md - Advanced caching (expiration, selective API, storage cleanup, navigation preload)
  • examples/updates.md - Version tracking, update strategies (aggressive, deferred, idle, rollout, migration)
  • reference.md - Decision frameworks, anti-patterns, lifecycle reference, checklists

Philosophy

Service Workers are programmable network proxies that run in a separate thread, intercepting requests between your application and the network. They enable offline functionality, sophisticated caching, and background operations.

The Service Worker lifecycle is designed for safety:

  1. Install Phase: Download and cache critical assets. The worker is "waiting" until installation completes.
  2. Waiting Phase: New workers wait for all tabs using the old worker to close, preventing version conflicts.
  3. Activate Phase: Old caches are cleaned up, and the worker takes control.
  4. Fetch Phase: The active worker intercepts all network requests within its scope.
Registration → Download → Install → Waiting → Activate → Fetch
                            ↓          ↓
                     (skipWaiting)  (claim)

Core Principles:

  1. Safety First: The lifecycle prevents running multiple versions simultaneously, which could corrupt state.
  2. User Control: Users should decide when updates apply, not be surprised by sudden behavior changes mid-session.
  3. Graceful Degradation: Always provide fallbacks when network and cache both fail.
  4. Cache Versioning: Version your caches to enable clean upgrades and prevent unbounded growth.

Core Patterns

Pattern 1: Service Worker Registration

Register from your main application with feature detection, update checking, and user-controlled updates.

const SW_PATH = "/sw.js";
const UPDATE_CHECK_INTERVAL_MS = 60 * 60 * 1000;

const registration = await navigator.serviceWorker.register(SW_PATH, {
  scope: "/",
  updateViaCache: "none", // Always check server for updates
});

// Periodic update checks
setInterval(() => registration.update(), UPDATE_CHECK_INTERVAL_MS);

// Track waiting worker for user-controlled updates
registration.addEventListener("updatefound", () => {
  const installing = registration.installing;
  installing?.addEventListener("statechange", () => {
    if (
      installing.state === "installed" &&
      navigator.serviceWorker.controller
    ) {
      // New version waiting - notify user
    }
  });
});

See examples/core.md Pattern 1 for complete registration with update tracking and reload handling.


Pattern 2: Lifecycle Handlers (Install / Activate / Message)

The three essential lifecycle event handlers: precache in install, cleanup in activate, user-controlled skipWaiting via message.

// Install - precache critical assets
self.addEventListener("install", (event: ExtendableEvent) => {
  event.waitUntil(
    caches.open(CACHES.static).then((cache) => cache.addAll(PRECACHE_URLS)),
  );
  // Do NOT call skipWaiting here - let user control updates
});

// Activate - cleanup old caches, claim clients
self.addEventListener("activate", (event: ExtendableEvent) => {
  event.waitUntil(
    caches
      .keys()
      .then((names) =>
        Promise.all(
          names
            .filter((n) => !currentCaches.includes(n))
            .map((n) => caches.delete(n)),
        ),
      )
      .then(() => self.clients.claim()),
  );
});

// Message - user-controlled skipWaiting
self.addEventListener("message", (event: ExtendableMessageEvent) => {
  if (event.data?.type === "SKIP_WAITING") self.skipWaiting();
});

See examples/core.md Pattern 2 for complete template with constants and type safety.


Pattern 3: Caching Strategies

Four strategies to match content types:

StrategyWhen to UseBehavior
Cache-firstStatic assets, fonts, hashed filesReturn cached immediately, network fallback
Network-firstHTML pages, user-specific API dataTry network with timeout, cache fallback
Stale-while-revalidateAvatars, non-critical API, feedsReturn cached, refresh in background
Cache-only / Network-onlyPrecached shells / real-time dataSingle source, no fallback

Key implementation details:

  • Always check response.ok before caching (avoid caching 404/500)
  • Always response.clone() before cache.put() (body consumed once)
  • Add timeout to network-first to avoid hanging on slow connections
  • Limit cache size to prevent unbounded storage growth
// The clone pattern - response body can only be consumed once
const networkResponse = await fetch(request);
if (networkResponse.ok) {
  cache.put(request, networkResponse.clone()); // Clone for cache
}
return networkResponse; // Original for client

See examples/core.md Pattern 2 for all strategy implementations in the complete template, and examples/caching.md for advanced patterns (expiration, selective API caching, storage cleanup).


Pattern 4: Fetch Event Routing

Route requests to appropriate caching strategies based on request type and URL.

self.addEventListener("fetch", (event: FetchEvent) => {
  const { request } = event;
  const url = new URL(request.url);

  if (request.method !== "GET") return; // Skip non-GET
  if (url.origin !== location.origin) return; // Skip cross-origin

  if (request.mode === "navigate") {
    event.respondWith(networkFirst(request, CACHES.pages));
  } else if (request.destination === "image") {
    event.respondWith(
      cacheFirstWithLimit(request, CACHES.images, MAX_CACHE_ITEMS.images),
    );
  } else if (url.pathname.startsWith("/api/")) {
    event.respondWith(staleWhileRevalidate(request, CACHES.api));
  } else {
    event.respondWith(cacheFirst(request, CACHES.static));
  }
});

Pattern 5: Offline Fallback

Always precache an offline.html page and return it when both cache and network fail for navigation requests.

// In install handler: precache offline.html
// In fetch error handling:
if (request.mode === "navigate") {
  const offlinePage = await caches.match("/offline.html");
  if (offlinePage) return offlinePage;
}

// Last resort: inline response
return new Response(
  "<html><body><h1>Offline</h1><p>Check your connection.</p></body></html>",
  { status: 503, headers: { "Content-Type": "text/html" } },
);

Pattern 6: Navigation Preload

Fetch navigation requests in parallel with service worker bootup, reducing latency for network-first HTML. Enable in activate, consume via event.preloadResponse in fetch.

// Activate: enable navigation preload
if (self.registration.navigationPreload) {
  await self.registration.navigationPreload.enable();
}

// Fetch: use preloaded response (avoids double fetch)
const preloadResponse = await event.preloadResponse;
if (preloadResponse) {
  cache.put(event.request, preloadResponse.clone());
  return preloadResponse;
}

Warning: If you enable navigation preload, you MUST use event.preloadResponse. Using fetch(event.request) instead results in two network requests for the same resource.

When to use: Network-first HTML pages with dynamic/authenticated content. Not needed for precached app shells.

See examples/caching.md Pattern 8 for complete implementation.


Pattern 7: Update Handling

Users should control when updates apply. Detect waiting workers, notify users, and let them trigger skipWaiting.

// Client: detect and apply updates
if (registration.waiting) {
  showUpdateBanner();
}

function applyUpdate() {
  registration.waiting?.postMessage({ type: "SKIP_WAITING" });
}

// Reload when new worker takes control
navigator.serviceWorker.addEventListener("controllerchange", () => {
  window.location.reload();
});

See examples/updates.md for version tracking, aggressive updates, deferred updates, idle-time updates, progressive rollout, and data migration patterns.


<red_flags>

RED FLAGS

High Priority Issues:

  • No event.waitUntil() in install/activate - browser may terminate SW before async operations complete
  • Calling skipWaiting() unconditionally in install - users experience unexpected behavior changes mid-session
  • No cache versioning - old cached content persists forever, storage grows unbounded
  • Not cleaning up old caches in activate - storage quota eventually exceeded
  • Missing offline fallback - users see browser error page instead of helpful message
  • Not checking response.ok before caching - error responses (404, 500) get cached and served

Medium Priority Issues:

  • No timeout on network requests in network-first strategy - fetch hangs indefinitely on slow connections
  • Not cloning response before caching - response body consumed, client gets empty response
  • No cache size limits - unbounded growth leads to quota issues
  • Attempting to cache POST requests - only GET requests are cacheable

Gotchas & Edge Cases:

  • Service workers only work over HTTPS (exception: localhost for development)
  • Scope determined by SW file location - /sw.js controls /, but /scripts/sw.js only controls /scripts/
  • Browser may terminate idle service workers - do not rely on in-memory state
  • clients.claim() does not trigger reload - clients keep running old page with new SW
  • Chrome DevTools "Update on reload" bypasses waiting - useful for dev, not representative of production
  • Web app manifest changes do not trigger SW update - only byte changes to SW file itself
  • IndexedDB transactions cannot span await - complete DB work in single transaction
  • Opaque responses (cross-origin without CORS) count against storage quota at inflated cost
  • Service worker bootup varies: ~50ms desktop, ~250ms mobile, 500ms+ slow devices - navigation preload mitigates this

</red_flags>


<critical_reminders>

CRITICAL REMINDERS

All code must follow project conventions in CLAUDE.md

(You MUST call event.waitUntil() in install and activate handlers to signal completion)

(You MUST version your caches and clean up old versions during activation)

(You MUST clone responses before caching - cache.put(request, response.clone()) - response body can only be consumed once)

(You MUST implement proper update detection and give users control over when updates apply)

(You MUST handle all fetch failures with appropriate offline fallbacks)

Failure to follow these rules will result in broken updates, unbounded cache growth, and poor offline experience.

</critical_reminders>

平台分布

Codex

36.33%
按下载量换算37

Claude

27.44%
按下载量换算28

Cursor

18.46%
按下载量换算19

Gemini CLI

9.71%
按下载量换算10

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

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

安装前确认

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

继续浏览同类 Skills