Skip to content

Commit c459164

Browse files
nicobailonjanah01
andcommitted
feat: add class diagram and C4 architecture support
Class diagrams: - Add classDiagram guidance for OOP design and domain modeling - Document relationships: association, composition, aggregation, inheritance - Note erDiagram as alternative for simple entity-only models C4 architecture: - Use graph TD + subgraph instead of native C4Context - Native C4 ignores themeVariables (hardcoded corners, fonts, colors) - Document flowchart-as-C4 pattern with classDef for external systems Directory tree CSS: - Add .dir-tree pattern for file structures with tree connectors - Add .dir-tree-card and .dir-compare for labeled/side-by-side trees - Enforce white-space: pre to preserve vertical alignment Also adds quick-reference table for choosing Mermaid diagram types. Co-authored-by: janah01 <janah01@users.noreply.github.com> Closes #16
1 parent 76bd4cb commit c459164

File tree

3 files changed

+122
-2
lines changed

3 files changed

+122
-2
lines changed

SKILL.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ For prose accents, see "Prose Page Elements" in `./references/css-patterns.md`.
2828

2929
**Who is looking?** A developer understanding a system? A PM seeing the big picture? A team reviewing a proposal? This shapes information density and visual complexity.
3030

31-
**What type of content?** Architecture, flowchart, sequence, data flow, schema/ER, state machine, mind map, data table, timeline, dashboard, or prose-first page. Each has distinct layout needs and rendering approaches (see Diagram Types below).
31+
**What type of content?** Architecture, flowchart, sequence, data flow, schema/ER, state machine, mind map, class diagram, C4 architecture, data table, timeline, dashboard, or prose-first page. Each has distinct layout needs and rendering approaches (see Diagram Types below).
3232

3333
**What aesthetic?** Pick one and commit. The constrained aesthetics (Blueprint, Editorial, Paper/ink) are safer — they have specific requirements that prevent generic output. The flexible ones (IDE-inspired) require more discipline.
3434

@@ -53,7 +53,7 @@ Vary the choice each time. If the last diagram was dark and technical, make the
5353

5454
**Read the reference material** before generating. Don't memorize it — read it each time to absorb the patterns.
5555
- For text-heavy architecture overviews (card content matters more than topology): read `./templates/architecture.html`
56-
- For flowcharts, sequence diagrams, ER, state machines, mind maps: read `./templates/mermaid-flowchart.html`
56+
- For flowcharts, sequence diagrams, ER, state machines, mind maps, class diagrams, C4: read `./templates/mermaid-flowchart.html`
5757
- For data tables, comparisons, audits, feature matrices: read `./templates/data-table.html`
5858
- For slide deck presentations (when `--slides` flag is present or `/generate-slides` is invoked): read `./templates/slide-deck.html` and `./references/slide-patterns.md`
5959
- For prose-heavy publishable pages (READMEs, articles, blog posts, essays): read the "Prose Page Elements" section in `./references/css-patterns.md` and "Typography by Content Voice" in `./references/libraries.md`
@@ -74,6 +74,8 @@ Vary the choice each time. If the last diagram was dark and technical, make the
7474
| ER / schema diagram | **Mermaid** | Relationship lines between many entities need auto-routing |
7575
| State machine | **Mermaid** | State transitions with labeled edges need automatic layout |
7676
| Mind map | **Mermaid** | Hierarchical branching needs automatic positioning |
77+
| Class diagram | **Mermaid** | Inheritance, composition, aggregation lines with automatic routing |
78+
| C4 architecture | **Mermaid** | Use `graph TD` + `subgraph` for C4 (not native `C4Context` — it ignores themes) |
7779
| Data table | HTML `<table>` | Semantic markup, accessibility, copy-paste behavior |
7880
| Timeline | CSS (central line + cards) | Simple linear layout doesn't need a layout engine |
7981
| Dashboard | CSS Grid + Chart.js | Card grid with embedded charts |
@@ -211,6 +213,14 @@ Three approaches depending on complexity:
211213
### Mind Maps / Hierarchical Breakdowns
212214
**Use Mermaid.** Use `mindmap` syntax for hierarchical branching from a root node. Mermaid handles the radial layout automatically. Style with `themeVariables` to control node colors at each depth level.
213215

216+
### Class Diagrams
217+
**Use Mermaid.** Use `classDiagram` syntax for domain modeling, OOP design, and entity relationships with typed properties and methods. Supports relationships: association (`-->`), composition (`*--`), aggregation (`o--`), and inheritance (`<|--`). Add multiplicity labels (e.g., `"1" --> "*"`) and abstract/interface markers (`<<interface>>`, `<<abstract>>`). For simple entity boxes without OOP semantics (no methods, no inheritance), prefer `erDiagram` instead — it produces cleaner output for pure data modeling.
218+
219+
### C4 Architecture Diagrams
220+
**Use Mermaid flowchart syntax — NOT native C4.** Use `graph TD` with `subgraph` blocks for C4 boundaries. Native `C4Context` hardcodes sharp corners, its own font, blue icons, and inline SVG colors that ignore `themeVariables` — it always clashes with custom palettes.
221+
222+
**Flowchart-as-C4 pattern:** Persons → rounded nodes `(("Name"))`, systems → rectangles `["Name"]`, databases → cylinders `[("Name")]`, boundaries → `subgraph` blocks, relationships → labeled arrows `-->|"protocol"|`. Use `classDef` + `:::className` to visually differentiate external systems (e.g., dashed borders). This inherits `themeVariables`, `fontFamily`, and CSS overrides like every other Mermaid diagram.
223+
214224
### Data Tables / Comparisons / Audits
215225
Use a real `<table>` element — not CSS Grid pretending to be a table. Tables get accessibility, copy-paste behavior, and column alignment for free. The reference template at `./templates/data-table.html` demonstrates all patterns below.
216226

