Nonblocking post connect capability broadcast

From ychampion/cskill-agents · View interactive version

Nonblocking post connect capability broadcast is an AI agent skill from the GitHub repository ychampion/cskill-agents. Commit the connected state first, then gather optional capabilities and send a post-connect broadcast asynchronously without delaying readiness.

How to use this skill

Skill file

SKILL: Nonblocking Post-Connect Capability Broadcast

Domain: bridge-lifecycle

Trigger: Apply when a transport has reached its ready or connected state, but optional capability discovery and hello metadata still need to be broadcast to the remote peer.

Source Pattern: Distilled from reviewed bridge-lifecycle, capability-broadcast, and reconnect-flow implementations.

Core Method

Treat connection visibility and capability advertisement as two separate phases. In the state-change handler, synchronously commit the host's connected/session-active flags first so the UI and downstream effects can react immediately. Only after that state commit should you launch a detached async task that resolves optional capabilities, re-checks cancellation or liveness, snapshots any current state needed for the payload, and sends the post-connect broadcast. Keep the late path best-effort: if capability loading or broadcast assembly fails, log it locally and leave the connection marked ready.

Key Rules

Example Application

When a mobile or web client connects to a background bridge, flip the app state to connected immediately so forwarding and UI badges start right away. Then, in a detached async block, load the bridge-safe skill list, collect the latest runtime metadata, and send one system/init message. If that late load fails, record the error, but do not bounce the session back out of connected.

Anti-Patterns (What NOT to do)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.