agentleFS
cheyuriycheyuriy/codelabgen/skills/diagramming/SKILL.md

diagramming

Skill1 starsChanged 24 days agoMITView on GitHub

How to draw diagrams and write math in codelabgen lessons — choosing Mermaid, D2 or Graphviz, generating diagrams from the code itself, size and labeling rules, and LaTeX conventions that render on both GitHub and the MkDocs site.

5 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Default to Mermaid. Use D2 or Graphviz only when codelabgen doctor shows the tool as ok.

    line 20
  2. Very specific:

    Put the source in <lesson dir>/docs/diagrams/<name>.d2 (or .dot) and run codelabgen diagrams render <id> --course <dir>.

    line 24
  3. Distinctive:

    No colors or fonts in the source: the renderer's themes handle light and dark mode.

    line 26
  4. Distinctive:

    Keep it readable at page width: about 20 shapes at most.

    line 27

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Diagrams and math in lessons

A diagram earns its place when the reader needs to see structure or flow: how parts connect, the order things happen in, how state changes. Don't draw what a sentence says just as well.

Choosing the tool

NeedToolWhy
Flows, graphs of nodes, sequences, state machinesMermaid (```mermaid block)GitHub renders it natively; no build step
A diagram of something the library can draw itselfGenerated from the codeIt always matches the code
Architecture, layered systems, many containersD2 (docs/diagrams/<name>.d2 + rendered .svg)Better layout for big pictures
Dense graphsGraphviz (docs/diagrams/<name>.dot + .svg)Handles many edges

Default to Mermaid. Use D2 or Graphviz only when codelabgen doctor shows the tool as ok.

D2 and Graphviz

  • Put the source in <lesson dir>/docs/diagrams/<name>.d2 (or .dot) and run codelabgen diagrams render <id> --course <dir>. It writes <name>.svg next to the source. Graphviz SVGs have a transparent background; D2 SVGs switch between a light and a dark palette with the reader's color scheme. codelabgen verify re-renders changed sources too.
  • Reference the SVG from the docs: ![Архитектура сервиса](diagrams/<name>.svg). Never reference the source file.
  • No colors or fonts in the source: the renderer's themes handle light and dark mode. Labels in the course language, short.
  • Keep it readable at page width: about 20 shapes at most.

Generate from the code when you can

Libraries that build graphs can often draw them. For example, LangGraph's compiled graph prints Mermaid:

cd <lesson dir>
env -u VIRTUAL_ENV uv run python -c "from l1_2_routing.graph import build_graph; print(build_graph().get_graph().draw_mermaid())"

Paste the result into a ```mermaid block and add a sentence saying it was generated from the code. You may simplify styling, but never change the structure.

Mermaid rules

  • At most about 15 nodes. Split larger pictures, or show one level of detail.
  • Labels in the course language, short (1–4 words). Identifiers stay as they are: route(), TicketState.
  • Pick the right type: flowchart LR/TD for flows and graphs, sequenceDiagram for interactions over time, stateDiagram-v2 for state machines.
  • No hard-coded colors or themes. Let GitHub and the site apply light and dark themes.
  • Put labels with spaces, parentheses or non-Latin text in quotes: A["Классификация (classify)"].
  • Introduce each diagram with one sentence saying what to look at.

Math

  • Inline: $…$ with no spaces just inside the delimiters ($O(n)$, not $ O(n) $).
  • Block: $$…$$ on lines of their own, with a blank line before and after.
  • Nothing else: no \(…\), no ```math blocks.
  • Escape a literal dollar sign in prose as \$.
  • Formulas with _ or * in several places go in block form, so Markdown on GitHub doesn't mangle them.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.