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.
التثبيت
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
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.
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.
const pubnub = newPubNub({
publishKey: process.env.PN_PUBLISH_KEY,
subscribeKey: process.env.PN_SUBSCRIBE_KEY,
userId: getUserId() // REQUIRED — must be persistent per user
});
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).