/trogonstack-eventmodeling:eventmodeling-validating-event-modelsfrom trogonstack-eventmodeling
Validates event-sourced models for completeness and event sourcing purity: immutable events, deterministic projections, minimal per-command state. Run before code generation.
Ships in trogonstack-eventmodeling. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
CRITICAL: Every command must have its own minimal state projection (NOT a DDD Aggregate) What DDD calls an "aggregate root" is actually a READ MODEL. Command handlers must NEVER use read models for validation.
This is the primary validation gate. If a model violates this rule, it fails validation immediately.
VIOLATION EXAMPLE (WILL FAIL VALIDATION):
OrderAggregate { orderId, customerId, items[], total, status, paymentId, address, shippedAt, cancelledAt, ... }
↑ This is a READ MODEL, not command state
Used by: ConfirmOrder, ShipOrder, CancelOrder, ApproveReturn
REJECTED: This is DDD aggregate pattern (a read model), not event sourcing command state
CORRECT PATTERN (PASSES VALIDATION):
ConfirmOrderState { status, orderId }
ShipOrderState { status, orderId, paymentId }
CancelOrderState { status, orderId, createdAt }
ApproveReturnState { status, orderId, paymentId }
APPROVED: Each command has minimal state
OrderSummaryView { orderId, customerId, items[], total, status, paymentId, ... }
OK: This is a READ MODEL for UI queries, separate from command state
Ensures event-sourced models are complete, correct, and follow pure event sourcing principles (minimal per-command state).
When given an event model, perform comprehensive validation:
Verify each event stream has:
For each event:
For each state projection:
For each command:
Check against event sourcing fundamentals:
Events are Facts: Events describe what happened, not potential futures
Events are Immutable: No modification of event data
Complete Event Data: Events contain all facts needed for state rebuild
No Computed Fields in Events: Only raw captured facts
Deterministic Projections: Replaying events always produces same state
Stream Identity Clear: Stream name uniquely identifies entity
State is Derived: Current state always comes from replaying events
Verify that every command has explicit actor attribution from the Role Catalog:
Role Catalog exists: A Role Catalog was defined in Step 1 (eventmodeling-brainstorming-events)
Every command has actor attribution: No command uses generic "User"
CreateOrder attributed to "User" (which user? Customer? Admin? Seller?)CreateOrder attributed to "Customer" (specific role from catalog)Every human role has at least one command path: No orphaned roles
Every human role has at least one read model: Roles can see system state
Permission boundaries respected: Commands are only issued by authorized roles
OverrideOrderStatus not restricted to Support Agent roleValidation Verdict: If no Role Catalog exists → REJECT MODEL — Role Catalog is a prerequisite If any command lacks actor attribution → REJECT MODEL — all commands must have explicit role/actor
This is the PRIMARY validation gate. Violations are CRITICAL and must be fixed before approval. Validate that command decision state is minimal and command-specific, not bundled like DDD aggregates.
Note: Decision state is internal to each command handler. It is not a read model and should not appear as one on the board; only query read models do.
CRITICAL RULE CHECK:
Naming Convention Compliance - For automation tooling
OrderState (ambiguous - command? query?)ConfirmOrderState (clear: command state for ConfirmOrder)ShipOrderStateToDo (clear: planned, needs implementation)OrderQueryModel (clear: query read model)NO shared state between commands - This is the #1 rule
Each command has its own state interface - CRITICAL: Only one OrderState interface for all commands
No Full Aggregate State: Commands don't load all entity fields upfront
State Only For Validation: No unused fields in state
Per-Command State Shapes: Different interfaces for different commands
Validation Verdict: If ANY command shares state with another command → REJECT MODEL - CRITICAL VIOLATION
Draft → Confirmed (ConfirmOrder)
Draft → Cancelled (CancelOrder)
Confirmed → Shipped (ShipOrder)
Confirmed ↛ Draft (invalid)
PendingPayouts and PayoutsToRetry project the same events with the same fieldsFormat findings as:
# Event Model Validation Report: [Domain]
## Issues Found
### Critical (Must Fix)
1. **Stream Root**: Order
**Issue**: No command for order cancellation
**Impact**: Cannot model cancellation requirement
**Fix**: Add CancelOrder command with OrderCancelled event
2. **Event**: PaymentProcessed
**Issue**: Missing payment method in event data
**Impact**: Cannot determine if card declined, etc.
**Fix**: Add paymentMethod, authCode fields
3. **State Design**: Order stream
**Issue**: ConfirmOrder loads full OrderState with items[], shipping, etc.
**Impact**: Violates minimal state principle
**Fix**: ConfirmOrder should load only: { status, orderId }
### Warnings (Should Consider)
1. **Stream Root**: Order
**Issue**: Events contain computed total instead of raw amounts
**Recommendation**: Store line item amounts in event, compute total in read models
**Rationale**: Events are facts, computations belong in projections
2. **ReadModel**: CustomerDashboard
**Issue**: Denormalizes data from 3 stream roots
**Recommendation**: Ensure dashboard is truly for querying, not command validation
**Rationale**: Read models support UI queries, not decision logic
## Completeness Analysis
| Aspect | Status | Details |
|--------|--------|---------|
| Stream Roots | Complete | 5 stream roots identified |
| Commands | 80% | Missing: ReactivateAccount |
| Events | Complete | 18 events cover all transitions |
| State Designs | 70% | Several have unnecessary fields for validation |
| Read Models | Complete | 4 views cover query needs |
## Event Sourcing Compliance
- Immutable Events: 100%
- Minimal Command State: 75%
- Stream Root Clarity: Clear identities
- Event Sourcing Pattern: Follows ES principles
- CQRS Separation: Command state vs Read models clear
## Validation Summary
**Overall Status**: Ready with recommendations
**Blockers for Implementation**: 0 critical issues
**Recommended Fixes**:
1. Add missing OrderCancelled event
2. Move PaymentMethod to its own minimal state projection
3. Document all implicit invariants explicitly
**Ready for Code Generation**: Yes, after implementing recommendations
## Next Steps
1. Review recommendations with domain expert
2. Update model with critical fixes
3. Proceed to code generation
Provide a score for each dimension (0-100):
Overall: Ready for Implementation if all critical issues are resolved.
| Issue | Pattern | Fix |
|---|---|---|
| Missing cancellation flows | No "Cancelled" events | Add compensation paths |
| Implicit invariants | "Obviously can't do X" | Make invariants explicit |
| Command state too broad | Shared state used by 2+ commands | Split into per-command minimal state projections |
| Orphaned events | Events no one listens to | Link to projections or commands |
| No read models | Commands reading query/read models for validation | Add separate query read models; keep command state minimal |
| Circular dependencies | Projection A depends on B, B on A | Redesign stream boundaries |
Your event model validation is successful when:
A model is ready for code generation if:
[CommandName]State)[CommandName]State conventionWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
event-modeling, event-sourcing, model-validation, cqrs, domain-modeling
npx claudepluginhub trogonstack/agentskills --plugin trogonstack-eventmodeling16 skills in this plugin
/eventmodeling-applying-conways-lawStep 6 of Event Modeling - Apply Conway's Law with swimlanes. Organize events into autonomous system parts that different teams can independently own. Use after defining inputs/outputs. Do not use for: planning feature slice implementation order (use eventmodeling-slicing-event-models) or defining command/read model boundaries (use eventmodeling-designing-event-models)./eventmodeling-brainstorming-eventsStep 1 of Event Modeling - Brainstorm all domain events from requirements. Extract every state-changing event the system could have. Use when starting event modeling from requirements or a new domain. Do not use for: arranging events in sequence (use eventmodeling-plotting-events), designing commands or read models (use eventmodeling-designing-event-models), or when a complete event list already exists./eventmodeling-checking-completenessStep 8 of Event Modeling - Completeness Check. Verify every field has origin and destination. Ensure complete event model before code generation. Use after all scenarios defined. Do not use for: architectural validation against event sourcing principles (use eventmodeling-validating-event-models) or elaborating Given-When-Then specs (use eventmodeling-elaborating-scenarios).Other plugins' skills for the same job