Agent Wranglers

DOC-46Recommended

Draw diagrams as code

Write diagrams as text in the repository, with a diagram language such as Mermaid, PlantUML or D2, never only as an exported image.

How to do it

Text diagrams change in the same pull request as the code and show a readable diff. GitHub and GitLab draw Mermaid blocks inside Markdown. Render others to SVG in the build with their command-line tool. Keep one diagram per idea, with at most about 15 boxes. Update each diagram with its code, as Change the docs in the same pull request says.

Examples

Mermaid example

flowchart LR
  shop[Order page] --> api[Orders API]
  api --> db[(Orders database)]
  api --> kitchen[Kitchen screen]

How to check

The build renders every diagram source with its tool, such as mmdc for Mermaid, and fails on a syntax error. A search finds no .png or .svg diagram without a source file next to it.

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/documentation/readme-and-docs-as-code/diagrams-as-code">Agent Wranglers documentation playbook</a>. In code you write, add a comment next to it with the same link.