Most architecture diagrams fail in one of two ways: they are technically valid but hard to read, or they look polished but no longer describe the system accurately. A coding agent can produce either result very quickly.
Tech Leads Club Agent Skills includes Mermaid Studio, a focused workflow for creating, validating, and rendering Mermaid diagrams. It gives an agent explicit rules for diagram type selection, styling, density, naming, validation, and output formats instead of leaving visual quality to a generic prompt.
This tutorial uses a small checkout architecture to show what the skill contributes, how to install it for OpenAI Codex, and how to verify the result before sharing it with a team.
What Mermaid Studio actually does
Mermaid Studio is not just a prompt for drawing boxes. Its workflow has three modes:
- Create: produce Mermaid source from a description or code analysis.
- Render: convert an existing
.mmdfile to SVG, PNG, or ASCII. - Full: create the source, validate it, and render it when the request is ambiguous or asks for the complete result.
The skill also adds concrete constraints that a generic diagram request often misses:
- choose a diagram type that matches the problem, such as a sequence diagram for API messages or an ERD for table relationships;
- put an
%%{init}directive or frontmatter configuration at the start of the diagram; - use a curated palette with soft slate lines instead of default black lines;
- keep a diagram below 15 nodes when possible and group related elements with subgraphs;
- use descriptive camelCase IDs and labels that explain roles or actions;
- validate syntax before rendering;
- save the
.mmdsource beside the rendered artifact.
For C4 diagrams, the skill adds further boundaries: style every relationship, optimize the layout, and keep the diagram to six Rel() calls or fewer when possible. For AWS architecture diagrams, it documents the architecture-beta syntax and the icon-pack flag needed by the renderer.
The output is therefore more than a code block. It is a source diagram, a validation result, and, when requested, a rendered artifact that a person can inspect.
The scenario: map a checkout request path
Imagine a checkout flow with a browser, an API, an order service, a payment provider, and an event bus. The team wants a diagram for an incident review, but the original request is vague:
Draw our checkout architecture. That request leaves several decisions unresolved. Is the goal to show system boundaries, request order, data ownership, or deployment infrastructure? A useful first instruction gives the agent enough context to choose deliberately:
Use the $mermaid-studio skill from Tech Leads Club Agent Skills. Create a Mermaid diagram for the checkout request path in this project. Show the browser, checkout API, order service, payment provider, and event bus. Choose the diagram type that best explains request and event boundaries. Keep the result under 15 nodes and use meaningful camelCase IDs. Return the .mmd source first and explain why you chose this diagram type. Do not render or edit files yet. In Codex, $mermaid-studio is an explicit skill invocation. You can also select the installed skill from the /skills picker. The exact selection mechanism belongs to the agent, so do not assume that pasting $mermaid-studio into another product will attach the skill automatically.
Install it for OpenAI Codex
The official Agent Skills CLI currently reports version 1.6.3. Install Mermaid Studio in the current project with the exact skill and agent IDs from the official pages:
npx @tech-leads-club/agent-skills install --skill mermaid-studio --agent codex This places the project skill under .codex/skills. The supported-agent catalog lists the other current targets and their exact IDs. Append --global to the Codex command when you want the skill available in every project on the machine:
npx @tech-leads-club/agent-skills install --skill mermaid-studio --agent codex --global Installation and invocation are different steps. The installer copies SKILL.md and its scripts into the agent's skill directory. The chat invocation tells Codex which installed instructions to apply to the request.
Create the source with a deliberate visual contract
After the agent chooses a flowchart, sequence diagram, or C4 view, ask it to produce the source with the skill's styling rules. For a request path, a sequence diagram may be clearer than a component map:
Use the $mermaid-studio skill from Tech Leads Club Agent Skills. Create a sequence diagram for one successful checkout request. Include the browser, checkout API, order service, payment provider, and event bus. Show the synchronous payment authorization before the order-created event is published. Add the skill's curated init configuration, keep labels concise, and use action verbs on messages. Do not invent retries, queues, or data stores that are not described in the project. Return only the Mermaid source and a short list of assumptions. For a general flowchart, the source should start with a professional init directive before the diagram type. A compact example looks like this:
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#4f46e5', 'primaryTextColor': '#ffffff', 'primaryBorderColor': '#3730a3', 'lineColor': '#94a3b8', 'secondaryColor': '#10b981', 'tertiaryColor': '#f59e0b', 'background': '#ffffff', 'mainBkg': '#f8fafc', 'nodeBorder': '#cbd5e1', 'clusterBkg': '#f1f5f9', 'clusterBorder': '#e2e8f0', 'titleColor': '#1e293b', 'edgeLabelBackground': '#ffffff', 'textColor': '#334155' }}}%% flowchart LR browser[Browser] --> checkoutApi[Checkout API] checkoutApi --> orderService[Order Service] orderService --> paymentProvider[Payment Provider] orderService --> eventBus[Event Bus] The styling is not decoration. Softer lines, restrained colors, and short labels make relationships easier to follow when the diagram is embedded in a pull request or incident document.
Validate before rendering
The installed skill includes a validator. Run it against the source file before asking for an image:
node .codex/skills/mermaid-studio/scripts/validate.mjs checkout-flow.mmd The validator performs basic checks such as diagram type detection, bracket matching, reserved-word warnings, and node-count warnings. When the Mermaid dependency is available, it can also perform parser validation. Treat warnings as review prompts, not as permission to ignore the diagram.
In a smoke test on the current CLI, a project-scoped installation completed successfully and the validator returned Valid (basic checks only) for a minimal graph. That confirms the installation and command path. It does not prove that a complex diagram is correct or readable.
Ask Codex for a verification pass that connects the source to the real system:
Use the $mermaid-studio skill from Tech Leads Club Agent Skills. Review checkout-flow.mmd against the checkout implementation. Check that every participant and message is supported by the code or the documented integration. Flag missing boundaries, invented behavior, ambiguous labels, more than 15 nodes, and relationships that need a human decision. Do not rewrite the diagram yet. Return a table with: finding, evidence, risk, and recommended change. This is where the skill helps beyond syntax validation. A diagram can parse correctly while still claiming that the order service owns payment data or that an event is emitted before authorization. The agent can compare the source with the workspace, but the team still owns the system truth.
Render the verified source
When the source and assumptions are approved, render an artifact for the audience that needs it:
SVG for documentation and high-quality review: node .codex/skills/mermaid-studio/scripts/render.mjs \ -i checkout-flow.mmd \ -o checkout-flow.svg PNG for documents or presentations: node .codex/skills/mermaid-studio/scripts/render.mjs \ -i checkout-flow.mmd \ -o checkout-flow.png \ --width 1200 ASCII for a terminal or text-only README: node .codex/skills/mermaid-studio/scripts/render-ascii.mjs \ -i checkout-flow.mmd For an AWS architecture-beta diagram that uses Iconify logos, add --icons logos to the render command. If the destination does not support the icon pack, use the built-in icon names or a simpler diagram type.
The skill also supports batch rendering. Keep the input directory and output directory separate, preserve the .mmd files, and use a bounded worker count for larger diagram sets:
node .codex/skills/mermaid-studio/scripts/batch.mjs \ --input-dir ./diagrams \ --output-dir ./rendered \ --format svg \ --workers 4 Review the result like an engineer
Before publishing the SVG or adding it to a design document, check four things:
- The diagram type answers the intended question. A sequence diagram should not be used as a database schema.
- The source reflects the current implementation, including the direction and timing of important relationships.
- The rendered layout is readable at the size where people will see it. Shorten labels or split an overloaded diagram instead of shrinking the font indefinitely.
- The assumptions and unresolved questions are visible to reviewers.
For C4 diagrams, verify that each Rel() has matching relationship styling and that the layout is not routing lines through nodes. For code-to-diagram work, ask the agent to explain how it mapped modules, routes, handlers, or models to the selected diagram type before trusting the picture.
Limits and practical boundaries
Mermaid Studio can create consistent source and automate repeatable validation and rendering. It cannot know whether the architecture is correct without reliable project context, and it cannot replace an architecture review. A passing parser check proves syntax, not ownership, security, latency, availability, or operational behavior.
Keep the diagram focused. If a system needs dozens of nodes, make several views with explicit purposes instead of forcing every dependency onto one canvas. If the request is actually to generate a non-Mermaid image or a data plot, use a more appropriate tool or skill.
AI assistance disclosure
This tutorial was researched and drafted with AI assistance. The selected skill's frontmatter name, version, workflow, installation command, Codex path, CLI version, and rendering commands were checked against the current Tech Leads Club catalog, official Mermaid Studio source, and supported-agent pages on publication day. The checkout scenario and sample labels are illustrative. Verify current CLI behavior, project paths, and system relationships in your own environment before publishing a diagram.
What system boundary in your project would become easier to review if the agent had to validate the source before rendering it?
