Dev Diagram
Overview
Construct diagrams that stay readable in their final destination. Support only two output formats: ASCII for plain-text readability and Mermaid for renderable Markdown.
Invocation Shape
When the user invokes the skill with positional hints, treat them as:
text$dev.diagram [format] [diagram-kind]
Examples:
$dev.diagram mermaid general-flow$dev.diagram mermaid linear-flow$dev.diagram ascii decision-tree
If the format and diagram kind conflict, follow the user's explicit format and adapt the kind to that format. If a named diagram kind is unknown, fall back to the closest kind in Choose The Diagram Kind.
Choose The Format
- Use ASCII when the user explicitly asks for ASCII, box art, or text diagrams.
- Use ASCII when the destination is a terminal, plain Markdown fence, comment, note, or any medium that may not render Mermaid.
- Use Mermaid when the user explicitly asks for Mermaid or when the destination is known to render Mermaid.
- Preserve the existing format when updating an existing diagram unless the user asks to convert it.
- Default to ASCII when the format is unspecified and render support is unclear.
- Do not mix ASCII and Mermaid in one diagram block.
Choose The Diagram Kind
- Use
linear-flowfor one request or operation through ordered stages. In Mermaid, render it assequenceDiagram. - Use
general-flowfor a call path with important branches grouped by components, ownership, or lifecycle boundaries. In Mermaid, render it asgraph TD. - Use a sequence diagram for actor-to-actor messages over time when the user says
sequencebut notlinear-flow. - Use a flow diagram for ordered steps, branching, and control flow.
- Use a state diagram for lifecycle transitions between named states.
- Use a dependency or topology diagram for ownership, connectivity, or one-way coupling.
- Use a decision tree when the point is rule evaluation rather than runtime sequencing.
Build The Diagram
- Identify the actors, systems, states, or steps before drawing.
- Order the nodes in the direction the reader should scan.
- Keep one abstraction level per diagram; split the diagram if system-level and code-level details are both needed.
- Label an edge only when the action or condition is not obvious.
- Prefer short box labels and move long explanation into surrounding prose.
- Remove incidental helpers, retries, and logging unless they are part of the point of the diagram.
- When updating an existing doc, replace only the diagram block and preserve nearby prose unless the user asks for more.
Write ASCII Diagrams
- Use plain ASCII only:
+,-,|,/,\,<,>. - Keep the diagram valid in a monospaced font without relying on Unicode box-drawing characters.
- Prefer top-to-bottom flow for pipelines and sequences.
- Use side-by-side branches only when the full block stays readable within the document width.
- Align box widths within a local cluster.
- Put branch labels on the branch path, using concrete labels like
yes,no,enabled,disabled,true, orfalse. - Use arrows and spacing consistently across the whole block.
- Keep decorative art out of the diagram.
ASCII Pattern
text+------------------+ | Start request | +------------------+ | v +------------------+ | Check condition | +------------------+ | yes | no v v +---------+ +--------------+ | Path A | | Pass through | +---------+ +--------------+
Write Mermaid Diagrams
- Use Mermaid only inside a
mermaidfence. - Choose the smallest diagram type that fits:
graph TDforgeneral-flowsequenceDiagramforlinear-flowand actor/message sequencesflowchart TDfor most other flowsstateDiagram-v2for state transitions
- Keep node ids short and stable; put readable text in the label.
- Always wrap node labels in double quotes when they contain parentheses, commas, arrows, function-like text, or other parser-sensitive punctuation.
- Use the label form
A["label text here"], notA[label text here]. <br/>is allowed inside quoted labels.- Decision nodes in
{}may stay unquoted only when they contain simple words. - If unsure whether a label is safe, quote it anyway.
- Prefer
flowchart TDunless left-to-right materially improves readability. - Keep styling minimal unless the user explicitly asks for styling or visual emphasis.
- Avoid dense cross-links that make the graph unreadable; split the diagram instead.
- Treat Mermaid like a grammar parser, not Markdown; never rely on it to infer intent from punctuation.
- For
sequenceDiagram, keep participant ids syntax-safe and alphanumeric, such asCreateHelper,ArchiveParser, orSkillClient. - For
sequenceDiagram, use readable aliases withparticipant CreateHelper as Create helper, then reference only the safe id in arrows. - Do not quote sequence message text just to protect punctuation. Prefer plain message text and simplify nested quotes, for example
version_no=1instead ofversion_no="1".
Mermaid General-Flow Pattern
Use general-flow when the diagram should answer an architectural routing or composition question, such as "which component handles this request?" or "how does this configuration become runtime behavior?"
- Pick one concrete request path, resource, or artifact as the running example.
- Create 2-4
subgraphblocks for real component, ownership, or lifecycle boundaries. - Use source-grounded implementation names for nodes.
- Put branch predicates on edges, not in surrounding prose.
- Show the happy path plus only the important alternate routes.
- End at meaningful sinks such as storage, handler, proxy, external service, or terminal state.
- Explain source symbols in prose below the diagram instead of expanding every method in the diagram.
Mermaid Linear-Flow Pattern
Use linear-flow when the diagram should answer an ordered processing question, such as "what stages does one request pass through?"
- Pick exactly one request or operation.
- Identify the client, coordinator, major semantic stages, and terminal endpoint.
- Use 5-8 participants maximum.
- For each stage, draw one request and one returned state or decision.
- Preserve source-backed ordering invariants.
- Collapse observability, timeout, tracing, logging, and bookkeeping wrappers unless they change the business flow.
- Keep branches out unless the branch is the topic; encode secondary reject or deny cases in message labels.
- Put code/package anchors in surrounding prose, not inside the diagram.
Mermaid Basic Pattern
Mermaid Validation
- When editing Mermaid syntax, extract the fenced block to a real temporary file, for example
/tmp/diagram.mmd. - Validate with
npx -y @mermaid-js/mermaid-cli -i /tmp/diagram.mmd -o /tmp/diagram.svg. - Avoid process substitution as
mermaid-cliinput; it can fail on/dev/fd/...paths. - Treat a local preview server starting as a preview check, not a parser check. Use parser-backed validation before considering syntax fixed.
Convert Between Formats
- Preserve the same actors, decision points, and branch labels when converting between ASCII and Mermaid.
- Simplify the layout when a literal one-to-one conversion would hurt readability.
- Verify that the converted diagram still communicates the same control flow and outcomes.
Final Checks
- Ensure every box and edge serves a purpose.
- Ensure directionality is obvious on first read.
- Ensure labels use the vocabulary from the source material rather than invented system names.
- Ensure the diagram reads cleanly in the target medium without extra explanation.
- Emit one final diagram block unless the user explicitly asks for alternatives.


