service-worker

service-worker is a skill for Claude Code, Codex from jgamaraalv/ts-dev-kit. It costs 132 tokens per session (1,691 once invoked), scanned A, original, MIT.

A guide to service workers, browser scripts that can handle network requests and background tasks separately from a webpage. It covers registration, lifecycle events, caching, push notifications, and background sync.

In plain words
What is it for?
Use it when creating a service worker, adding offline support, configuring cache strategies, or integrating one with Next.js.
Why use it?
It explains the rules and timing that often make service workers difficult to implement, including installation, updates, caching, and page control.

Skill for Claude CodeCodex

Part of the ts-dev-kit plugin — 22 skills, 15 agents shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/jgamaraalv/ts-dev-kit/service-worker
Any agent
npx skills add jgamaraalv/ts-dev-kit --skill service-worker
Clone the repo
git clone --depth 1 https://github.com/jgamaraalv/ts-dev-kit

Made for: Claude Code, Codex.

Or install ts-dev-kit, the plugin that ships this one along with the rest of its 22 skills, 15 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for service-worker

README.md
[![agentmods](https://agentmods.dev/badge/skills/jgamaraalv/ts-dev-kit/service-worker.svg)](https://agentmods.dev/skills/jgamaraalv/ts-dev-kit/service-worker)
Your own site
<a href="https://agentmods.dev/skills/jgamaraalv/ts-dev-kit/service-worker"><img src="https://agentmods.dev/badge/skills/jgamaraalv/ts-dev-kit/service-worker.svg" alt="Measured on agentmods" height="20"></a>
Per session 132 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,691 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00132 $0.01691
Opus 5 $0.00066 $0.00846
Sonnet 5 $0.00026 $0.00338
Haiku 4.5 $0.00013 $0.00169

Measured 5d ago against content hash 2a5f68b5d850, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

service-worker scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

event.respondWith(caches.match(event.request).then((cached) => cached || fetch(event.request)));
skills/service-worker/SKILL.md · 207 lines

How it starts

The opening of the file, as written. The whole thing — 207 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Service Worker

Table of Contents

Constraints

  • HTTPS required (localhost exempt for dev)
  • No DOM access — runs on separate thread
  • Fully async — no synchronous XHR, no localStorage
  • No dynamic import() — only static import statements
  • Scope defaults to the directory containing the SW file
  • self refers to ServiceWorkerGlobalScope

<quick_reference>

Lifecycle

register() → Download → Install → [Wait] → Activate → Fetch control
  1. Register from main thread via navigator.serviceWorker.register()
  2. Install event fires once — use to pre-cache static assets
  3. Wait — new SW waits until all tabs using old SW are closed (skip with self.skipWaiting())
  4. Activate event fires — use to clean up old caches
  5. Fetch events start flowing — SW controls page network requests

A document must reload to be controlled (or call clients.claim() during activate).

Updating a Service Worker

  • Browser byte-compares the SW file on each navigation (or every 24h)
  • New version installs in background while old version still serves
  • Increment the cache name (e.g., v1v2) in the new version
  • Delete old caches in the activate handler
  • Call self.skipWaiting() in install to activate immediately
  • Call self.clients.claim() in activate to take control of open pages

DevTools

  • Chrome: chrome://inspect/#service-workers or Application > Service Workers
  • Firefox: about:debugging#/runtime/this-firefox or Application > Service Workers
  • Edge: edge://inspect/#service-workers or Application > Service Workers

Unregister, update, and inspect caches from the Application panel. Use "Update on reload" checkbox during development.

Read the full file on GitHub · 207 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 207 lines · 132 tokens per session scan A 2a5f68b5d850

Subscribe to this mod's changes

service-worker is a skill published in the GitHub repository jgamaraalv/ts-dev-kit (15 stars, last pushed 6mo ago), licensed MIT. It adds 132 tokens to every session and 1,691 once invoked, about $0.0007 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

v8-jit

V8 JIT optimization patterns for writing high-performance JavaScript in Next.js server internals. Use when writing or reviewing hot-path code in app-render, stream-utils, routing, caching, or any per-request code path. Covers hidden classes / shapes, monomorphic call sites, inline caches, megamorphic deopt, closure…

vercel/next.js · 88 tokens

use-agent-browser-for-airi

Test AIRI display-model imports with agent-browser across stage-tamagotchi Electron, stage-web, and stage-pocket mobile web layouts. Use when uploading and verifying contributor-supplied Live2D ZIP, VRM, or MMD ZIP/PMX/PMD files through AIRI's model selector, including onboarding bypass, format-specific import…

moeru-ai/airi · 87 tokens

opencli-sitemap-author

Use when creating or maintaining OpenCLI site sitemaps: agent-facing navigation, page-state, action, workflow, API-reference, pitfall, and fallback knowledge for a website. Use after browser exploration discovers durable site context, when a sitemap is stale, or when promoting local site knowledge into the repo.

jackwener/OpenCLI · 67 tokens

debug-optimize-lcp

Guides debugging and optimizing Largest Contentful Paint (LCP) using Chrome DevTools MCP tools. Use this skill whenever the user asks about LCP performance, slow page loads, Core Web Vitals optimization, or wants to understand why their page's main content takes too long to appear. Also use when the user mentions…

ChromeDevTools/chrome-devtools-mcp · 99 tokens

webapp-testing

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

every-app/open-seo · 35 tokens

interactive-login

How to complete browser/interactive logins (aws / gh / glab / gcloud). The platform backgrounds the login poller so it survives the human's browser round-trip — and when that does NOT work.

yc-software/qm · 46 tokens