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:
$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-flow for one request or operation through ordered stages. In Mermaid, render it as sequenceDiagram.
- Use
general-flow for a call path with important branches grouped by components, ownership, or lifecycle boundaries. In Mermaid, render it as graph TD.
- Use a sequence diagram for actor-to-actor messages over time when the user says
sequence but not linear-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, or false.
- Use arrows and spacing consistently across the whole block.
- Keep decorative art out of the diagram.
ASCII Pattern
+------------------+
| Start request |
+------------------+
|
v
+------------------+
| Check condition |
+------------------+
| yes | no
v v
+---------+ +--------------+
| Path A | | Pass through |
+---------+ +--------------+
Write Mermaid Diagrams
- Use Mermaid only inside a
mermaid fence.
- Choose the smallest diagram type that fits:
graph TD for general-flow
sequenceDiagram for linear-flow and actor/message sequences
flowchart TD for most other flows
stateDiagram-v2 for 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"], not A[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 TD unless 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 as CreateHelper, ArchiveParser, or SkillClient.
- For
sequenceDiagram, use readable aliases with participant 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=1 instead of version_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
subgraph blocks 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.
graph TD
subgraph Incoming
direction LR
A["Client"] --> B{"/apis/example/v1/widgets"}
end
subgraph Runtime
direction LR
B --> C["Gateway"]
C -->|known route| D["Core handler"]
C -->|extension route| E["Extension proxy"]
D --> F["Storage"]
end
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.
sequenceDiagram
participant Client
participant Pipeline
participant Authn as Authentication
participant Authz as Authorization
participant Handler as REST Endpoint
Client->>Pipeline: Request
Pipeline->>Authn: Authenticate
Authn-->>Pipeline: User info
Pipeline->>Authz: Authorize
Authz-->>Pipeline: Allowed or denied
Pipeline->>Handler: Handle
Handler-->>Pipeline: Response
Pipeline-->>Client: Response
Mermaid Basic Pattern
flowchart TD
A["Start request"] --> B["Check condition"]
B -->|yes| C["Path A"]
B -->|no| D["Pass through"]
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-cli input; 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.
1---2name: dev-diagram3description: Create or revise engineering diagrams in ASCII or Mermaid.4---56# Dev Diagram78## Overview910Construct diagrams that stay readable in their final destination. Support only two output formats: ASCII for plain-text readability and Mermaid for renderable Markdown.1112## Invocation Shape1314When the user invokes the skill with positional hints, treat them as:1516```text17$dev.diagram [format] [diagram-kind]18```1920Examples:2122- `$dev.diagram mermaid general-flow`23- `$dev.diagram mermaid linear-flow`24- `$dev.diagram ascii decision-tree`2526If 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-diagram-kind).2728## Choose The Format29301. Use ASCII when the user explicitly asks for ASCII, box art, or text diagrams.312. Use ASCII when the destination is a terminal, plain Markdown fence, comment, note, or any medium that may not render Mermaid.323. Use Mermaid when the user explicitly asks for Mermaid or when the destination is known to render Mermaid.334. Preserve the existing format when updating an existing diagram unless the user asks to convert it.345. Default to ASCII when the format is unspecified and render support is unclear.356. Do not mix ASCII and Mermaid in one diagram block.3637## Choose The Diagram Kind38391. Use `linear-flow` for one request or operation through ordered stages. In Mermaid, render it as `sequenceDiagram`.402. Use `general-flow` for a call path with important branches grouped by components, ownership, or lifecycle boundaries. In Mermaid, render it as `graph TD`.413. Use a sequence diagram for actor-to-actor messages over time when the user says `sequence` but not `linear-flow`.424. Use a flow diagram for ordered steps, branching, and control flow.435. Use a state diagram for lifecycle transitions between named states.446. Use a dependency or topology diagram for ownership, connectivity, or one-way coupling.457. Use a decision tree when the point is rule evaluation rather than runtime sequencing.4647## Build The Diagram48491. Identify the actors, systems, states, or steps before drawing.502. Order the nodes in the direction the reader should scan.513. Keep one abstraction level per diagram; split the diagram if system-level and code-level details are both needed.524. Label an edge only when the action or condition is not obvious.535. Prefer short box labels and move long explanation into surrounding prose.546. Remove incidental helpers, retries, and logging unless they are part of the point of the diagram.557. When updating an existing doc, replace only the diagram block and preserve nearby prose unless the user asks for more.5657## Write ASCII Diagrams58591. Use plain ASCII only: `+`, `-`, `|`, `/`, `\`, `<`, `>`.602. Keep the diagram valid in a monospaced font without relying on Unicode box-drawing characters.613. Prefer top-to-bottom flow for pipelines and sequences.624. Use side-by-side branches only when the full block stays readable within the document width.635. Align box widths within a local cluster.646. Put branch labels on the branch path, using concrete labels like `yes`, `no`, `enabled`, `disabled`, `true`, or `false`.657. Use arrows and spacing consistently across the whole block.668. Keep decorative art out of the diagram.6768### ASCII Pattern6970```text71+------------------+72| Start request |73+------------------+74 |75 v76+------------------+77| Check condition |78+------------------+79 | yes | no80 v v81+---------+ +--------------+82| Path A | | Pass through |83+---------+ +--------------+84```8586## Write Mermaid Diagrams87881. Use Mermaid only inside a `mermaid` fence.892. Choose the smallest diagram type that fits:90 - `graph TD` for `general-flow`91 - `sequenceDiagram` for `linear-flow` and actor/message sequences92 - `flowchart TD` for most other flows93 - `stateDiagram-v2` for state transitions943. Keep node ids short and stable; put readable text in the label.954. Always wrap node labels in double quotes when they contain parentheses, commas, arrows, function-like text, or other parser-sensitive punctuation.965. Use the label form `A["label text here"]`, not `A[label text here]`.976. `<br/>` is allowed inside quoted labels.987. Decision nodes in `{}` may stay unquoted only when they contain simple words.998. If unsure whether a label is safe, quote it anyway.1009. Prefer `flowchart TD` unless left-to-right materially improves readability.10110. Keep styling minimal unless the user explicitly asks for styling or visual emphasis.10211. Avoid dense cross-links that make the graph unreadable; split the diagram instead.10312. Treat Mermaid like a grammar parser, not Markdown; never rely on it to infer intent from punctuation.10413. For `sequenceDiagram`, keep participant ids syntax-safe and alphanumeric, such as `CreateHelper`, `ArchiveParser`, or `SkillClient`.10514. For `sequenceDiagram`, use readable aliases with `participant CreateHelper as Create helper`, then reference only the safe id in arrows.10615. Do not quote sequence message text just to protect punctuation. Prefer plain message text and simplify nested quotes, for example `version_no=1` instead of `version_no="1"`.107108### Mermaid General-Flow Pattern109110Use `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?"1111121. Pick one concrete request path, resource, or artifact as the running example.1132. Create 2-4 `subgraph` blocks for real component, ownership, or lifecycle boundaries.1143. Use source-grounded implementation names for nodes.1154. Put branch predicates on edges, not in surrounding prose.1165. Show the happy path plus only the important alternate routes.1176. End at meaningful sinks such as storage, handler, proxy, external service, or terminal state.1187. Explain source symbols in prose below the diagram instead of expanding every method in the diagram.119120```mermaid121graph TD122 subgraph Incoming123 direction LR124 A["Client"] --> B{"/apis/example/v1/widgets"}125 end126127 subgraph Runtime128 direction LR129 B --> C["Gateway"]130 C -->|known route| D["Core handler"]131 C -->|extension route| E["Extension proxy"]132 D --> F["Storage"]133 end134```135136### Mermaid Linear-Flow Pattern137138Use `linear-flow` when the diagram should answer an ordered processing question, such as "what stages does one request pass through?"1391401. Pick exactly one request or operation.1412. Identify the client, coordinator, major semantic stages, and terminal endpoint.1423. Use 5-8 participants maximum.1434. For each stage, draw one request and one returned state or decision.1445. Preserve source-backed ordering invariants.1456. Collapse observability, timeout, tracing, logging, and bookkeeping wrappers unless they change the business flow.1467. Keep branches out unless the branch is the topic; encode secondary reject or deny cases in message labels.1478. Put code/package anchors in surrounding prose, not inside the diagram.148149```mermaid150sequenceDiagram151 participant Client152 participant Pipeline153 participant Authn as Authentication154 participant Authz as Authorization155 participant Handler as REST Endpoint156157 Client->>Pipeline: Request158 Pipeline->>Authn: Authenticate159 Authn-->>Pipeline: User info160 Pipeline->>Authz: Authorize161 Authz-->>Pipeline: Allowed or denied162 Pipeline->>Handler: Handle163 Handler-->>Pipeline: Response164 Pipeline-->>Client: Response165```166167### Mermaid Basic Pattern168169```mermaid170flowchart TD171 A["Start request"] --> B["Check condition"]172 B -->|yes| C["Path A"]173 B -->|no| D["Pass through"]174```175176### Mermaid Validation1771781. When editing Mermaid syntax, extract the fenced block to a real temporary file, for example `/tmp/diagram.mmd`.1792. Validate with `npx -y @mermaid-js/mermaid-cli -i /tmp/diagram.mmd -o /tmp/diagram.svg`.1803. Avoid process substitution as `mermaid-cli` input; it can fail on `/dev/fd/...` paths.1814. Treat a local preview server starting as a preview check, not a parser check. Use parser-backed validation before considering syntax fixed.182183## Convert Between Formats1841851. Preserve the same actors, decision points, and branch labels when converting between ASCII and Mermaid.1862. Simplify the layout when a literal one-to-one conversion would hurt readability.1873. Verify that the converted diagram still communicates the same control flow and outcomes.188189## Final Checks1901911. Ensure every box and edge serves a purpose.1922. Ensure directionality is obvious on first read.1933. Ensure labels use the vocabulary from the source material rather than invented system names.1944. Ensure the diagram reads cleanly in the target medium without extra explanation.1955. Emit one final diagram block unless the user explicitly asks for alternatives.