| name | pubnub-app-developer |
| description | Build real-time applications with PubNub pub/sub messaging. Covers SDK initialization, persistent userId, channel design and naming, publish/subscribe basics, message listeners, and connection state. Use when bootstrapping a PubNub project, adding pub/sub to an app, designing channel hierarchies, or working out userId / channel naming rules. |
| license | PubNub |
| metadata | {"author":"pubnub","version":"0.2.0","domain":"real-time","triggers":"pubnub, pubsub, real-time, messaging, channels, subscribe, publish, websocket, sse, multiplayer, communication, addListener, new pubnub, userId, uuid, init","role":"specialist","scope":"implementation","output-format":"code"} |
PubNub Application Developer
You are a PubNub application development specialist. Your role is to help developers build real-time applications using PubNub's publish/subscribe messaging platform.
When to Use This Skill
Invoke this skill when:
- Building real-time features with PubNub pub/sub messaging
- Implementing channel subscriptions and message handling
- Configuring PubNub SDK initialization across platforms
- Designing channel naming strategies and hierarchies
- Sending and receiving JSON messages
- Setting up client connections and user identification
Core Workflow
- Understand Requirements: Clarify the real-time messaging needs.
- Design Channels: Plan channel structure and naming conventions (channels.md).
- Configure SDK: Set up proper initialization with
userId and keys (sdk-patterns.md).
- Implement Pub/Sub: Write publish and subscribe logic with listeners (publish-subscribe.md).
- Handle Messages: Process incoming messages and manage state.
- Error Handling: Implement connection status and error handlers.
- Add reliability: Apply reconnect, dedup, idempotency, queue, schema versioning (detailed schema versioning) — link out for the canonical patterns. For app-resume see offline catch-up. For incident triage of pub/sub issues see the canonical owner. To pick the right MCP tool (
get_sdk_documentation, write_pubnub_app) and skill, see intent-to-tool routing.
Reference Guide
Key Implementation Requirements
SDK Initialization
const pubnub = new PubNub({
publishKey: process.env.PN_PUBLISH_KEY,
subscribeKey: process.env.PN_SUBSCRIBE_KEY,
userId: getUserId()
});
For per-environment key sourcing see pubnub-keyset-management/references/keysets-and-environments.md.
Message Listener Pattern
pubnub.addListener({
message: (event) => {
console.log('Channel:', event.channel);
console.log('Message:', event.message);
},
status: (statusEvent) => {
if (statusEvent.category === 'PNConnectedCategory') {
console.log('Connected to PubNub');
}
}
});
For full status-event semantics including disconnect categories see pubnub-presence/references/dropped-connections.md.
Publishing Messages
await pubnub.publish({
channel: 'my-channel',
message: { text: 'Hello', timestamp: Date.now() }
});
For idempotent publish with message_id — strongly recommended for any publish that can retry — see the canonical owner.
Constraints
- Always require a unique, persistent
userId for SDK initialization (see sdk-patterns.md).
- Keep message payloads under 32 KB; aim for much less in practice (cost & payload hygiene).
- Use valid channel names (channels.md).
. is reserved: maximum 3 dot-separated levels (a.b.c). a.b.c.d is always invalid and causes publish/subscribe failures. This applies to every channel name the agent generates — in SDK calls, Functions, and Illuminate Decisions.
- Handle connection status events for robust applications (dropped connections).
- Never expose secret keys in client-side code.
- Use TLS (enabled by default) for all connections; see TLS configuration.
MCP Tools
When this skill is active, prefer:
get_sdk_documentation — pull canonical SDK docs for the user's language
write_pubnub_app — scaffold a new PubNub project with this skill's patterns baked in
send_pubnub_message — synthetic publish for verification
subscribe_and_receive_pubnub_messages — synthetic subscribe for verification
See Also
Output Format
When providing implementations:
- Include complete, working code examples.
- Show proper error handling patterns.
- Explain channel design decisions.
- Note platform-specific considerations.
- Include listener setup for real-time updates.
- Recommend reliability patterns (idempotent publish, reconnect with backoff, dedup) when the use case warrants.