Craft Mermaid
Create focused Mermaid diagrams and deterministic high-resolution PNG artifacts
using the same renderer family as Craft Agents. Treat the rendered PNG, not the
host client's Mermaid preview, as the portable visual result.
Preserve Craft Compatibility
- Use only
graph/flowchart, stateDiagram-v2, sequenceDiagram,
classDiagram, erDiagram, and xychart-beta in compatibility mode.
- Render with the bundled runtime and its pinned
beautiful-mermaid version.
- Do not silently fall back to Mermaid CLI, Kroki, or another renderer.
- Avoid custom
style and classDef directives unless the user asks for them;
they override the portable Craft palette.
- Quote labels containing punctuation, brackets, parentheses, or colons.
- Keep one concept per diagram. Split dense diagrams instead of shrinking text.
- Prefer
LR for small flows and processes. Prefer TD for deep hierarchies or
large graphs whose horizontal layout would become excessively wide.
Read references/syntax.md when selecting or authoring a
diagram type. Read
references/visual-review.md before reviewing a
rendered preview or repairing a diagram after review.
Complete Installation and Updates
Do not treat a Craft Mermaid installation or update as complete when only the
Skill files have been copied.
After skills add, resolve the actual installed Skill directory from the
installer's output. Obtain approval when required because dependency setup can
use the network and modifies that directory, then run:
node <installed-skill-dir>/scripts/setup-runtime.mjs
When asked to update Craft Mermaid:
- Determine whether the installed copy is project-level or global. Run
npx skills update craft-mermaid --project or
npx skills update craft-mermaid --global with the matching explicit scope.
- Read the update result. If Craft Mermaid is already current, report that and
do not reinstall dependencies.
- If Craft Mermaid was updated, resolve the updated Skill directory. Skills CLI
replaces the directory and does not restore
scripts/runtime/node_modules.
- Obtain dependency-installation approval when required, then run
node <installed-skill-dir>/scripts/setup-runtime.mjs before declaring the
update complete.
The setup entry point checks Node.js compatibility, runs npm ci against the
bundled lockfile, and runs the smoke test. Report the installed directory and
test result. Treat a setup or test failure as an incomplete installation or
update.
Workflow
Extract the entities, relationships, order, and labels from the request.
Select the narrowest supported diagram type that expresses the information.
Write the source to a .mmd file in the user's requested output directory.
Resolve this skill's directory and check for
scripts/runtime/node_modules. If dependencies are absent, ask before
running node <skill-dir>/scripts/setup-runtime.mjs; dependency installation
can require network access and modifies the skill directory. Do not continue
to rendering unless its smoke test succeeds.
Render and validate with:
node <skill-dir>/scripts/runtime/render.mjs \
--input <diagram.mmd> \
--out-dir <output-directory> \
--theme craft-light \
--json
Read the JSON validation result from stdout. Stop and repair syntax when
valid is false. Do not save it as a report artifact.
Inspect the generated PNG using the host's image-inspection capability when
one exists. Judge it using references/visual-review.md; never infer visual
quality from Mermaid source alone.
Keep the structured visual-review result in the current reasoning context;
do not write a separate review or render-report file.
Repair and re-render at most twice. Preserve semantics while fixing layout.
Deliver only the .mmd and .png artifacts. Embed or link the PNG when the
host supports it. Include a Mermaid code fence only as editable source; a
host renderer may produce a different appearance.
Render Options
Use craft-light unless the user requests dark output. Use craft-dark for a
dark artifact. The runtime supports:
--input <path> Required Mermaid source
--out-dir <path> Required artifact directory
--theme craft-light|craft-dark
--scale <factor> Default: 3
--max-width <pixels> Default: 4096
--max-height <pixels> Default: 3072
--json Print validation details to stdout
The runtime writes normalized Mermaid source beside the high-resolution PNG. It
uses an in-memory SVG for deterministic validation and rasterization but does
not save or deliver that intermediate representation. YAML frontmatter is used
only as input metadata and removed before rendering, matching the Craft renderer
pipeline. When the output directory is also the input directory, the runtime
writes <name>.normalized.mmd instead of overwriting the original source.
Visual Review
- Review the PNG, not a screenshot from a different Mermaid renderer.
- Check clipping, overlap, legibility, grouping, direction, whitespace, and
semantic coverage.
- Modify layout before shortening meaningful labels.
- Mark visual review as
skipped when the host cannot inspect images. The
renderer still performs deterministic checks on its in-memory SVG, but those
checks do not constitute visual approval.
- Report unresolved issues after two repair rounds instead of looping.
Failure Rules
- If the renderer rejects a diagram, return the exact diagnostic and revise it.
- If a requested diagram type is unsupported, explain that Craft-compatible
mode cannot preserve the requested type. Ask before using another renderer.
- If dependency installation is unavailable, still provide
.mmd source and
state clearly that rendering and visual review were not performed.
- Never describe a diagram as validated merely because the source looks valid.
1---2name: craft-mermaid3description: Create, render, and visually verify Craft-style Mermaid diagrams with the same beautiful-mermaid layout engine and matching light/dark palettes. Use for architecture, workflows, state transitions, API sequences, class models, entity relationships, XY charts, Mermaid code fences, .mmd files, Craft Mermaid installation, updates, or runtime repair, or whenever a diagram would materially improve an explanation in Codex, Claude Code, or another shell-capable agent.4---56# Craft Mermaid78Create focused Mermaid diagrams and deterministic high-resolution PNG artifacts9using the same renderer family as Craft Agents. Treat the rendered PNG, not the10host client's Mermaid preview, as the portable visual result.1112## Preserve Craft Compatibility1314- Use only `graph`/`flowchart`, `stateDiagram-v2`, `sequenceDiagram`,15 `classDiagram`, `erDiagram`, and `xychart-beta` in compatibility mode.16- Render with the bundled runtime and its pinned `beautiful-mermaid` version.17- Do not silently fall back to Mermaid CLI, Kroki, or another renderer.18- Avoid custom `style` and `classDef` directives unless the user asks for them;19 they override the portable Craft palette.20- Quote labels containing punctuation, brackets, parentheses, or colons.21- Keep one concept per diagram. Split dense diagrams instead of shrinking text.22- Prefer `LR` for small flows and processes. Prefer `TD` for deep hierarchies or23 large graphs whose horizontal layout would become excessively wide.2425Read [references/syntax.md](references/syntax.md) when selecting or authoring a26diagram type. Read27[references/visual-review.md](references/visual-review.md) before reviewing a28rendered preview or repairing a diagram after review.2930## Complete Installation and Updates3132Do not treat a Craft Mermaid installation or update as complete when only the33Skill files have been copied.3435After `skills add`, resolve the actual installed Skill directory from the36installer's output. Obtain approval when required because dependency setup can37use the network and modifies that directory, then run:3839```bash40node <installed-skill-dir>/scripts/setup-runtime.mjs41```4243When asked to update Craft Mermaid:44451. Determine whether the installed copy is project-level or global. Run46 `npx skills update craft-mermaid --project` or47 `npx skills update craft-mermaid --global` with the matching explicit scope.482. Read the update result. If Craft Mermaid is already current, report that and49 do not reinstall dependencies.503. If Craft Mermaid was updated, resolve the updated Skill directory. Skills CLI51 replaces the directory and does not restore `scripts/runtime/node_modules`.524. Obtain dependency-installation approval when required, then run53 `node <installed-skill-dir>/scripts/setup-runtime.mjs` before declaring the54 update complete.5556The setup entry point checks Node.js compatibility, runs `npm ci` against the57bundled lockfile, and runs the smoke test. Report the installed directory and58test result. Treat a setup or test failure as an incomplete installation or59update.6061## Workflow62631. Extract the entities, relationships, order, and labels from the request.642. Select the narrowest supported diagram type that expresses the information.653. Write the source to a `.mmd` file in the user's requested output directory.664. Resolve this skill's directory and check for67 `scripts/runtime/node_modules`. If dependencies are absent, ask before68 running `node <skill-dir>/scripts/setup-runtime.mjs`; dependency installation69 can require network access and modifies the skill directory. Do not continue70 to rendering unless its smoke test succeeds.715. Render and validate with:7273 ```bash74 node <skill-dir>/scripts/runtime/render.mjs \75 --input <diagram.mmd> \76 --out-dir <output-directory> \77 --theme craft-light \78 --json79 ```80816. Read the JSON validation result from stdout. Stop and repair syntax when82 `valid` is false. Do not save it as a report artifact.837. Inspect the generated PNG using the host's image-inspection capability when84 one exists. Judge it using `references/visual-review.md`; never infer visual85 quality from Mermaid source alone.868. Keep the structured visual-review result in the current reasoning context;87 do not write a separate review or render-report file.889. Repair and re-render at most twice. Preserve semantics while fixing layout.8910. Deliver only the `.mmd` and `.png` artifacts. Embed or link the PNG when the90 host supports it. Include a Mermaid code fence only as editable source; a91 host renderer may produce a different appearance.9293## Render Options9495Use `craft-light` unless the user requests dark output. Use `craft-dark` for a96dark artifact. The runtime supports:9798```text99--input <path> Required Mermaid source100--out-dir <path> Required artifact directory101--theme craft-light|craft-dark102--scale <factor> Default: 3103--max-width <pixels> Default: 4096104--max-height <pixels> Default: 3072105--json Print validation details to stdout106```107108The runtime writes normalized Mermaid source beside the high-resolution PNG. It109uses an in-memory SVG for deterministic validation and rasterization but does110not save or deliver that intermediate representation. YAML frontmatter is used111only as input metadata and removed before rendering, matching the Craft renderer112pipeline. When the output directory is also the input directory, the runtime113writes `<name>.normalized.mmd` instead of overwriting the original source.114115## Visual Review116117- Review the PNG, not a screenshot from a different Mermaid renderer.118- Check clipping, overlap, legibility, grouping, direction, whitespace, and119 semantic coverage.120- Modify layout before shortening meaningful labels.121- Mark visual review as `skipped` when the host cannot inspect images. The122 renderer still performs deterministic checks on its in-memory SVG, but those123 checks do not constitute visual approval.124- Report unresolved issues after two repair rounds instead of looping.125126## Failure Rules127128- If the renderer rejects a diagram, return the exact diagnostic and revise it.129- If a requested diagram type is unsupported, explain that Craft-compatible130 mode cannot preserve the requested type. Ask before using another renderer.131- If dependency installation is unavailable, still provide `.mmd` source and132 state clearly that rendering and visual review were not performed.133- Never describe a diagram as validated merely because the source looks valid.