event-driven-design
Skill6 starsChanged 6 months agoMITView on GitHub
When designing loosely coupled systems that react to state changes asynchronously.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- kayaman/skillstheir own version, first seen Mar 7, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- kayaman/skills★ 3same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository13 other files it gives its agents.
- caching-strategiesSkill
- logging-observability-standardsSkill
- api-design-restSkill
- database-query-optimizationSkill
- error-handling-architectureSkill
- code-review-guidelinesSkill
- ci-cd-pipeline-architectureSkill
- debugging-strategiesSkill
- git-workflow-branchingSkill
- dom-security-hardeningSkill
- react-component-designSkill
- state-management-patternsSkill
- accessibility-ui-designSkill
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 11 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈11
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 52
Idempotent Consumers: Ensure consumer services can process the same event multiple times without adverse side effects
- Distinctive: line 54
Track Processing: Add idempotency keys or processed event IDs to detect duplicates
- Very specific: line 58
MUST model events as immutable facts (past tense: OrderPlaced not PlaceOrder)
- Distinctive: line 59
MUST NEVER modify or delete events once emitted (audit trail requirement)
- Distinctive: line 60
MUST make consumers idempotent (same event processed multiple times = same outcome)
- Distinctive: line 61
MUST avoid deeply nested, rapidly changing entity graphs in payloads
- Distinctive: line 62
MUST include Event ID, Timestamp, Event Type in all events
- Distinctive: line 63
MUST implement Dead Letter Queues for failed events
- Distinctive: line 64
MUST NOT use synchronous HTTP calls as part of event workflows
- Distinctive: line 72
Event Loss: Not persisting events to broker.
- Distinctive: line 77
No Dead Letter Queue for failed events
- Distinctive: line 96
Consumer pattern: Read event, validate idempotency key, process, mark as processed
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Event-Driven Design
Purpose
Tightly coupled systems break and scale poorly. Event-driven architectures decouple producers from consumers by using immutable, timestamped facts as the communication mechanism. This enables systems to evolve independently, scale horizontally, and handle distributed failures gracefully.
When to use
- De-coupling monolithic microservices
- Implementing long-running asynchronous workflows (e.g., video processing, email sending)
- Triggering multiple side-effects across different domains from a single action
- Designing systems that need to replay history or audit changes
When NOT to use
- Simple synchronous request-response flows (don't add unnecessary complexity)
- Real-time bidirectional communication (use WebSockets instead)
- Workflows requiring immediate response to action
Inputs required
- Microservices or monolithic application with clear domain boundaries
- Message broker infrastructure (Kafka, RabbitMQ, EventBridge, etc.)
- Understanding of event sourcing concepts
Workflow
- Define Events: Identify state changes in the domain and model them as past-tense events (e.g.,
OrderPlaced,UserRegistered,PaymentProcessed) - Design Event Payloads: Include Event ID, Timestamp, Event Type, and minimal required data (avoid large nested objects)
- Publishing Mechanism: Have the producer system emit the event to a Message Broker without caring who consumes it
- Idempotent Consumers: Ensure consumer services can process the same event multiple times without adverse side effects
- Handle Failures: Implement Dead Letter Queues (DLQ) for events that consumers repeatedly fail to process
- Track Processing: Add idempotency keys or processed event IDs to detect duplicates
- Monitor: Set up alerts for DLQ messages and processing delays
Rules
- MUST model events as immutable facts (past tense:
OrderPlacednotPlaceOrder) - MUST NEVER modify or delete events once emitted (audit trail requirement)
- MUST make consumers idempotent (same event processed multiple times = same outcome)
- MUST avoid deeply nested, rapidly changing entity graphs in payloads
- MUST include Event ID, Timestamp, Event Type in all events
- MUST implement Dead Letter Queues for failed events
- MUST NOT use synchronous HTTP calls as part of event workflows
Anti-patterns
- Commands as Events: Naming events like actions (
SendEmailEvent) rather than facts (UserCreated) - Distributed Monolith: Systems requiring synchronous HTTP calls in response to an event before completing their workflow
- Huge Event Payloads: Sending entire entity graphs; include only IDs and essential context
- No Idempotency: Processing events without tracking duplicate processing
- Synchronous Dependencies: Event handler blocks waiting for another service response
- Event Loss: Not persisting events to broker; memory-only event storage
Failure conditions
- Events cannot be replayed (no persistence)
- Consumers not idempotent (duplicates cause data corruption)
- No Dead Letter Queue for failed events
- Synchronous dependencies between event producers and consumers
- Event payloads change format without versioning support
Validation checklist
- All events named as past-tense facts (not commands)
- Events are immutable after emission
- Event payloads include ID, Timestamp, Type
- Consumers are idempotent (can process same event multiple times safely)
- Dead Letter Queue configured and monitored
- No synchronous HTTP dependencies in event handlers
- Event versioning strategy defined
- Idempotency keys tracked (to detect duplicates)
- Monitoring/alerting on DLQ messages
- Event processing latency within SLA
Output format
- Event schema: Event ID, Timestamp, Type, Payload (minimal data)
- Payload format: JSON with primitive types, IDs, not full objects
- Consumer pattern: Read event, validate idempotency key, process, mark as processed
- Infrastructure: Message broker setup with persistence and DLQ
- Monitoring: Dashboards for event processing latency and DLQ depth
Security considerations
- Event payloads MUST NOT contain credentials or PII
- Access control MUST be enforced at consumer (not all services can listen to all events)
- Event encryption MUST be used for sensitive domains
- Audit logging MUST track who published and consumed events
- Dead Letter Queues MUST be monitored (may contain sensitive data)
Agent execution notes
- Agent MAY: Define events, create event handlers, implement idempotency, set up DLQ
- Agent MUST NEVER: Use commands instead of events, create synchronous dependencies, lose events
- Agent MUST ASK: Before adding new event types, before changing event schema, before removing DLQ
- Agent MUST VALIDATE: Events are facts not commands, consumers are idempotent, DLQ configured
Example
❌ Anti-pattern (Commands as events, synchronous coupling, no idempotency):
// WRONG: Command not event
publishEvent('SendEmail', { userId, subject });
// WRONG: Synchronous dependency
async function handleOrderPlaced(event) {
const order = await orderService.fetch(event.orderId); // Blocks on external service
await emailService.send(order.email); // Fails if service is down
}
// WRONG: No idempotency tracking - processes duplicate
async function handleUserCreated(event) {
await database.createUser(event); // Processes same event twice = duplicate user
}✅ Correct pattern (Events, async, idempotent):
// CORRECT: Past-tense event with minimal payload
publishEvent({
type: 'UserCreated',
id: uuid(),
timestamp: new Date(),
payload: {
userId: event.userId,
email: event.email
}
});
// CORRECT: Asynchronous, idempotent consumer
async function handleUserCreated(event) {
// 1. Track processed events (idempotency)
const alreadyProcessed = await cache.get(`processed:${event.id}`);
if (alreadyProcessed) return; // Skip duplicate
// 2. Process without waiting for external services
await emailQueue.enqueue({
email: event.payload.email,
template: 'welcome'
});
// 3. Mark as processed
await cache.set(`processed:${event.id}`, true, { ttl: 86400 });
}
// 4. Dead Letter Queue for failed events
async function handleFailedEvent(event, error) {
await dlq.store({
originalEvent: event,
error: error.message,
timestamp: new Date(),
retryCount: 0
});
}Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

