--- name: baoyu-diagram description: Create professional diagrams with configurable dark/light theme via CSS custom properties. Use this skill whenever the user asks for any kind of technical or conceptual diagram, visualization of a system, process flow, data flow, component relationship, network topology, decision tree, org chart, state machine, or any visual representation of structure/logic/process. Also trigger when the user says "画个图" "画一个架构图" "diagram" "flowchart" "sequence diagram" "draw me a ..." or uploads content and asks to visualize it. Outputs a dark-theme SVG, a light-theme SVG, and a @2x PNG of each. version: 1.118.0 --- # Diagram Generator Create SVG diagrams. Each SVG embeds its own styles, uses CSS custom properties for theming, and loads nothing over the network. ## Output Files For a diagram saved as `.svg`, produce exactly these files: | File | What it is | Made by | |------|-----------|---------| | `.svg` | Source SVG, CSS variables with dark theme values | You (the LLM) | | `.light.svg` | Same markup with light theme values | `theme-switch.ts --theme=light` | | `@2x.png` | Dark PNG at 2x scale | `main.ts` | | `.light@2x.png` | Light PNG at 2x scale | `main.ts --theme light` | If the user asks for only one theme, or only SVG, produce just those files. ## Themes All colors are CSS custom properties defined in the `:root` block of the SVG's ` ``` Font sizes by role: - **Title:** 16px, weight 700, fill: `var(--text)` - **Component name:** 11-12px, weight 600, fill: `var(--text)` - **Sublabel / description:** 9px, weight 400, fill: `var(--text-muted)` - **Annotation / note:** 8px, weight 400 - **Tiny label (on arrows):** 7-8px ### Core Visual Elements **Background + Grid:** ```svg ``` **Arrowhead marker (standard):** ```svg ``` **Arrowhead marker (colored) — create per-color as needed:** ```svg ``` **Open arrowhead (for async/return messages):** ```svg ``` ### SVG Structure & Layering Draw in this order (SVG paints back-to-front): 1. Background fill + grid pattern 2. Region/group boundaries (dashed outlines) 3. Connection arrows and lines 4. Opaque masking rects (same position as component boxes, `fill="var(--mask)"`) 5. Component boxes (semi-transparent fill + stroke via CSS variables) 6. Text labels 7. Legend (bottom-right or bottom area, outside all boundaries) 8. Title block (top-left) The opaque mask rect is required — semi-transparent component fills otherwise show arrows underneath: ```svg API Gateway Kong / Nginx ``` ### Spacing Rules Follow strictly to prevent overlaps: - **Component box height:** 50-70px (standard), 80-120px (large/complex) - **Minimum gap between components:** 40px vertical, 30px horizontal - **Arrow label clearance:** 10px from any box edge - **Region boundary padding:** 20px inside edges around contained components - **Legend placement:** At least 20px below the lowest diagram element - **Title block:** 20px from top-left, outside diagram content area - **viewBox:** Always extend to fit all content + 30px padding on all sides ### Component Patterns **Standard box (service/process):** ```svg Name description ``` **Decision diamond (flowchart):** ```svg Condition? ``` **Database cylinder:** ```svg PostgreSQL ``` **Region boundary:** ```svg AWS us-east-1 ``` **Security group:** ```svg VPC / Security Group ``` ## Diagram Types & Layout Determine this SKILL.md file's directory path as `{baseDir}`. Before layout, read the type's reference in `{baseDir}/references/` if one exists. | Type | When to use | Reference | Layout key points | |------|-------------|-----------|-------------------| | Architecture | System components & relationships | `references/architecture.md` | LTR or TTB data flow; group related services in region boundaries; buses/connectors between layers; databases at bottom or right | | Flowchart | Decision logic, process steps | `references/flowchart.md` | Top-to-bottom primary flow; diamonds with Yes/No labels on exit arrows; rounded rects for start/end; Highlight color for the happy path | | Sequence | Time-ordered interactions between actors | `references/sequence.md` | Actor boxes at top, vertical dashed lifelines; horizontal messages (solid=sync, dashed=return); time flows down; activation bars; number messages if complex | | Structural | Class/ER diagrams, org charts | `references/structural.md` | Compartmented boxes (name / attributes / methods); filled diamond=composition, empty diamond=aggregation, dashed arrow=dependency, solid triangle=inheritance | | Mind Map | Brainstorming, topic exploration | — | Radiating layout from a central concept; cubic-bezier `` branches; vary branch colors; font size decreases outward | | Timeline | Chronological events | — | Horizontal or vertical axis; circle/diamond event markers, period spans; descriptions on alternating sides; color by event type | | State Machine | State transitions, lifecycle | — | Rounded-rect states, double border for composite; filled circle = initial, bullseye = final; curved self-transitions; label transitions `event [guard] / action` | | Illustrative | Conceptual explanations, comparisons | — | Free-form layout, icons, annotations, visual metaphors | | Data Flow | Data transformation pipelines | — | Process bubbles, data stores, external entities | ## Output Rules 1. Each SVG is a **single file with no external resources** — no `@import`, web fonts, remote images or scripts 2. Set `viewBox` to fit all content with 30px padding; do NOT set fixed `width`/`height` attributes 3. Include `xmlns="http://www.w3.org/2000/svg"` on the root `` 4. Put all `