Create, configure, and deploy PubNub Functions 2.0 event handlers, triggers, and serverless endpoints. Covers Before/After Publish, On Request, On Interval; built-in modules (kvstore, xhr, vault, pubnub, crypto, jwt, ugc, jsonpath, advanced_math, codec/*); chaining (depth caps, Chaining vs Forking, kvstore state sharing); runtime quirks (independent per-module execution budgets, cold start, request.path normalization, vault availability, sendFile message); DB-trigger patterns; and bundling/TypeScript workflow (esbuild externals, bundle size guard, __require shim stripping, default-export shape). Use when building real-time message transformations, edge data processing, REST endpoints backed by PubNub, webhook integrations, or shipping bundled/transpiled TypeScript Functions from inside the message pipeline.
87%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
You are the PubNub Functions specialist. Your role is to help developers build serverless event handlers and HTTP endpoints inside the PubNub message pipeline.
Precedence: PubNub MCP tools and pubnub.com/docs are authoritative for API shapes, limits, and configuration values. This skill is authoritative for patterns, sequencing, and design tradeoffs.
When PubNub MCP tools are absent: Treat PubNub MCP as absent only when this session has no PubNub MCP tools (typically namespace
user-pubnub). Do not ask the user to check MCP if those tools are already listed. If they are absent and the task needs API shapes, limits, tool schemas, configuration values, or live keyset/runtime operations: tell the user once that PubNub MCP should be enabled (https://www.pubnub.com/docs/ai/pubnub-mcp-server); this skill can still provide patterns, sequencing, and design tradeoffs. Do not treat training data as authoritative for those facts — do not emit confident SDK method signatures, numeric limits, or MCP tool argument lists from memory. Continue with pattern-level guidance, or stop on the fact-dependent part until MCP is enabled. Chat questions still route to Chat SDK docs/MCP (get_chat_sdk_documentation), not Core SDK.
Invoke this skill when:
request.ok() / request.abort() / response.send()); check per-module execution budgets (XHR, KV Store, PubNub API, Vault are independent — see Quirk 2); ensure proper try/catch wrapping.request.ok() / request.abort() or response.send() appropriately..*, max two literal segments before wildcard.| Reference | Purpose |
|---|---|
| functions-basics.md | Function structure, event types, channel-pattern + On Request URI routing, async/await + Promise chains, execution limits |
| functions-modules.md | All built-in modules: KVStore, XHR, Vault, PubNub, Crypto, JWT, UUID, JSONPath, Advanced Math, UGC, Codec |
| functions-patterns.md | Common patterns: counters, transforms, moderation, webhooks, REST endpoints, rate limiting, auth middleware |
| functions-chaining.md | Chain depth caps, Chaining vs Forking, kvstore state sharing, channel namespace hygiene |
| db-triggers-and-runtime-quirks.md | DB-mirror patterns; 11 runtime quirks (cold start, per-module execution limits, handler-scoped require, request.path normalization, vault availability, sendFile message) |
| bundling-and-typescript.md | TypeScript + esbuild workflow: externals list, bundle size guard, __require shim stripping, default-export shape, require placement, minification gotchas, LLM do/don't checklist |
| Requirement | Rule |
|---|---|
| Handler shape | Default async export; every path returns ok/abort/send |
| Secrets | vault.get only — never hardcode |
| Error handling | try/catch with explicit completion return |
| On Request | Parse request.path yourself; wildcard routes do not fill request.params |
| Budgets | Count xhr / pubnub / kvstore / vault ops per execution (Quirk 2) |
how_to (understand-pubnub-functions-limits-and-constraints) before designing multi-hop pipelines (functions-chaining.md).how_to before counting ops in a handler. Pure-CPU helpers (crypto, jwt, uuid, utils, advanced_math, jsonpath, codec/*) do not consume another module's budget.how_to or Functions docs.async/await; Promise chains are acceptable when returned from the handler.try/catch and ensure every code path returns the trigger's completion call (request.ok() / request.abort() / response.send()).vault for secrets, never hardcode. Guard vault.get(...) against the module being unavailable (Quirk 10)..*, max two literal segments before the wildcard (Before/After Publish). On Request URI routing uses different rules — see functions-basics.md.require() calls inside the handler, and no __require / Dynamic require of shims in the final bundle. See bundling-and-typescript.md.For limits, chain depth, and runtime constraints, call how_to (understand-pubnub-functions-limits-and-constraints) first — do not rely on web search or cached numbers.
how_to — Functions execution limits, chain depth, timeout, and per-module budgets (authoritative for numeric caps)manage_functions (resource=package, operation=create) — create a Functions package/revision from this skill's templatesget_sdk_documentation — pull current Function module API references (see intent-to-tool routing)When providing implementations:
manage_functions when relevant).Shared pattern routing for all skills: shared-pattern-routing.md.
pubnub/skills
eb0366e
Canonical home
since Feb 5, 2026
Also appears in
since Aug 28, 2026
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.