JimLiu/baoyu-skills / skills/baoyu-diagram
baoyu-diagram
FlaggedCreate 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.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 15.8 KB |
| references/architecture.md | markdown | 3.1 KB |
| references/flowchart.md | markdown | 2.3 KB |
| references/sequence.md | markdown | 3.9 KB |
| references/structural.md | markdown | 3.8 KB |
| scripts/bun.lock | other | 8.1 KB |
| scripts/flatten-vars.ts | script | 1.3 KB |
| scripts/main.ts | script | 5.3 KB |
| scripts/package.json | manifest | 104 B |
| scripts/theme-switch.ts | script | 7.1 KB |
| scripts/themes.test.ts | script | 2.9 KB |
| scripts/themes.ts | script | 4.1 KB |
| themes/dark.json | config | 958 B |
| themes/light.json | config | 978 B |
references/structural.md
View on GitHub# Structural Diagram Layout
Covers: class diagrams, ER diagrams, component diagrams, package diagrams, org charts.
## Class Diagram
### Class Box (3-compartment)
```svg
<g transform="translate(X, Y)">
<!-- Mask -->
<rect width="180" height="120" rx="6" fill="var(--mask)"/>
<!-- Box -->
<rect width="180" height="120" rx="6" fill="var(--color-primary-fill)" stroke="var(--color-primary-stroke)" stroke-width="1.5"/>
<!-- Class name compartment -->
<text x="90" y="24" fill="var(--text)" font-size="11" font-weight="700" text-anchor="middle">ClassName</text>
<!-- Divider 1 -->
<line x1="0" y1="35" x2="180" y2="35" stroke="var(--color-primary-stroke)" stroke-width="0.5" stroke-opacity="0.5"/>
<!-- Attributes -->
<text x="10" y="52" fill="var(--text-muted)" font-size="8">- id: int</text>
<text x="10" y="64" fill="var(--text-muted)" font-size="8">- name: string</text>
<!-- Divider 2 -->
<line x1="0" y1="75" x2="180" y2="75" stroke="var(--color-primary-stroke)" stroke-width="0.5" stroke-opacity="0.5"/>
<!-- Methods -->
<text x="10" y="92" fill="var(--text-muted)" font-size="8">+ getName(): string</text>
<text x="10" y="104" fill="var(--text-muted)" font-size="8">+ setName(s: string)</text>
</g>
```
For abstract classes, italicize the class name. For interfaces, add `«interface»` above the name in smaller font.
### Relationship Lines
| Relationship | Line Style | Arrow/End |
|-------------|------------|-----------|
| Inheritance | Solid | Empty triangle (▷) pointing to parent |
| Implementation | Dashed | Empty triangle pointing to interface |
| Composition | Solid | Filled diamond (◆) at owner end |
| Aggregation | Solid | Empty diamond (◇) at owner end |
| Dependency | Dashed | Open arrowhead at dependency target |
| Association | Solid | Open arrowhead or none |
**Markers:**
```svg
<!-- Inheritance triangle -->
<marker id="inherit" markerWidth="12" markerHeight="10" refX="12" refY="5" orient="auto">
<polygon points="0 0, 12 5, 0 10" fill="var(--mask)" stroke="var(--text-muted)" stroke-width="1.5"/>
</marker>
<!-- Composition diamond -->
<marker id="composition" markerWidth="12" markerHeight="8" refX="0" refY="4" orient="auto">
<polygon points="0 4, 6 0, 12 4, 6 8" fill="var(--text-muted)"/>
</marker>
<!-- Aggregation diamond -->
<marker id="aggregation" markerWidth="12" markerHeight="8" refX="0" refY="4" orient="auto">
<polygon points="0 4, 6 0, 12 4, 6 8" fill="var(--mask)" stroke="var(--text-muted)" stroke-width="1.5"/>
</marker>
```
### Cardinality Labels
Place at each end of the relationship line, offset 5-8px from the box edge:
```svg
<text x="X" y="Y" fill="var(--text-muted)" font-size="8">1..*</text>
```
## ER Diagram
Similar to class diagrams but:
- Use 2-compartment boxes (entity name + attributes)
- Mark primary keys with `PK` prefix and bold
- Mark foreign keys with `FK` prefix
- Relationship lines use crow's foot notation:
```svg
<!-- One end (single line) -->
<line x1="X1" y1="Y" x2="X1+15" y2="Y" stroke="var(--text-muted)" stroke-width="1.5"/>
<!-- Many end (crow's foot) -->
<line x1="X2-15" y1="Y-6" x2="X2" y2="Y" stroke="var(--text-muted)" stroke-width="1.5"/>
<line x1="X2-15" y1="Y+6" x2="X2" y2="Y" stroke="var(--text-muted)" stroke-width="1.5"/>
<line x1="X2-15" y1="Y" x2="X2" y2="Y" stroke="var(--text-muted)" stroke-width="1.5"/>
```
## Org Chart
- Top-down tree layout
- Root at top center
- Each level evenly spaced (100-120px vertical gap)
- Siblings evenly distributed horizontally
- Connection lines: vertical from parent bottom center to horizontal bar, then vertical down to each child top center
- Use color to indicate departments or hierarchy levels
## Layout Tips
- Start by counting the widest level to determine total diagram width
- Center the tree horizontally in the viewBox
- For deep trees (5+ levels), consider horizontal layout instead
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |