EM

emitting-api-events

Implement event-driven patterns in your API, including webhook delivery, Server-Sent Events, and event sourcing.

Install

mkdir -p .claude/skills/emitting-api-events && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/3841" && unzip -o skill.zip -d .claude/skills/emitting-api-events && rm skill.zip

Installs to .claude/skills/emitting-api-events

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Build event-driven APIs with webhooks, Server-Sent Events, and real-time
72 charsno explicit “when” trigger
Advanced

Key capabilities

  • Identify event-producing API operations
  • Define versioned event schemas for API events
  • Implement an event emitter service with transactional outbox pattern
  • Build a webhook subscription management API
  • Configure webhook delivery with HMAC-SHA256 signed payloads and retry policy
  • Add Server-Sent Events endpoint for real-time delivery

How it works

The skill guides building event-driven APIs by identifying event-producing operations, defining schemas, implementing an event emitter with a transactional outbox, and managing webhook subscriptions and Server-Sent Events.

Inputs & outputs

You give it
API mutation operations (POST, PUT, PATCH, DELETE), event type names, event schemas, and subscriber webhook URLs.
You get back
Event-driven API architecture with emitted events, webhook subscriptions, and real-time notifications.

When to use emitting-api-events

  • Implement outbound webhooks for API state changes
  • Setup Server-Sent Events for real-time notifications
  • Create event-driven audit logs for API operations
  • Build subscriber management for event delivery

About this skill

Emitting API Events

Overview

Build event-driven API architectures using outbound webhooks, Server-Sent Events (SSE), and message broker integration. Implement event emission from API mutations, event schema registry, subscriber management, delivery guarantees with retry logic, and event sourcing patterns for maintaining a complete audit log of API state changes.

Prerequisites

  • Message broker: Redis Pub/Sub, RabbitMQ, Apache Kafka, or AWS SNS/SQS
  • Persistent storage for event log and subscriber registrations (PostgreSQL, MongoDB)
  • Webhook delivery infrastructure with retry queue (Bull, Celery, or managed service)
  • Event schema registry for versioned event type definitions
  • SSE-capable web framework for real-time event streaming to browser clients

Instructions

  1. Identify event-producing operations using Grep and Read, cataloging every API mutation (POST, PUT, PATCH, DELETE) that should emit events, with event type names following resource.action convention (e.g., order.created, user.updated).
  2. Define event schemas for each event type with versioning: include eventId (UUID), eventType, version, timestamp (ISO 8601), source (service identifier), and data (type-specific payload).
  3. Implement the event emitter service that publishes events to the message broker after successful API mutations, using the transactional outbox pattern to ensure events are not lost on application crash.
  4. Build a webhook subscription management API: POST /webhooks (subscribe), GET /webhooks (list), DELETE /webhooks/:id (unsubscribe), with URL validation, event type filtering, and signing secret generation.
  5. Implement webhook delivery with HMAC-SHA256 signed payloads, configurable retry policy (exponential backoff: 1min, 5min, 30min, 2hr, 24hr), and automatic subscription deactivation after consecutive failures.
  6. Add Server-Sent Events endpoint (GET /events/stream) for real-time event delivery to browser clients, with Last-Event-ID support for reconnection and missed event replay.
  7. Create a dead-letter queue for events that exhaust all delivery retry attempts, with alerting and manual replay capability.
  8. Write integration tests covering event emission, webhook delivery with signature verification, SSE stream connection with reconnection, and dead-letter queue behavior.

See ${CLAUDE_SKILL_DIR}/references/implementation.md for the full implementation guide.

Output

  • ${CLAUDE_SKILL_DIR}/src/events/emitter.js - Event emission service with outbox pattern
  • ${CLAUDE_SKILL_DIR}/src/events/schemas/ - Versioned event type schema definitions
  • ${CLAUDE_SKILL_DIR}/src/events/webhooks/ - Webhook delivery, signing, and retry logic
  • ${CLAUDE_SKILL_DIR}/src/events/sse.js - Server-Sent Events streaming endpoint
  • ${CLAUDE_SKILL_DIR}/src/routes/webhooks.js - Webhook subscription management API
  • ${CLAUDE_SKILL_DIR}/src/events/dead-letter.js - Dead-letter queue handler with replay
  • ${CLAUDE_SKILL_DIR}/tests/events/ - Event emission and delivery integration tests

Error Handling

