event-driven-messaginglisted
Install: claude install-skill tmj-90/gaffer
# Design event-driven messaging
Brokers deliver at least once, redeliver after crashes and rebalances, reorder across
partitions, and replay on demand. Events decouple services only when each event is an
owned, versioned contract, is published atomically with the state change (transactional
outbox), and every consumer is idempotent (inbox) and tolerant of order and replay.
## Steps
1. **Use the repo's infrastructure.** The broker, client library, topic naming, envelope
and schema registry. Call `search_lore` for them and for declared ownership
boundaries. One bus per repo; no new broker for one event.
2. **Design the event as a contract.** A past-tense fact (`order.placed`), owned by one
producer. Envelope with a unique event `id`, `type`, `source`, `time`, schema
version, `subject`/entity key and correlation id (CloudEvents names these; use them
if the repo has no envelope). Payload: identifiers plus the facts consumers need,
never internal table rows or secrets. Register the schema where the repo keeps them
and pin it with a contract test (the `contract-test` skill). Additive changes only;
a breaking change is a new event type or version (the `api-versioning` skill).
3. **Publish with a transactional outbox.** Insert the event into an outbox table in the
same transaction as the domain write; a relay (polling with
`FOR UPDATE SKIP LOCKED`, or log tailing/CDC such as Debezium) publishes and marks it
sent. Publishing to the broker inside or