migrate-example

A command for moving a Web Worker example into shared application logic and displaying it in five visual themes. A Web Worker runs JavaScript in the background so it does not block the main page.

In plain words
What is it for?
Use it to migrate an existing Worker example, create its testable logic and service, register it, and connect it to each theme. It can also select the next unmigrated example when no example is specified.
Why use it?
It gives a repeatable path for moving old examples without duplicating their core logic. It also includes testing and design review so the example works across themes.

Command for Claude Code

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 commands/damiansire/web-worker-patterns/migrate-example
Clone the repo
git clone --depth 1 https://github.com/damiansire/web-worker-patterns

Made for: Claude Code.

Per session 30 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,121 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. 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.00030 $0.01121
Opus 5 $0.00015 $0.00561
Sonnet 5 $0.00006 $0.00224
Haiku 4.5 $0.00003 $0.00112

Measured yesterday against content hash e09a253d338a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

migrate-example scanned grade A with 0 findings 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 yesterday.

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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/migrate-example.md · 69 lines

How it starts

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

Migrar ejemplo: $1

Codifica el pipeline por-ejemplo que ya repetimos en los ejemplos 04–13. Seguilo en orden; no saltees el loop de design-review. La regla de oro manda: el dominio se escribe una vez en core/, la presentación cinco veces en themes/. core/ NUNCA importa de themes/.

0. Encuadre

  • Si $1 está vacío, abrí src/app/core/domain/examples/examples.registry.ts y tomá el primer ejemplo sin migrar (sin @case en los layouts / sin entrada de contenido).
  • Mirá el worker legacy correspondiente y decidí el DemoKind (o si hace falta uno nuevo).
  • Anotá el plan con TodoWrite antes de tocar código.

1. Dominio (se escribe UNA vez, en core/)

  1. Worker neutral: portá el legacy a core/domain/workers/<id>.worker.ts. Extraé la lógica pura a <id>.worker.logic.ts para poder testearla sin Worker real (jsdom no los soporta). El worker queda como cáscara fina sobre la lógica pura.
  2. Service: core/services/<algo>-demo.service.ts, @Injectable({ providedIn: 'root' }), estado en signals. Seam de tiempo inyectable (clock / stepDelayMs) para los specs. Requisito duro: el estado sobrevive al cambio de theme (un worker corriendo sigue).
  3. DemoKind: si el ejemplo no encaja en una variante existente, sumá el literal a la union en core/domain/examples/example.model.ts.
  4. Registry: entrada en examples.registry.ts con workerFactory/sharedWorkerFactory y los snippets de código neutrales que muestra el code-block.
  5. Test de dominio (antes de UI): spec del .worker.logic.ts y/o del service con un fake-worker. Si tocaste dominio, hay test que lo cubre. npm test verde.

2. i18n (contenido neutral)

  • Agregá examples.$1.* a public/i18n/es.json, en.json, pt.json. El contenido educativo es neutral; sólo el chrome de cada theme tiene strings propios.

3. Presentación (se escribe CINCO veces)

  • Sumá el @case '<DemoKind>' en los 5 example-layouts: editorial, dev-tool, narrative, brutalist, full-brutalist.
  • Cada theme con su visualización propia del concepto: nada de colores/fuentes literales, siempre tokens semánticos (--surface, --ink, --accent, --thread-*). El visualizer se resuelve por DI (THREAD_VISUALIZER).
  • Criterio clave: la visualización enseña el concepto SIN leer el código.

Read the full file on GitHub · 69 lines

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. yesterday First seen · 69 lines · 30 tokens per session scan A e09a253d338a

Subscribe to this mod's changes

migrate-example is a command published in the GitHub repository damiansire/web-worker-patterns (175 stars, last pushed 15d ago), licensed MIT. It adds 30 tokens to every session and 1,121 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.