ErrorCauseSolution
Event lost on crashApplication crashes between database commit and event publishUse transactional outbox pattern: write event to outbox table in same transaction, poll and publish separately
Webhook delivery failureSubscriber endpoint unreachable or returns non-2xxRetry with exponential backoff; deactivate subscription after 5 consecutive failures; notify subscriber admin
Event ordering violationConcurrent mutations publish events out of orderUse partition keys (resource ID) for ordered delivery within a partition; accept out-of-order across partitions
SSE connection memory leakServer accumulates stale SSE connections without cleanupImplement heartbeat comments (:keepalive\n\n) every 15 seconds; detect and close dead connections
Schema version mismatchConsumer expects v1 event format but receives v2Include version field in event envelope; support simultaneous v1/v2 delivery; deprecate old versions with notice

Refer to ${CLAUDE_SKILL_DIR}/references/errors.md for comprehensive error patterns.

Examples

Order lifecycle events: Emit order.created, order.payment_received, order.shipped, and order.delivered events with order details, enabling downstream services (warehouse, email, analytics) to react asynchronously.

SSE live notifications: Browser client connects to GET /events/stream?types=message.received,order.updated and receives real-time event updates with automatic reconnection and Last-Event-ID replay on network interruption.

Transactional outbox: Write the event record to an outbox table within the same database transaction as the API mutation, then poll the outbox table every 100ms to publish events to Kafka, ensuring at-least-once delivery.

See ${CLAUDE_SKILL_DIR}/references/examples.md for additional examples.

Resources

When not to use it

  • When a message broker is not available
  • When persistent storage for event logs is not available

Prerequisites

Message brokerPersistent storage for event log and subscriber registrationsWebhook delivery infrastructure with retry queueEvent schema registry for versioned event type definitions

Limitations

  • Event ordering may be violated across partitions if not using partition keys

How it compares

This approach provides a structured method for emitting API events with delivery guarantees and real-time streaming, contrasting with simple API responses that lack event logging, retry mechanisms, or subscriber management.

Compared to similar skills

emitting-api-events side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
emitting-api-events (this skill)126dReviewAdvanced
webapp-testing3533moReviewIntermediate
resolve-conflicts818moReviewIntermediate
telegram-bot-builder1066moReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

More by jeremylongshore

View all by jeremylongshore

analyzing-logs

jeremylongshore

Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.

14123

ollama-setup

jeremylongshore

Configure auto-configure Ollama when user needs local LLM deployment, free AI alternatives, or wants to eliminate hosted API costs. Trigger phrases: "install ollama", "local AI", "free LLM", "self-hosted AI", "replace OpenAI", "no API costs". Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

1167

backtesting-trading-strategies

jeremylongshore

Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".

1071

generating-database-seed-data

jeremylongshore

Process this skill enables AI assistant to generate realistic test data and database seed scripts for development and testing environments. it uses faker libraries to create realistic data, maintains relational integrity, and allows configurable data volumes. u... Use when working with databases or data models. Trigger with phrases like 'database', 'query', or 'schema'.

1033

cursor-codebase-indexing

jeremylongshore

Execute set up and optimize Cursor codebase indexing. Triggers on "cursor index setup", "codebase indexing", "index codebase", "cursor semantic search". Use when working with cursor codebase indexing functionality. Trigger with phrases like "cursor codebase indexing", "cursor indexing", "cursor".

885

testing-mobile-apps

jeremylongshore

Execute mobile app testing on iOS and Android devices/simulators. Use when performing specialized testing. Trigger with phrases like "test mobile app", "run iOS tests", or "validate Android functionality".

810

You might also like

webapp-testing

anthropics

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

353585

resolve-conflicts

antinomyhq

Use this skill immediately when the user mentions merge conflicts that need to be resolved. Do not attempt to resolve conflicts directly - invoke this skill first. This skill specializes in providing a structured framework for merging imports, tests, lock files (regeneration), configuration files, and handling deleted-but-modified files with backup and analysis.

81334

telegram-bot-builder

davila7

Expert in building Telegram bots that solve real problems - from simple automation to complex AI-powered bots. Covers bot architecture, the Telegram Bot API, user experience, monetization strategies, and scaling bots to thousands of users. Use when: telegram bot, bot api, telegram automation, chat bot telegram, tg bot.

106130

dev-browser

SawyerHood

Browser automation with persistent page state. Use when users ask to navigate websites, fill forms, take screenshots, extract web data, test web apps, or automate browser workflows. Trigger phrases include "go to [url]", "click on", "fill out the form", "take a screenshot", "scrape", "automate", "test the website", "log into", or any browser interaction request.

53176

openspec-onboard

studyzy

Guided onboarding for OpenSpec - walk through a complete workflow cycle with narration and real codebase work.

10207

codex-cli-bridge

alirezarezvani

Bridge between Claude Code and OpenAI Codex CLI - generates AGENTS.md from CLAUDE.md, provides Codex CLI execution helpers, and enables seamless interoperability between both tools

9180

Search skills

Search the agent skills registry