class-module-diagramming
UML class + module diagrams — classes / interfaces / enums with visibility, inheritance / implementation / composition / aggregation / association / dependency relationships, multiplicities, package boundaries. Mermaid classDiagram.
What this skill does
# Class + Module Diagramming
You produce structural diagrams for code — at class, interface, package, or module level. Each diagram has a clear purpose; avoid the kitchen-sink diagram.
## Core rules
- **One purpose per diagram** — "domain model" or "port/adapter layout" or "hierarchy", not all three
- **Show what matters** — omit trivial helpers, getters/setters, obvious deps
- **Visibility explicit** — `+` public, `-` private, `#` protected, `~` package
- **Relationships distinct** — inheritance vs composition vs association vs dependency
- **Multiplicity noted** when non-obvious (`1..*`, `0..1`, `*`)
- **Module boundaries** when crossing bounded contexts or layers
- **No fabricated members** — work from supplied structure
## Input handling
| Dimension | Required | Default |
|---|---|---|
| **Subject** (domain / module / component) | Yes | — |
| **Scope** (what to include / exclude) | Yes | — |
| **Target audience** | No | Asked |
| **Existing code** | No | Asked |
## Phase 1 — Setup
```
**Subject**: [what's being diagrammed]
**Purpose**: [domain model / hierarchy / layer structure / adapters]
**Scope**: [included / excluded]
**Audience**: [architects / new devs / reviewers]
**Source**: [new design / documenting existing / refactor target]
```
Ask render mode per `diagram-rendering` mixin and output path (default: `/documentation/[case]/class-diagrams/[subject]/`).
## Phase 2 — Element types
| Element | Mermaid |
|---|---|
| Class | `class Order { ... }` |
| Interface | `class OrderRepository { <<interface>> ... }` |
| Abstract class | `class Shape { <<abstract>> ... }` |
| Enum | `class Status { <<enumeration>> PENDING PAID }` |
| Annotation / stereotype | `<<service>>`, `<<value-object>>`, `<<aggregate-root>>` |
| Package | Mermaid doesn't natively group; use comment separators or split diagrams |
Stereotypes help when diagramming DDD: `<<entity>>`, `<<value-object>>`, `<<aggregate-root>>`, `<<domain-service>>`, `<<repository>>`.
## Phase 3 — Members
### Visibility
- `+` public
- `-` private
- `#` protected
- `~` package-private
### Attributes
```
class Order {
+OrderId id
-OrderStatus status
-Money total
-List~OrderLine~ lines
}
```
### Methods
```
class Order {
+place() void
+cancel(reason: String) void
+markPaid() void
}
```
Include only methods that participate in the public/contract view; skip getters unless they mean something.
## Phase 4 — Relationships
| Relationship | Meaning | Mermaid |
|---|---|---|
| Inheritance | "is-a" | `Dog --|> Animal` |
| Implementation | implements interface | `OrderServiceImpl ..|> OrderService` |
| Composition | strong whole-part (lifetime bound) | `Order *-- OrderLine` |
| Aggregation | weak whole-part (shared lifetime ok) | `Team o-- Player` |
| Association | general relation | `Customer -- Order` |
| Dependency | uses-a (non-structural) | `OrderService ..> Logger` |
Multiplicities: `"1" -- "0..*"`, `"1..*"`, etc.
## Phase 5 — Domain model example
```mermaid
classDiagram
class Order {
<<aggregate-root>>
+OrderId id
-OrderStatus status
-Money total
+place()
+cancel(reason)
+markPaid()
}
class OrderLine {
<<value-object>>
+Sku sku
+Quantity quantity
+Money unitPrice
}
class OrderStatus {
<<enumeration>>
PENDING
PLACED
PAID
CANCELLED
FULFILLED
}
class OrderRepository {
<<interface>>
+save(Order) Order
+findById(OrderId) Order
}
class PostgresOrderRepository {
}
Order "1" *-- "1..*" OrderLine
Order --> OrderStatus
PostgresOrderRepository ..|> OrderRepository
```
## Phase 6 — Layer / ports-adapters example
```mermaid
classDiagram
class OrderService {
<<application>>
}
class OrderRepository {
<<port>>
<<interface>>
}
class EventPublisher {
<<port>>
<<interface>>
}
class PostgresOrderRepository {
<<adapter>>
}
class KafkaEventPublisher {
<<adapter>>
}
class HTTPController {
<<adapter>>
}
HTTPController ..> OrderService
OrderService ..> OrderRepository
OrderService ..> EventPublisher
PostgresOrderRepository ..|> OrderRepository
KafkaEventPublisher ..|> EventPublisher
```
## Phase 7 — Hierarchy / inheritance diagram
Use for class-hierarchy questions only; keep branches shallow. Prefer composition diagrams unless the question is about substitutability / Liskov.
## Phase 8 — Package / module diagram
Mermaid has limited package syntax; use `graph` instead of `classDiagram` when focused on packages:
```mermaid
graph TD
subgraph orders
OrderHttp
OrderApp
OrderDomain
OrderInfra
end
subgraph payments
PaymentApp
end
OrderApp --> OrderDomain
OrderInfra --> OrderDomain
OrderHttp --> OrderApp
OrderApp -.publishes.-> PaymentApp
```
Document the rule for cross-module calls:
- Layers: only downward
- Bounded contexts: only via published contract (event or API)
## Phase 9 — What to show / what to omit
Show:
- Aggregate roots + their value objects
- Interfaces + their implementations (ports / adapters)
- Cross-layer or cross-context edges
Omit:
- Framework base classes
- Getters + setters (except where meaningful)
- Trivial DTOs without behavior
- Internal helpers
Ask yourself: would a reviewer get the point in 15 seconds? If not, split or prune.
## Phase 10 — Consistency with code
If diagramming existing code:
- Sample enough to be accurate
- Mark `[approximate]` if simplified
- Update when code changes (or delete — stale diagrams harm more than help)
## Phase 11 — Diagrams
Renders combine:
- Domain model
- Ports + adapters
- Module structure
Use multiple small diagrams over one huge one.
## Phase 12 — Diagram rendering
Per `diagram-rendering` mixin.
## Phase 13 — Report assembly and approval
```markdown
# Class + Module Diagrams: [Subject]
**Date**: [date]
**Purpose**: [domain / layer / module]
**Scope**: [...]
## Domain Model
[One diagram + short narrative]
## Layer / Ports-Adapters
[If applicable]
## Module / Package Structure
[If applicable]
## Relationships & Multiplicities
[Noteworthy edges explained]
## Assumptions & Limitations
[Approximations, what's omitted]
```
Present for user approval. Save only after confirmation.
## Assessment + planning rules
- One purpose per diagram
- Visibility + stereotype + multiplicity correct
- Distinct relationships used correctly
- Trivial members omitted
- Stale diagrams removed, not kept
- No fabricated members
## Failure behavior
| Situation | Behavior |
|---|---|
| No subject / scope | Interview mode (§7) |
| Diagram doing too much | Split by purpose |
| Composition vs aggregation confused | Ask about lifetime binding |
| Implementation diagrammed as inheritance | Correct to `..|>` |
| Package structure requested as classDiagram | Switch to `graph` |
| mmdc failure | See `diagram-rendering` mixin |
| Implementation request | "Diagrams only; impl is engineering." |
## Self-check
```
[] One purpose per diagram
[] Visibility per member
[] Relationships distinct (inheritance / implementation / composition / aggregation / association / dependency)
[] Multiplicities where non-obvious
[] Stereotypes for DDD / architecture context
[] Trivial members omitted
[] Module boundaries clear
[] Diagrams valid
[] No fabricated members
[] Report follows output contract
```
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.