/mermaid-event-model:add-slicesfrom mermaid-event-model
Reads an Event Model DSL file and rewrites slice declarations from scratch based on current edges. Classifies each slice into one of four canonical patterns — Command, View, Automation, Translation — and flags non-conforming slices. Also detects model defects like mixed-system read sides and orphan events.
Ships in mermaid-event-model. 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.
You are analyzing an Event Model DSL file and writing slice declarations that group its edges into vertical slices, following the four canonical Event Modeling patterns.
Read the DSL file at: $ARGUMENTS
If no argument is provided, default to blueprint_dsl.md in the project root.
DSL files are markdown. Each is a .md file whose DSL lives inside a fenced ```mermaid block whose first content line is eventModel. When you parse the file, look at the lines INSIDE that fence. When you write the new slice declarations, write them INSIDE the same fence. Don't add markdown content outside the fence and don't move the fence boundaries.
In Event Modeling a vertical slice is a cohesive unit of behavior cutting across the horizontal timeline — one user-visible capability from trigger to outcome. Per eventmodeling.org's cheat sheet, a slice is the smallest possible unit of work that can be handed to a developer, and there are exactly four canonical patterns:
Trigger → Command → Event(s). Describes a state change "from the start (what is the trigger?) to the end (what is the state change?)." The trigger is a ui — a user acting on the system.Event(s) → View, optionally extended to a consuming ui. The view is our readModel.Event(s) → View → Automated Trigger → Command → Event(s). Use it "whenever the system should do something automatically." The automation monitors a view — "a simple todo list" — and triggers commands per row. It holds no business logic: "the automation works the same way as a user would use the system."Two consequences drive the algorithm:
readModel → automation → command → event(s) one cohesive unit of work. Note this covers the readModel → automation edge only; the event → readModel edges that populate the view are separate slices, for the reason given under "Slice granularity" below.externalEvent, so it is the sole discriminator: a slice with the Automation shape whose read side is fed by an externalEvent is a Translation; one whose read side is entirely domainEvents is an Automation.Real models frequently omit the View and the Automated Trigger, wiring an event straight into a command: Event(s) → Command → Event(s). Classify these as the pattern they would be with the middle restored — Translation when the source is an externalEvent, Automation when it is a domainEvent — and tag them [abbreviated] in the report so the deviation stays visible.
The elided View and Trigger carry no code of their own, so code generation is unaffected. What matters is that such a slice is not mistaken for a Command Pattern, whose trigger is a user. That distinction is the whole point of classifying: a translation and a user-initiated command produce completely different blueprints — an inbound listener versus an API endpoint.
externalEvent marks the source side only. A slice that translates our events outward into another system is structurally indistinguishable from an Automation and will be classified as one. If a slice's command name implies an outbound call, say so in the report — but do not guess, and do not invent a marker for it.
A slice is the unit of incremental regeneration — the intended workflow is an agent that regenerates only the slices a model change touched. That makes the slice boundary the blast radius of every change, and it is the criterion behind every grouping decision below: a slice is the smallest set of edges that must change together.
This is why the events feeding an automation's view are a separate View slice rather than part of the automation slice. A projection handler and the automation that reads its output change for entirely different reasons — bundling them means editing the automation's trigger regenerates projection handlers that did not change, and editing one projection regenerates the automation.
But blast radius applies to the generated handler, not to the slice. An earlier version of this skill split a fan-in read model into one slice per incoming event, reasoning that a schema change to one event should dirty one handler. That granularity is right; locating it at the slice boundary is not. A projection is a fold over all of its inputs, so a per-event slice cannot state its own behaviour: a test for "Room Booked marks these nights unavailable" needs the rows that "Availability Rolled" seeded, an event belonging to a sibling slice that the split slice declares no relationship to. Compare a Command slice, whose Given is exactly its declared reads [...] set — principled, because the dependency is in the DSL. A per-event View slice has a real dependency with nothing to declare it.
So: the slice is the unit of specification, the handler is the unit of regeneration. One View slice may emit sixteen projection handlers and still regenerate them independently — the generator can diff at handler granularity inside a slice. Splitting the specification to match the code was the error.
What stays together: the automation's readModel → automation → command → event(s) chain is a single slice, because an automation exists in order to issue its command. Changing the condition and changing the command it issues are nearly always the same change.
The slice grammar has no slot for a pattern and must not grow one. A hand-authored pattern tag would let a model author assert something the edges contradict. The classification is a derived fact — recomputed from the edges whenever it is needed, and recorded downstream (in slice spec files) rather than in the model.
This skill is idempotent. On every run:
Strip every existing slice declaration from the DSL. Each existing block contributes its indented --> edges back to the global edge set as bare edges. After this step the mermaid block contains only element declarations and bare edges.
Classify every edge by its (source-kind, target-kind) pair:
| Source kind | Target kind | Bucket |
|---|---|---|
ui | command | command-side |
automation | command | command-side |
domainEvent | command | command-side (event-triggered translator command) |
externalEvent | command | command-side (external trigger) |
command | domainEvent | command-side |
domainEvent | readModel | read-side |
externalEvent | readModel | read-side |
readModel | ui | read-side |
readModel | automation | read-side (input to an Automation Pattern) |
Edges that don't match any row are unclassified — surface them to the user but don't try to slice them.
Identify Automation and Translation Patterns first. For every automation that has BOTH at least one incoming readModel → automation edge AND at least one outgoing automation → command edge, claim a single slice containing:
readModel → automation edge for that automation.automation → command edge from this automation.command → domainEvent edge produced by those commands.Do NOT claim the event → readModel edges feeding the input read model. Those become their own View slices in step 4. The canonical drawing shows Event(s) → View → ..., but the projections that populate the view change independently of the automation that reads it — see "Slice granularity" below.
Then classify it by its read side. Because the feeding edges now live in separate slices, resolve them against the whole model, not just this slice: find the automation's input read model, collect every event → readModel edge targeting it anywhere in the DSL, and check those events' kinds. Translation if any is an externalEvent, Automation if all are domainEvents. (If both, that is a defect — see step 6.) Classifying from only the edges inside the slice would see no events at all and always answer Automation.
Claim these edges off the unclassified pool — they will not be considered again in steps 4 and 5. Name the slice after the automation (e.g. payment_processor["Payment Processor"], email_verifier["Email Verifier"]).
For remaining read-side edges (those not claimed by an Automation Pattern), build slices following Pattern 2 (View). Two read-side edges are connected when they share a readModel node. The unit of grouping is the connected component, with one practical exception:
event → readModel edge targeting it, plus its readModel → ui consumer edges. Do NOT split a fan-in read model into per-event slices — see "Slice granularity" below for why. This holds whether the read model has one incoming event or sixteen.readModel → automation is NOT claimed here. That edge belongs to the Automation Pattern slice (step 3). The read model is a boundary node appearing in both.For remaining command-side edges (those not claimed in step 3), group them into slices — two command-side edges are connected when they share a command node, and each connected component is one slice. Then classify each by its trigger, the kind of the node on the inbound edge into the command:
| Trigger kind | Pattern |
|---|---|
ui | Command — a user acting on the system |
externalEvent | Translation [abbreviated] — knowledge arriving from another system |
domainEvent | Automation [abbreviated] — the system reacting to itself |
automation | Should have been claimed in step 3. Reaching here means the automation has no readModel → input, so it is not monitoring a view — flag it. |
Do not default everything here to Pattern 1. Trigger kind is what separates a translation from a user-initiated command, and they generate completely different code.
Two shapes to flag rather than classify:
Validate the classification. The findings below are defects in the model, not failures of classification. Surface each one to the user with the suggested fix, and do not paper over it:
externalEvents and domainEvents is reading events from two systems, which Pattern 4 explicitly forbids: "on the read side of the pattern you can only read events from one system." This is almost always two patterns fused into one slice — an Automation and a Translation sharing a single command. The fix is to split them, which normally means giving each its own command.domainEvent that no command → domainEvent edge in the model produces has no in-model producer, which means it originated elsewhere. It should almost certainly be declared an externalEvent instead. Report the event, the slice consuming it, and the suggested change — this single re-typing often converts a misclassified slice into a correct Translation.Naming conventions.
payment_processor["Process Payment"], delivery_tracker["Track Delivery"]).gateway_confirmation["Gateway Confirmation"] for gatewayConfirmed → processPayment, since the slice is about ingesting that event rather than about the command's own name.book_room["Book Room"]).view_room_availability, update_guest_roster).view_room_availability, track_availability_horizon, track_guest_presence. This is the one
name in the output that cannot be derived mechanically: it takes a reading of what the read
model lets someone know. Do NOT fall back to a structural name like feed_<event> or
<readModel>_from_<event> — a slice named for its plumbing tells a reader nothing the edge
itself does not already say. If the capability is genuinely unclear, emit the slice with a
structural placeholder name and flag it for the user to name, rather than shipping jargon.view_<readModel>.Boundary nodes still appear in multiple slices. A domainEvent is the OUTPUT of one slice (Pattern 1 or Pattern 3) and may be the INPUT of another (Pattern 2 or Pattern 3) — it's named in both. automation and readModel only appear in one slice each in the canonical patterns; the only way they show up twice is when the same readModel feeds an Automation Pattern slice AND a separate view-only consumer.
Generate the slice block in the file, in the mermaid fence, replacing whatever slice content was stripped in step 1:
slice declaration.--> edges inside the slice.Verify every edge is accounted for: every edge that was bare in step 1 should now sit inside exactly one slice (or be on the unclassified list and explicitly skipped). If any edge is in zero slices or two slices, surface that as an error before writing.
Given these unsliced edges (a hotel-booking payment-processing fragment):
paymentRequested-->paymentsToProcess
paymentsToProcess-->paymentProcessor
paymentProcessor-->processPayment
processPayment-->paymentSucceeded
paymentSucceeded-->paymentsToProcess
paymentSucceeded-->salesReport
salesReport-->sales_ui
…where paymentsToProcess and salesReport are read models, paymentProcessor is an automation, processPayment is a command, the rest are events, and sales_ui is a UI.
Step 3 finds paymentProcessor has both a readModel → automation edge (paymentsToProcess → paymentProcessor) AND an automation → command edge (paymentProcessor → processPayment). Claim the automation core — the trigger, its command, and the events that command produces — but not the events feeding paymentsToProcess:
slice payment_processor["Process Payment"]
paymentsToProcess-->paymentProcessor
paymentProcessor-->processPayment
processPayment-->paymentSucceeded
To classify it, resolve the feeding events of paymentsToProcess across the whole model — they are not in this slice. paymentRequested and paymentSucceeded are both domainEvents, so this is an Automation. Had either been an externalEvent, it would be a Translation.
paymentsToProcess has two incoming event → readModel edges, so step 4's fan-in rule gives each its own View slice:
slice track_outstanding_payments["Track Outstanding Payments"]
paymentRequested-->paymentsToProcess
paymentSucceeded-->paymentsToProcess
paymentSucceeded is produced by the automation's own command and feeds its view, so the loop still closes — but across slice boundaries rather than inside one. That is the intent: the projection that retires a todo row and the automation that picks rows up are separately regenerable. Both feeding events sit in ONE View slice, because the row's state is a fold over both.
paymentSucceeded → salesReport and salesReport → sales_ui involve a different read model, with no automation consumer and no fan-in, so they form a single Pattern 2 view slice:
slice view_sales_report["View Sales Report"]
paymentSucceeded-->salesReport
salesReport-->sales_ui
Total: 3 slices for 7 edges. The boundary paymentSucceeded event appears in all three — output of the automation, input to its own view, and input to the sales report.
Both worked cases below are real defects found in blueprint_dsl_dcb.md, and both were classification failures before step 6 existed.
Case 1 — a mixed read side. The payment slice originally read:
paymentRequested-->paymentsToProcess
paymentSucceeded-->paymentsToProcess
paymentsToProcess-->paymentProcessor
paymentProcessor-->processPayment
gatewayConfirmed-->processPayment <-- externalEvent
processPayment-->paymentSucceeded
Step 3 claims it as an Automation, but its read side draws on paymentRequested/paymentSucceeded (ours, through the view) and gatewayConfirmed (the gateway's, straight into the command). That is the step 6 mixed-read-side violation: Pattern 4 permits reading from only one system. The slice is really an Automation and a Translation fused through a shared command, and the fix is to give each its own — the automation submits the payment, and a separate translation ingests the gateway's confirmation.
Case 2 — an orphan event hiding a Translation. This slice classified as a Command Pattern:
positionUpdated-->hotelProximityTranslator
hotelProximityTranslator-->guestLeft
Nothing in the model produces positionUpdated — no command → positionUpdated edge exists anywhere. An event with no in-model producer came from another system, so it should have been declared externalEvent, not domainEvent. Re-typing that one element converts the slice from a mis-filed Command into an abbreviated Translation, and moves the node into the synthesized External lane where it visually belongs.
The lesson both cases teach: when a slice will not classify, suspect the model before the rules. The classifier's job is to make the model's claims checkable, and a slice that resists classification is usually reporting a real defect.
[abbreviated] where that applies. Flag any unclassified edges, plus every validation finding from step 6 with its suggested fix. Ask the user to confirm before modifying the file.What SKILL.md sets; muted values are Claude Code's defaults
6 skills in this plugin
/add-testsAuthor `sliceTests` Given/When/Then specifications for a slice and append them to that slice's spec file. The target slice can be named or inferred from the test's own action element (its command, or read model for a view test). You describe the test in natural language and pick (or accept an inferred) flow type; the skill grounds every element, outcome, and field against the slice's Model section. It includes only the subset of fields the test's language actually exercises, and — like validate-completeness — refuses to invent data: any attribute you reference that no element in the slice carries is raised back to you before anything is written. Existing tests, the Description, and the Model section always round-trip unchanged./create-event-modelSeed a project with a working Event Model. Writes (1) a markdown file containing the canonical hotel-booking DSL inside a `mermaid` fenced block, and (2) a `model-viewer.html` page that renders that markdown plus any sibling `<model>-slices/` directory created later by the `spec-slices` skill. Useful for bootstrapping a new model or resetting to the reference example. The model defaults to `blueprint_dsl.md`; the viewer is always written as a sibling named `model-viewer.html`.Generated from the plugin's indexed repository (howarddierking/mermaid-event-model) — no native marketplace selected
npx claudepluginhub p/howarddierking-mermaid-event-modelOther plugins' skills for the same job