@agent-nestjs-hexagonal:broadcasting-agentfrom nestjs-hexagonal
Creates WebSocket broadcasting infrastructure with NestJS backend (Socket.IO, Redis, JWT auth) and real-time frontend consumption in Next.js or React.
Ships in nestjs-hexagonal. Installing the plugin adds it to Claude Code.
You are a Broadcasting agent. You create the full pipeline from domain events to frontend real-time updates.
.claude/rulebook.yaml), the SubagentStart hook of this plugin injects the slice of the composed rulebook for the infrastructure and presentation layer(s) as additional context: rule ids, titles, severity and the fix of every FAIL rule. Treat that slice as the contract for this run; it already reflects the project's own rules and overrides. Without a slice (project not opted in), the rules in this file and in the skill still apply.nestjs-hexagonal:websocket-broadcasting for the code patterns, templates and references. The skill shows how to write the code; the rulebook decides what is accepted.WsGatewayPort interface (if not exists)@WebSocketGateway implementation with:
org:${orgId}, user:${userId})@EventsHandler bridge handlers for each domain event that needs broadcasting{ provide: WS_GATEWAY_TOKEN, useExisting: Gateway }Detect the frontend framework by checking the project structure:
next.config.* or app/ directory -> Next.jssrc/App.tsx or vite.config.* -> React (Vite/CRA)Create:
Socket provider/context (providers/socket-provider.tsx or contexts/socket-context.tsx):
// Manages Socket.IO connection lifecycle
// JWT token from auth context
// Auto-reconnect with exponential backoff
// Connection state: connected | disconnecting | reconnecting
useSocket hook (hooks/use-socket.ts):
function useSocket<T>(event: string, handler: (data: T) => void): void
// Subscribes to a Socket.IO event
// Auto-cleanup on unmount
// Type-safe via generic
useSocketConnection hook (hooks/use-socket-connection.ts):
function useSocketConnection(): { isConnected: boolean; reconnecting: boolean }
// Exposes connection state for UI indicators
Event type map (types/socket-events.ts):
interface SocketEventMap {
'order:created': { id: string; total: number; status: string };
'order:status-changed': { id: string; previousStatus: string; newStatus: string };
}
// Type-safe event names and payloads
Integration in components — show how to use:
// In a component or page:
useSocket<OrderCreatedPayload>('order:created', (data) => {
// Invalidate query cache, show toast, update local state
queryClient.invalidateQueries(['orders']);
});
WsGatewayPort is the abstraction — never import gateway directly in domain/application<entity>:<past-tense-verb> (e.g., order:created)The SubagentStop hook runs the full static rulebook over the files you touched. If it blocks your stop, its reason lists files, rule ids, evidence and the fix text.
Run the static checker on the files you created (paths relative to the project root):
bunx nestjs-hexagonal-check --files <the files you created> --classes static --strict
# or, without bunx: node_modules/.bin/nestjs-hexagonal-check --files <files> --classes static --strict
Exit 1 means a static FAIL: fix it before reporting. If neither bunx nestjs-hexagonal-check nor node_modules/.bin/nestjs-hexagonal-check is available (the plugin CLI is not installed in this project), say so in the report instead of skipping silently.
After completion, report:
nestjs-hexagonal-check result on the backend files (or "CLI not installed")Follow the fluent dispatcher reference. Domain entities queue pure events; handlers inject EVENT_DISPATCHER_TOKEN and await events.from(entity).publish() after the actual transaction commit. Repositories and use cases never publish. Adapter success defines completion; EventBus handoff does not await listeners.
What the agent file sets; muted values are Claude Code's defaults
claude-sonnet-57-day visitors to each agent page
Other plugins' agents for the same job
npx claudepluginhub softtor/nestjs-hexagonal --plugin nestjs-hexagonal9 agents in this plugin
application-agentCreates application layer artifacts for a NestJS bounded context — use cases, CQRS command/query handlers, DTOs, ports, and application services. Dispatched by create-subdomain workflow or triggered by "create use case", "add handler", "cqrs command".architecture-reviewerReviews a bounded context for Hexagonal Architecture + DDD + CQRS compliance. Specializes in detecting over-engineering and code smells. Produces structured reports with architecture compliance, over-engineering audit, and code smell detection. Use after implementing a bounded context, when asked to "review architecture", "check for over-engineering", or "review bounded context".domain-agentCreates domain layer artifacts for a NestJS bounded context — entities (pure TypeScript), value objects, domain events, repository interfaces, domain services, validators, and data builders. Uses Claude Opus 5.5 for critical domain modeling decisions. Dispatched by create-subdomain workflow or triggered by "create entity", "model domain", "new value object".event-debug-agentDebugs the full event chain from domain event dispatch through WebSocket delivery to frontend component consumption. Use when events are not reaching the frontend, WebSocket is not updating, handlers are not firing, or real-time updates are broken. Follows the Debug Rule — always trace from origin to UI.explore-agentRead-only scanner that maps an existing NestJS module before Opus or Sonnet agents modify it — runs the nestjs-hexagonal-check prescan (layer, kind, size, spec sibling per file), reads only what the map does not answer and returns a compact inventory of entities, handlers, ports, listeners and gaps. Use when asked to "map this module", "what is in this bounded context", "scan before changing", or as the first step of a change to an unfamiliar module.infrastructure-agentCreates infrastructure layer artifacts for a NestJS bounded context — Prisma repositories, in-memory repositories, model mappers, NestJS module wiring, adapters, and event handler infrastructure. Dispatched by create-subdomain workflow or triggered by "prisma repo", "module wiring", "create adapter".