typed-events

typed-events is a skill for Claude Code, Codex from stephansama/packages. It costs 80 tokens per session (1,826 once invoked), scanned A, original, MIT.

A TypeScript wrapper around browser messaging features: page events, communication between browser tabs, and messages sent to iframes or other windows. It checks event data against schemas before delivering it.

In plain words
What is it for?
Use it for typed custom events within a page, grouped event maps, state sharing across tabs, combined local-and-tab events, and messages to iframes or cross-origin windows.
Why use it?
It reduces the chance that browser messages contain the wrong data shape and provides one consistent way to send and receive them. Listeners can also be removed through a returned cleanup function.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it for typed custom events within a page, grouped event maps, state sharing across tabs, combined local-and-tab events, and messages to iframes or cross-origin windows.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/stephansama/packages/typed-events
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.

Any agent
npx skills add stephansama/packages --skill typed-events
Clone the repo
git clone --depth 1 https://github.com/stephansama/packages

Made for: Claude Code, Codex.

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 typed-events

README.md
[![agentmods](https://agentmods.dev/badge/skills/stephansama/packages/typed-events/github.svg)](https://agentmods.dev/skills/stephansama/packages/typed-events)
Your own site
<a href="https://agentmods.dev/skills/stephansama/packages/typed-events"><img src="https://agentmods.dev/badge/skills/stephansama/packages/typed-events/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for typed-events

Your own site · 80×15
<a href="https://agentmods.dev/skills/stephansama/packages/typed-events"><img src="https://agentmods.dev/badge/skills/stephansama/packages/typed-events.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 80 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,826 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00080 $0.01826
Opus 5.5 $0.00032 $0.00730
Sonnet 5.5 $0.00016 $0.00365
Haiku 4.5 $0.00008 $0.00183

Measured 1mo ago against content hash 7126183bb83d, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

typed-events 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 1mo 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.

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.

core/typed-events/skills/typed-events/SKILL.md · 256 lines

How it starts

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

typed-events

Typed, schema-validated wrappers for native browser event APIs. Each factory returns an object with dispatch() and listen() — listen() returns a cleanup function.

Choosing the right factory

Goal Use
Fire an event on the current page createEvent
Group related events under a namespace createEventMap
Sync state across browser tabs createBroadcastChannel
Fire locally AND across tabs simultaneously createBroadcastEvent
Send a message to an iframe or cross-origin window createMessage

Setup

import * as z from "zod";
import { createEvent } from "@stephansama/typed-events";

export const animationEvent = createEvent(
  "my-app:animation",
  z.object({ x: z.number(), y: z.number() }),
);

Core Patterns

Single validated CustomEvent

import * as z from "zod";
import { createEvent } from "@stephansama/typed-events";

export const clickEvent = createEvent(
  "my-app:click",
  z.object({ id: z.string() }),
);

// dispatch
clickEvent.dispatch({ id: "btn-1" });

// listen — store cleanup and call it when done
const cleanup = clickEvent.listen(({ data }) => {
  console.log(data.id);
});
// later:
cleanup();

Namespaced event map (group related events)

import * as z from "zod";
import { createEventMap } from "@stephansama/typed-events";

export const formEvents = createEventMap("form", {
  submit: z.object({ values: z.record(z.string()) }),
  reset: z.object({}),
});

formEvents.dispatch("submit", { values: { email: "[email protected]" } });

const cleanup = formEvents.listen("submit", ({ data }) => {
  console.log(data.values);
});

Event names are scoped internally as form:submit and form:reset.

Cross-tab sync with BroadcastChannel

import * as z from "zod";
import { createBroadcastChannel } from "@stephansama/typed-events";

export const tabChannel = createBroadcastChannel("my-app", {
  theme: z.object({ mode: z.enum(["light", "dark"]) }),
});

tabChannel.dispatch("theme", { mode: "dark" });

const cleanup = tabChannel.listen("theme", ({ data }) => {
  document.documentElement.dataset.theme = data.mode;
});

Read the full file on GitHub · 256 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. 1mo ago First seen · 256 lines · 80 tokens per session scan A 7126183bb83d

Subscribe to this mod's changes

typed-events is a skill published in the GitHub repository stephansama/packages (5 stars, last pushed yesterday), licensed MIT. It adds 80 tokens to every session and 1,826 once invoked, about $0.0003 per session on Opus 5.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-31.

Related

Other skills, from other repositories

psl-ast-layers

How to use the PSL syntax tree layers (green tree, red tree, strongly-typed AST classes) correctly. Use for any PSL-related work: PSL interpreters (contract-psl), helpers inside the psl-parser package, the language server, formatters, or anything else that consumes parse() output from @internal/psl-parser.

prisma/orm · 78 tokens

ast-visitor-pattern

Use the frozen-class/visitor pattern for discriminated unions that have multiple dispatch sites. Use when creating a new set of variants (commands, IR nodes, factory calls) that will be switched over in 2+ places, or when refactoring an existing union type that has grown multiple switch sites.

prisma/orm · 65 tokens

no-bare-casts

Writing as in TypeScript or TSX production code, modifying a file that contains a bare as cast, silencing a type error with a cast, encountering as unknown as, or reviewing a cast site.

prisma/orm · 52 tokens

bumping-biome

Bumps biome package versions (e.g. @biomejs/biome) using pnpm, aligns biome.jsonc files with the new version/s across the repository and runs biome-related checks. Use when required to update biome to a newer version - explicitly or implicitly (e.g. after running pnpm up, pnpm update, pnpm upgrade without specific…

prisma/orm · 96 tokens

migrate-oxfmt

Guide for migrating a project from Prettier or Biome to Oxfmt. Use when asked to migrate, convert, or switch a project's formatter from Prettier or Biome to Oxfmt.

oxc-project/oxc · 48 tokens

ax-cpp-ai

Use when writing C++ code with axllm for named deployment profiles, generic provider clients, model selection, OpenAI-compatible calls, Responses, Gemini, Anthropic, routers, and balancers.

ax-llm/ax · 47 tokens