references/css-patterns.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,57 @@ For implementation plans and architecture docs, **don't display entire source fi
288288

289289
If someone needs the full file, put it in a collapsible section or link to it.
290290

291+
## Directory Tree
292+
293+
For file structures, use `<pre>` with monospace + `white-space: pre`. Tree connectors (`├──`, `└──`, ``) only work when vertically aligned — they become noise if text wraps.
294+
295+
```css
296+
.dir-tree {
297+
font-family: var(--font-mono);
298+
font-size: 13px;
299+
line-height: 1.7;
300+
background: var(--surface);
301+
border: 1px solid var(--border);
302+
border-radius: 8px;
303+
padding: 16px 20px;
304+
overflow-x: auto;
305+
white-space: pre;
306+
}
307+
308+
.dir-tree .ann { color: var(--text-dim); font-size: 11px; font-style: italic; }
309+
.dir-tree .hl { color: var(--accent); font-weight: 600; }
310+
```
311+
312+
```html
313+
<pre class="dir-tree">my-project/
314+
├── src/
315+
│ ├── <span class="hl">index.ts</span> <span class="ann">— entry point</span>
316+
│ ├── services/
317+
│ │ └── <span class="hl">api.py</span> <span class="ann">(142 lines)</span>
318+
│ └── utils/
319+
├── tests/ <span class="ann">(14 test files)</span>
320+
└── README.md</pre>
321+
```
322+
323+
For labeled trees, wrap in a card. For side-by-side comparisons, put two cards in a grid:
324+
325+
```css
326+
.dir-tree-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
327+
.dir-tree-card__header {
328+
display: flex; align-items: center; gap: 8px;
329+
padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
330+
font-family: var(--font-mono); font-size: 11px; font-weight: 600;
331+
text-transform: uppercase; letter-spacing: 1.5px;
332+
}
333+
.dir-tree-card .dir-tree { border: none; border-radius: 0; }
334+
335+
/* Side-by-side: two .dir-tree-card in a grid */
336+
.dir-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
337+
@media (max-width: 900px) { .dir-compare { grid-template-columns: 1fr; } }
338+
```
339+
340+
**Never** render tree connectors inside wrapping text (`white-space: normal`), flex children, or grid items — the vertical pipes lose alignment and the hierarchy becomes unreadable.
341+
291342
## Overflow Protection
292343

293344
Grid and flex children default to `min-width: auto`, which prevents them from shrinking below their content width. Long text, inline code badges, and non-wrapping elements will blow out containers.

references/libraries.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,65 @@ mindmap
374374
</pre>
375375
```
376376

377+
**Class diagram:**
378+
```html
379+
<pre class="mermaid">
380+
classDiagram
381+
class User {
382+
+string email
383+
+string name
384+
+login()
385+
+logout()
386+
}
387+
class Order {
388+
+int id
389+
+decimal total
390+
+submit()
391+
}
392+
class Product {
393+
+string name
394+
+decimal price
395+
}
396+
User "1" --> "*" Order : places
397+
Order "*" --> "*" Product : contains
398+
</pre>
399+
```
400+
401+
**C4 architecture (flowchart-as-C4):**
402+
```html
403+
<pre class="mermaid">
404+
graph TD
405+
user("👤 User<br/><small>Browser client</small>")
406+
subgraph boundary["Web Platform"]
407+
app["Web App<br/><small>Node.js</small>"]
408+
db[("Database<br/><small>PostgreSQL</small>")]
409+
end
410+
email["📧 Email Service"]:::ext
411+
payment["💳 Payment Gateway"]:::ext
412+
user -->|"HTTPS"| app
413+
app -->|"SQL"| db
414+
app -->|"SMTP"| email
415+
app -->|"API"| payment
416+
classDef ext fill:none,stroke-dasharray:5 5
417+
</pre>
418+
```
419+
420+
Do NOT use native `C4Context` / `C4Container` syntax — it hardcodes sharp corners, its own font, and inline colors that ignore `themeVariables`. Use `graph TD` + `subgraph` for C4 boundaries instead; it inherits all theme settings automatically.
421+
422+
### Which Mermaid Diagram Type?
423+
424+
Quick-reference for choosing the right Mermaid syntax:
425+
426+
| You want to show... | Use | Syntax keyword |
427+
|---|---|---|
428+
| Process flow, decisions, pipelines | Flowchart | `graph TD` / `graph LR` |
429+
| Request/response, API calls, temporal interactions | Sequence diagram | `sequenceDiagram` |
430+
| Database tables and relationships | ER diagram | `erDiagram` |
431+
| OOP classes, domain models with methods | Class diagram | `classDiagram` |
432+
| System architecture at multiple zoom levels | C4 diagram | `graph TD` + `subgraph` (not native `C4Context`) |
433+
| State transitions, lifecycles | State diagram | `stateDiagram-v2` |
434+
| Hierarchical breakdowns, brainstorms | Mind map | `mindmap` |
435+
377436
### Dark Mode Handling
378437

379438
Mermaid initializes once — it can't reactively switch themes. Read the preference at load time inside your `<script type="module">`:

0 commit comments

Comments
 (0)