Excalidraw diagram in Enterprise Integration Patterns notation: Order Service, badged tx and outbox, publishes OrderPlaced to the orders.placed publish-subscribe channel, which fans out to Billing and Shipping, dead-letters to orders.placed.dlq, and is wire-tapped into an Audit store

The Enterprise Integration Patterns diagrams in my Ankusa posts come from a skill that turns a small JSON spec into an Excalidraw file.

That skill is now public as diagram-skill, under the MIT license. It installs into Claude Code, Codex, Cursor, Oh My Pi and other agents that load Agent Skills.

What it draws

A diagram is a spec of nodes, edges and groups. One Node script with no dependencies lays the spec out in Hohpe and Woolf’s notation and writes an .excalidraw file and a preview .svg. The spec is the source of truth and the other files are build output, so a change to the diagram is a change to a few lines of JSON.

The diagram at the top of this post is built from docs/fan-out.spec.json, which is all of this:

{
  "title": "Order placed — publish-subscribe fan-out",
  "legend": false,
  "nodes": [
    {"id": "orders", "kind": "service", "label": "Order Service", "badges": ["tx", "outbox"]},
    {"id": "orders.placed", "kind": "pubsub-channel", "label": "orders.placed", "sub": "Kafka topic", "tags": ["key=orderId"]},
    {"id": "orders.placed.dlq", "kind": "dead-letter-channel", "label": "orders.placed.dlq", "shadow": "orders.placed"},
    {"id": "billing", "kind": "service", "label": "Billing", "badges": ["idempotent", "competing:3"]},
    {"id": "shipping", "kind": "service", "label": "Shipping", "badges": ["idempotent", "durable"]},
    {"id": "audit", "kind": "message-store", "label": "Audit store"}
  ],
  "edges": [
    {"from": "orders", "to": "orders.placed", "type": "event", "message": "OrderPlaced"},
    {"from": "orders.placed", "to": "billing", "type": "event", "message": "OrderPlaced"},
    {"from": "orders.placed", "to": "shipping", "type": "event", "message": "OrderPlaced"},
    {"from": "orders.placed", "to": "audit", "kind": "tap"}
  ]
}

Six nodes and four edges, with no coordinates anywhere. The pattern vocabulary does the drawing:

  • badges puts endpoint patterns on a service as pills. competing:3 renders Billing as a stack of boxes labelled competing ×3.
  • shadow hangs the dead letter channel under the channel it serves and draws the dashed red route between them.
  • "kind": "tap" draws a wire tap, a dotted line that copies messages into the message store without disturbing the flow.
  • "type": "event" marks the arrow «E». Commands get «C», documents «D», and replies «R» on a dashed line.

The catalogue covers 60 node kinds, 17 badges and 10 arrow styles. The node kinds follow the book’s chapters: channels, message construction, routing, transformation, endpoints and system management, plus a few the book does not have, like the transactional outbox and a schema registry. The README shows a stencil for every one of them next to the spec text that produces it.

BTW, the same stencils ship as an Excalidraw library, eip.excalidrawlib, so you can load them into excalidraw.com and draw by hand with no agent involved.

Installing it

The skills CLI installs it for any agent:

# into the current project; prompts for which agents to install for
npx skills add jamescarr/diagram-skill

# globally, for one agent
npx skills add jamescarr/diagram-skill -g -a claude-code -y

-a also takes codex, cursor, opencode, gemini-cli and github-copilot. In Claude Code you can install it as a plugin instead:

claude plugin marketplace add jamescarr/diagram-skill
claude plugin install diagram-skill@jamescarr-skills

I run it in Oh My Pi from a clone, so a git pull updates it:

git clone https://github.com/jamescarr/diagram-skill ~/src/diagram-skill
ln -s ~/src/diagram-skill/skills/excalidraw-architecture ~/.omp/agent/skills/excalidraw-architecture

It needs Node 22 or later and nothing else. The PNG export also needs Chrome or Chromium and network access to esm.sh, because Excalidraw itself does the rendering.

How the agent uses it

The skill is named excalidraw-architecture. Ask your agent to diagram a message flow and it works through the seven steps in SKILL.md: inventory, level, spec, build, look, fix and deliver. The inventory comes first because it forces the questions a whiteboard sketch skips. Is this channel point-to-point or publish-subscribe? What is the key? Where do failed messages go?

Three commands cover the build:

# the node kinds, endpoint badges, edge kinds and aliases the spec accepts
node skills/excalidraw-architecture/scripts/eip_excalidraw.mjs kinds

# write <name>.excalidraw and <name>.svg; --png adds an Excalidraw-rendered PNG
node skills/excalidraw-architecture/scripts/eip_excalidraw.mjs build <name>.spec.json --png

# validate and lay out without writing; warnings fail the run
node skills/excalidraw-architecture/scripts/eip_excalidraw.mjs build <name>.spec.json --check --strict

With --strict, a bad layout fails the build. A spec error exits 2 and a layout warning exits 1. The agent gets an exit code to fix against, and SKILL.md maps each symptom to a spec change: an arrow that crosses a node gets route: "ortho", and a crowded column gets lanes or the diagram is split.

Then it looks at the picture. The agent reads the PNG or the preview SVG and works a review checklist: every arrow is labelled, every channel shows its kind and key, the dead letter decision is visible for every channel, and the diagram has at most 20 nodes.

The skill also carries modelling rules for what a diagram must make visible. One of them says every consumer of an at-least-once channel wears the idempotent badge, or the diagram says why not. In a design review, a diagram drawn under these rules shows a missing dead letter queue, correlation id or idempotency check.

The exported PNG embeds its own scene. Drop the file onto excalidraw.com and it opens as an editable drawing.

SKILL.md also maps broker concepts to patterns:

StackDraw as
Kafka topicpubsub-channel; a consumer group is competing:N
RabbitMQ queuep2p-channel; a DLX is a dead-letter-channel
SQS / SNSp2p-channel / pubsub-channel
EventBridge rulecontent-based-router
Step Functionsprocess-manager or saga

How I use it for this blog

The Ankusa repo’s own documentation is drawn with the skill. The specs and their output are in the repo under docs/diagrams.

The posts need one more step. This blog shows an image at most 754px wide, and many of the Ankusa sheets are wider than that. So most illustrations in the posts come from their own copies of the specs, laid out again in two columns and split into parts where a sheet was too wide. Since the spec is JSON, that split is an edit an agent can make and check by itself.

A small script, render.py, then recolours each scene by role and has Excalidraw render it in the blog’s dark palette. The sink catalogue fits the column as drawn, so it only went through the recolouring:

Sink catalogue in the blog’s dark palette: Dispatch sends a deliver command to a recipient list, which fans out one delivery row per selected sink to an HTTP receiver, a Kafka topic, a RabbitMQ exchange, a NATS JetStream subject, an SQS queue, a Google Pub/Sub topic, a Redis channel and a log

Reference

The README has every stencil, and references/spec.md has every field a spec accepts.