SKILL.md
SKILL.mdBrowse 20 files
4,506 tokens
16,463 bytes
Token encoding: o200k_base
Snapshot 24fd22b
1---2name: concept-diagrams3description: Generate flat, minimal educational SVG visuals as HTML.4version: 0.1.05author: v1k22 (original PR), ported into hermes-agent6license: MIT7dependencies: []8platforms: [linux, macos, windows]9metadata:10 hermes:11 tags: [diagrams, svg, visualization, education, physics, chemistry, engineering]12 related_skills: [architecture-diagram, excalidraw]13---14 15# Concept Diagrams16 17Generate production-quality SVG diagrams with a unified flat, minimal design system. Output is a single self-contained HTML file that renders identically in any modern browser, with automatic light/dark mode.18 19## Scope20 21**Best suited for:**22- Physics setups, chemistry mechanisms, math curves, biology23- Physical objects (aircraft, turbines, smartphones, mechanical watches, cells)24- Anatomy, cross-sections, exploded layer views25- Floor plans, architectural conversions26- Narrative journeys (lifecycle of X, process of Y)27- Hub-spoke system integrations (smart city, IoT networks, electricity grids)28- Educational / textbook-style visuals in any domain29- Quantitative charts (grouped bars, energy profiles)30 31**Look elsewhere first for:**32- Dedicated software / cloud infrastructure architecture with a dark tech aesthetic (consider `architecture-diagram` if available)33- Hand-drawn whiteboard sketches (consider `excalidraw` if available)34- Animated explainers or video output (consider an animation skill)35 36If a more specialized skill is available for the subject, prefer that. If none fits, this skill can serve as a general-purpose SVG diagram fallback — the output will carry the clean educational aesthetic described below, which is a reasonable default for almost any subject.37 38## Workflow39 401. Decide on the diagram type (see Diagram Types below).412. Lay out components using the Design System rules.423. Write the full HTML page using `templates/template.html` as the wrapper — paste your SVG where the template says `<!-- PASTE SVG HERE -->`.434. Save as a standalone `.html` file (for example `~/my-diagram.html` or `./my-diagram.html`).445. User opens it directly in a browser — no server, no dependencies.45 46Optional: if the user wants a browsable gallery of multiple diagrams, see "Local Preview Server" at the bottom.47 48Load the HTML template:49```50skill_view(name="concept-diagrams", file_path="templates/template.html")51```52 53The template embeds the full CSS design system (`c-*` color classes, text classes, light/dark variables, arrow marker styles). The SVG you generate relies on these classes being present on the hosting page.54 55---56 57## Design System58 59### Philosophy60 61- **Flat**: no gradients, drop shadows, blur, glow, or neon effects.62- **Minimal**: show the essential. No decorative icons inside boxes.63- **Consistent**: same colors, spacing, typography, and stroke widths across every diagram.64- **Dark-mode ready**: all colors auto-adapt via CSS classes — no per-mode SVG.65 66### Color Palette67 689 color ramps, each with 7 stops. Put the class name on a `<g>` or shape element; the template CSS handles both modes.69 70| Class | 50 (lightest) | 100 | 200 | 400 | 600 | 800 | 900 (darkest) |71|------------|---------------|---------|---------|---------|---------|---------|---------------|72| `c-purple` | #EEEDFE | #CECBF6 | #AFA9EC | #7F77DD | #534AB7 | #3C3489 | #26215C |73| `c-teal` | #E1F5EE | #9FE1CB | #5DCAA5 | #1D9E75 | #0F6E56 | #085041 | #04342C |74| `c-coral` | #FAECE7 | #F5C4B3 | #F0997B | #D85A30 | #993C1D | #712B13 | #4A1B0C |75| `c-pink` | #FBEAF0 | #F4C0D1 | #ED93B1 | #D4537E | #993556 | #72243E | #4B1528 |76| `c-gray` | #F1EFE8 | #D3D1C7 | #B4B2A9 | #888780 | #5F5E5A | #444441 | #2C2C2A |77| `c-blue` | #E6F1FB | #B5D4F4 | #85B7EB | #378ADD | #185FA5 | #0C447C | #042C53 |78| `c-green` | #EAF3DE | #C0DD97 | #97C459 | #639922 | #3B6D11 | #27500A | #173404 |79| `c-amber` | #FAEEDA | #FAC775 | #EF9F27 | #BA7517 | #854F0B | #633806 | #412402 |80| `c-red` | #FCEBEB | #F7C1C1 | #F09595 | #E24B4A | #A32D2D | #791F1F | #501313 |81 82#### Color Assignment Rules83 84Color encodes **meaning**, not sequence. Never cycle through colors like a rainbow.85 86- Group nodes by **category** — all nodes of the same type share one color.87- Use `c-gray` for neutral/structural nodes (start, end, generic steps, users).88- Use **2-3 colors per diagram**, not 6+.89- Prefer `c-purple`, `c-teal`, `c-coral`, `c-pink` for general categories.90- Reserve `c-blue`, `c-green`, `c-amber`, `c-red` for semantic meaning (info, success, warning, error).91 92Light/dark stop mapping (handled by the template CSS — just use the class):93- Light mode: 50 fill + 600 stroke + 800 title / 600 subtitle94- Dark mode: 800 fill + 200 stroke + 100 title / 200 subtitle95 96### Typography97 98Only two font sizes. No exceptions.99 100| Class | Size | Weight | Use |101|-------|------|--------|-----|102| `th` | 14px | 500 | Node titles, region labels |103| `ts` | 12px | 400 | Subtitles, descriptions, arrow labels |104| `t` | 14px | 400 | General text |105 106- **Sentence case always.** Never Title Case, never ALL CAPS.107- Every `<text>` MUST carry a class (`t`, `ts`, or `th`). No unclassed text.108- `dominant-baseline="central"` on all text inside boxes.109- `text-anchor="middle"` for centered text in boxes.110 111**Width estimation (approx):**112- 14px weight 500: ~8px per character113- 12px weight 400: ~6.5px per character114- Always verify: `box_width >= (char_count × px_per_char) + 48` (24px padding each side)115 116### Spacing & Layout117 118- **ViewBox**: `viewBox="0 0 680 H"` where H = content height + 40px buffer.119- **Safe area**: x=40 to x=640, y=40 to y=(H-40).120- **Between boxes**: 60px minimum gap.121- **Inside boxes**: 24px horizontal padding, 12px vertical padding.122- **Arrowhead gap**: 10px between arrowhead and box edge.123- **Single-line box**: 44px height.124- **Two-line box**: 56px height, 18px between title and subtitle baselines.125- **Container padding**: 20px minimum inside every container.126- **Max nesting**: 2-3 levels deep. Deeper gets unreadable at 680px width.127 128### Stroke & Shape129 130- **Stroke width**: 0.5px on all node borders. Not 1px, not 2px.131- **Rect rounding**: `rx="8"` for nodes, `rx="12"` for inner containers, `rx="16"` to `rx="20"` for outer containers.132- **Connector paths**: MUST have `fill="none"`. SVG defaults to `fill: black` otherwise.133 134### Arrow Marker135 136Include this `<defs>` block at the start of **every** SVG:137 138```xml139<defs>140 <marker id="arrow" viewBox="0 0 10 10" refX="8" refY="5"141 markerWidth="6" markerHeight="6" orient="auto-start-reverse">142 <path d="M2 1L8 5L2 9" fill="none" stroke="context-stroke"143 stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>144 </marker>145</defs>146```147 148Use `marker-end="url(#arrow)"` on lines. The arrowhead inherits the line color via `context-stroke`.149 150### CSS Classes (Provided by the Template)151 152The template page provides:153 154- Text: `.t`, `.ts`, `.th`155- Neutral: `.box`, `.arr`, `.leader`, `.node`156- Color ramps: `.c-purple`, `.c-teal`, `.c-coral`, `.c-pink`, `.c-gray`, `.c-blue`, `.c-green`, `.c-amber`, `.c-red` (all with automatic light/dark mode)157 158You do **not** need to redefine these — just apply them in your SVG. The template file contains the full CSS definitions.159 160---161 162## SVG Boilerplate163 164Every SVG inside the template page starts with this exact structure:165 166```xml167<svg width="100%" viewBox="0 0 680 {HEIGHT}" xmlns="http://www.w3.org/2000/svg">168 <defs>169 <marker id="arrow" viewBox="0 0 10 10" refX="8" refY="5"170 markerWidth="6" markerHeight="6" orient="auto-start-reverse">171 <path d="M2 1L8 5L2 9" fill="none" stroke="context-stroke"172 stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>173 </marker>174 </defs>175 176 <!-- Diagram content here -->177 178</svg>179```180 181Replace `{HEIGHT}` with the actual computed height (last element bottom + 40px).182 183### Node Patterns184 185**Single-line node (44px):**186```xml187<g class="node c-blue">188 <rect x="100" y="20" width="180" height="44" rx="8" stroke-width="0.5"/>189 <text class="th" x="190" y="42" text-anchor="middle" dominant-baseline="central">Service name</text>190</g>191```192 193**Two-line node (56px):**194```xml195<g class="node c-teal">196 <rect x="100" y="20" width="200" height="56" rx="8" stroke-width="0.5"/>197 <text class="th" x="200" y="38" text-anchor="middle" dominant-baseline="central">Service name</text>198 <text class="ts" x="200" y="56" text-anchor="middle" dominant-baseline="central">Short description</text>199</g>200```201 202**Connector (no label):**203```xml204<line x1="200" y1="76" x2="200" y2="120" class="arr" marker-end="url(#arrow)"/>205```206 207**Container (dashed or solid):**208```xml209<g class="c-purple">210 <rect x="40" y="92" width="600" height="300" rx="16" stroke-width="0.5"/>211 <text class="th" x="66" y="116">Container label</text>212 <text class="ts" x="66" y="134">Subtitle info</text>213</g>214```215 216---217 218## Diagram Types219 220Choose the layout that fits the subject:221 2221. **Flowchart** — CI/CD pipelines, request lifecycles, approval workflows, data processing. Single-direction flow (top-down or left-right). Max 4-5 nodes per row.2232. **Structural / Containment** — Cloud infrastructure nesting, system architecture with layers. Large outer containers with inner regions. Dashed rects for logical groupings.2243. **API / Endpoint Map** — REST routes, GraphQL schemas. Tree from root, branching to resource groups, each containing endpoint nodes.2254. **Microservice Topology** — Service mesh, event-driven systems. Services as nodes, arrows for communication patterns, message queues between.2265. **Data Flow** — ETL pipelines, streaming architectures. Left-to-right flow from sources through processing to sinks.2276. **Physical / Structural** — Vehicles, buildings, hardware, anatomy. Use shapes that match the physical form — `<path>` for curved bodies, `<polygon>` for tapered shapes, `<ellipse>`/`<circle>` for cylindrical parts, nested `<rect>` for compartments. See `references/physical-shape-cookbook.md`.2287. **Infrastructure / Systems Integration** — Smart cities, IoT networks, multi-domain systems. Hub-spoke layout with central platform connecting subsystems. Semantic line styles (`.data-line`, `.power-line`, `.water-pipe`, `.road`). See `references/infrastructure-patterns.md`.2298. **UI / Dashboard Mockups** — Admin panels, monitoring dashboards. Screen frame with nested chart/gauge/indicator elements. See `references/dashboard-patterns.md`.230 231For physical, infrastructure, and dashboard diagrams, load the matching reference file before generating — each one provides ready-made CSS classes and shape primitives.232 233---234 235## Validation Checklist236 237Before finalizing any SVG, verify ALL of the following:238 2391. Every `<text>` has class `t`, `ts`, or `th`.2402. Every `<text>` inside a box has `dominant-baseline="central"`.2413. Every connector `<path>` or `<line>` used as arrow has `fill="none"`.2424. No arrow line crosses through an unrelated box.2435. `box_width >= (longest_label_chars × 8) + 48` for 14px text.2446. `box_width >= (longest_label_chars × 6.5) + 48` for 12px text.2457. ViewBox height = bottom-most element + 40px.2468. All content stays within x=40 to x=640.2479. Color classes (`c-*`) are on `<g>` or shape elements, never on `<path>` connectors.24810. Arrow `<defs>` block is present.24911. No gradients, shadows, blur, or glow effects.25012. Stroke width is 0.5px on all node borders.251 252---253 254## Output & Preview255 256### Default: standalone HTML file257 258Write a single `.html` file the user can open directly. No server, no dependencies, works offline. Pattern:259 260```python261# 1. Load the template262template = skill_view("concept-diagrams", "templates/template.html")263 264# 2. Fill in title, subtitle, and paste your SVG265html = template.replace(266 "<!-- DIAGRAM TITLE HERE -->", "SN2 reaction mechanism"267).replace(268 "<!-- OPTIONAL SUBTITLE HERE -->", "Bimolecular nucleophilic substitution"269).replace(270 "<!-- PASTE SVG HERE -->", svg_content271)272 273# 3. Write to a user-chosen path (or ./ by default)274write_file("./sn2-mechanism.html", html)275```276 277Tell the user how to open it:278 279```280# macOS281open ./sn2-mechanism.html282# Linux283xdg-open ./sn2-mechanism.html284```285 286### Optional: local preview server (multi-diagram gallery)287 288Only use this when the user explicitly wants a browsable gallery of multiple diagrams.289 290**Rules:**291- Bind to `127.0.0.1` only. Never `0.0.0.0`. Exposing diagrams on all network interfaces is a security hazard on shared networks.292- Pick a free port (do NOT hard-code one) and tell the user the chosen URL.293- The server is optional and opt-in — prefer the standalone HTML file first.294 295Recommended pattern (lets the OS pick a free ephemeral port):296 297```bash298# Put each diagram in its own folder under .diagrams/299mkdir -p .diagrams/sn2-mechanism300# ...write .diagrams/sn2-mechanism/index.html...301 302# Serve on loopback only, free port303cd .diagrams && python -c "304import http.server, socketserver305with socketserver.TCPServer(('127.0.0.1', 0), http.server.SimpleHTTPRequestHandler) as s:306 print(f'Serving at http://127.0.0.1:{s.server_address[1]}/')307 s.serve_forever()308" &309```310 311If the user insists on a fixed port, use `127.0.0.1:<port>` — still never `0.0.0.0`. Document how to stop the server (`kill %1` or `pkill -f "http.server"`).312 313---314 315## Examples Reference316 317The `examples/` directory ships 15 complete, tested diagrams. Browse them for working patterns before writing a new diagram of a similar type:318 319| File | Type | Demonstrates |320|------|------|--------------|321| `hospital-emergency-department-flow.md` | Flowchart | Priority routing with semantic colors |322| `feature-film-production-pipeline.md` | Flowchart | Phased workflow, horizontal sub-flows |323| `automated-password-reset-flow.md` | Flowchart | Auth flow with error branches |324| `autonomous-llm-research-agent-flow.md` | Flowchart | Loop-back arrows, decision branches |325| `place-order-uml-sequence.md` | Sequence | UML sequence diagram style |326| `commercial-aircraft-structure.md` | Physical | Paths, polygons, ellipses for realistic shapes |327| `wind-turbine-structure.md` | Physical cross-section | Underground/above-ground separation, color coding |328| `smartphone-layer-anatomy.md` | Exploded view | Alternating left/right labels, layered components |329| `apartment-floor-plan-conversion.md` | Floor plan | Walls, doors, proposed changes in dotted red |330| `banana-journey-tree-to-smoothie.md` | Narrative journey | Winding path, progressive state changes |331| `cpu-ooo-microarchitecture.md` | Hardware pipeline | Fan-out, memory hierarchy sidebar |332| `sn2-reaction-mechanism.md` | Chemistry | Molecules, curved arrows, energy profile |333| `smart-city-infrastructure.md` | Hub-spoke | Semantic line styles per system |334| `electricity-grid-flow.md` | Multi-stage flow | Voltage hierarchy, flow markers |335| `ml-benchmark-grouped-bar-chart.md` | Chart | Grouped bars, dual axis |336 337Load any example with:338```339skill_view(name="concept-diagrams", file_path="examples/<filename>")340```341 342---343 344## Quick Reference: What to Use When345 346| User says | Diagram type | Suggested colors |347|-----------|--------------|------------------|348| "show the pipeline" | Flowchart | gray start/end, purple steps, red errors, teal deploy |349| "draw the data flow" | Data pipeline (left-right) | gray sources, purple processing, teal sinks |350| "visualize the system" | Structural (containment) | purple container, teal services, coral data |351| "map the endpoints" | API tree | purple root, one ramp per resource group |352| "show the services" | Microservice topology | gray ingress, teal services, purple bus, coral workers |353| "draw the aircraft/vehicle" | Physical | paths, polygons, ellipses for realistic shapes |354| "smart city / IoT" | Hub-spoke integration | semantic line styles per subsystem |355| "show the dashboard" | UI mockup | dark screen, chart colors: teal, purple, coral for alerts |356| "power grid / electricity" | Multi-stage flow | voltage hierarchy (HV/MV/LV line weights) |357| "wind turbine / turbine" | Physical cross-section | foundation + tower cutaway + nacelle color-coded |358| "journey of X / lifecycle" | Narrative journey | winding path, progressive state changes |359| "layers of X / exploded" | Exploded layer view | vertical stack, alternating labels |360| "CPU / pipeline" | Hardware pipeline | vertical stages, fan-out to execution ports |361| "floor plan / apartment" | Floor plan | walls, doors, proposed changes in dotted red |362| "reaction mechanism" | Chemistry | atoms, bonds, curved arrows, transition state, energy profile |363 Discovery context
Discovered by repository scan. No exact path reference found in the snapshot’s root AGENTS.md.