# Craft Event Driven Model

> Crafting Event-Driven Models. Side effects via observers.

- Skill: `attac-t/craft-event-driven-model` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add attac-t/craft-event-driven-model`
- Raw SKILL.md: https://api.skillmd.com/api/skills/attac-t/craft-event-driven-model/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: attac-t (https://skillmd.com/u/attac-t)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/attac-t/craft-event-driven-model

---


# Skill: Craft Event-Driven Model

> "Models emit events. Subscribers handle consequences."

## The Standard

1. **Dispatch Domain Events**: `$dispatchesEvents` maps model events to domain events.
2. **Subscribers Handle Logic**: Calculations, notifications, logging—outside the model.
3. **Keep Models Thin**: Model changes state. Events trigger side effects.
4. **Test Events Separately**: Model tests don't test subscriber behavior.

## The Anti-Patterns

| ❌ Don't                  | ✅ Do                          | Why                        |
|--------------------------|-------------------------------|----------------------------|
| Logic in `boot()`        | Event + Subscriber            | Testable, traceable        |
| Direct method calls      | Dispatch event                | Loose coupling             |
| Fat model observers      | Focused subscribers           | Single responsibility      |
| Skip event for "simple"  | Always event for side effects | Consistency                |

## Real-World Examples

See [examples.md](examples.md).

