mermaid-diagram-preset

mermaid-diagram-preset is a cursor rule for Cursor from OriginTrail/dkg. It costs 860 tokens per session, scanned A, original, Apache-2.0.

A formatting rule for Mermaid sequence diagrams, which are text-based drawings that show messages exchanged between people, services, or other participants.

In plain words
What is it for?
It is for applying the repository's required spacing settings to sequence diagrams in Markdown, including diagrams with nested phases.
Why use it?
It adds spacing around arrows, notes, boxes, and participant columns so diagram elements are less likely to overlap or look cramped.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit It is for applying the repository's required spacing settings to sequence diagrams in Markdown, including diagrams with nested phases.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/origintrail/dkg/mermaid-diagram-preset
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/OriginTrail/dkg

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for mermaid-diagram-preset

README.md
[![agentmods](https://agentmods.dev/badge/rules/origintrail/dkg/mermaid-diagram-preset/github.svg)](https://agentmods.dev/rules/origintrail/dkg/mermaid-diagram-preset)
Your own site
<a href="https://agentmods.dev/rules/origintrail/dkg/mermaid-diagram-preset"><img src="https://agentmods.dev/badge/rules/origintrail/dkg/mermaid-diagram-preset/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for mermaid-diagram-preset

Your own site · 80×15
<a href="https://agentmods.dev/rules/origintrail/dkg/mermaid-diagram-preset"><img src="https://agentmods.dev/badge/rules/origintrail/dkg/mermaid-diagram-preset.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 860 This file is loaded in full into every session.
When invoked 860 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00860 $0.00860
Opus 5 $0.00430 $0.00430
Sonnet 5 $0.00172 $0.00172
Haiku 4.5 $0.00086 $0.00086

Measured 12d ago against content hash e4b2945b2a9b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

mermaid-diagram-preset scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/mermaid-diagram-preset.mdc · 67 lines

How it starts

The opening of the file, as written. The whole thing — 67 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Mermaid Sequence Diagram Preset

Every Mermaid sequence diagram in this repo MUST start with the shared init directive below. Mermaid's defaults are too tight: rect borders collide with adjacent arrows, stacked Note pills overlap each other, and multi-participant diagrams get cramped horizontally.

The preset

%%{init: { 'sequence': { 'messageMargin': 55, 'noteMargin': 15, 'boxMargin': 15, 'actorMargin': 70 } } }%%
sequenceDiagram
    ...

For diagrams with nested rect blocks (e.g., phase-based lifecycle diagrams), bump boxMargin to 20:

%%{init: { 'sequence': { 'messageMargin': 55, 'noteMargin': 15, 'boxMargin': 20, 'actorMargin': 70 } } }%%

Why these numbers

Setting Default Preset Effect
messageMargin 35 55 Vertical spacing between arrows. Main anti-overlap lever.
noteMargin 10 15 Padding inside Note pills so text doesn't crowd borders.
boxMargin 10 15 (20 for nested rect) Space around rect blocks so they don't kiss neighboring arrows.
actorMargin 50 70 Horizontal spacing between participant columns.

Companion rules (learned the hard way)

These rules keep diagrams readable beyond the preset:

  • Do not use <br/> inside notes. Split into multiple Note over X: lines or collapse into a single sentence. <br/> works but produces hard-to-read dense pills.
  • Avoid stacking 3+ consecutive Note over X: on the same participant. Mermaid renders each as a separate pill; they frequently overlap neighboring rect borders. Collapse into one concise sentence, or intersperse with arrows.
  • Do not indent multi-line math inside a Note (e.g., " = 840e18 · 1e18 / 8000"). Mermaid preserves the whitespace and widens the pill, causing horizontal collisions. Put the math on one line or use a pre-style code block outside the diagram.

Read the full file on GitHub · 67 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 67 lines · 860 tokens per session scan A e4b2945b2a9b

Subscribe to this mod's changes

mermaid-diagram-preset is a cursor rule published in the GitHub repository OriginTrail/dkg (148 stars, last pushed yesterday), licensed Apache-2.0. It adds 860 tokens to every session, about $0.0043 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.