Skip to content

forcedotcom/sf-skills / skills/external-diagram-mermaid-generate

external-diagram-mermaid-generate

Unverified

Salesforce architecture diagrams using Mermaid with ASCII fallback. Use this skill when generating text-based diagrams for Salesforce architecture, OAuth flows, ERDs, integration sequences, or Agentforce structure. TRIGGER when: user says "diagram", "visualize", "ERD", or asks for sequence diagrams, flowcharts, class diagrams, or architecture visualizations in Mermaid. DO NOT TRIGGER when: user asks about non-Salesforce systems.

FileKindSize
README.mdmarkdown4.1 KB
SKILL.mdskill md10.7 KB
assets/agentforce/agent-flow.mdmarkdown15.6 KB
assets/architecture/system-landscape.mdmarkdown17.8 KB
assets/datamodel/b2b-commerce-erd.mdmarkdown11.8 KB
assets/datamodel/campaigns-erd.mdmarkdown8.4 KB
assets/datamodel/consent-erd.mdmarkdown10.2 KB
assets/datamodel/files-erd.mdmarkdown9.2 KB
assets/datamodel/forecasting-erd.mdmarkdown9.3 KB
assets/datamodel/fsl-erd.mdmarkdown11.7 KB
assets/datamodel/party-model-erd.mdmarkdown9.1 KB
assets/datamodel/quote-order-erd.mdmarkdown9.9 KB
assets/datamodel/revenue-cloud-erd.mdmarkdown12.8 KB
assets/datamodel/sales-cloud-erd.mdmarkdown7.4 KB
assets/datamodel/salesforce-erd.mdmarkdown6.8 KB
assets/datamodel/scheduler-erd.mdmarkdown10.7 KB
assets/datamodel/service-cloud-erd.mdmarkdown8.1 KB
assets/datamodel/territory-management-erd.mdmarkdown10.0 KB
assets/integration/api-sequence.mdmarkdown12.7 KB
assets/oauth/authorization-code-pkce.mdmarkdown8.5 KB
assets/oauth/authorization-code.mdmarkdown6.8 KB
assets/oauth/client-credentials.mdmarkdown7.6 KB
assets/oauth/device-authorization.mdmarkdown10.5 KB
assets/oauth/jwt-bearer.mdmarkdown8.2 KB
assets/oauth/refresh-token.mdmarkdown9.5 KB
assets/oauth/user-agent-social-sign-on.mdmarkdown13.7 KB
assets/role-hierarchy/user-hierarchy.mdmarkdown13.3 KB
references/color-palette.mdmarkdown19.5 KB
references/diagram-conventions.mdmarkdown8.1 KB
references/erd-conventions.mdmarkdown8.9 KB
references/mermaid-reference.mdmarkdown8.1 KB
references/mermaid-styling.mdmarkdown2.8 KB
references/preview-guide.mdmarkdown1.2 KB
references/usage-examples.mdmarkdown11.1 KB
scripts/README.mdmarkdown6.3 KB
scripts/mermaid_preview.pyexecutablescript20.1 KB
scripts/query-org-metadata.pyexecutablescript8.5 KB

assets/datamodel/salesforce-erd.md

View on GitHub
# Salesforce Data Model Template

Data model diagram template using `flowchart LR` for visualizing Salesforce object relationships with color coding, LDV markers, and relationship type labels.

## When to Use
- Documenting object relationships
- Planning data model changes
- Understanding existing schema
- Design reviews and architecture discussions

## Cloud-Specific Templates

For pre-built cloud diagrams, see:
- **[Sales Cloud ERD](sales-cloud-erd.md)** - Account, Contact, Opportunity, Lead, Product, Campaign
- **[Service Cloud ERD](service-cloud-erd.md)** - Case, Entitlement, Knowledge, ServiceContract

## Preferred Format: `flowchart LR`

Use `flowchart LR` (left-to-right) for data model diagrams. This format supports:
- Individual node color coding by object type
- Thick arrows (`==>`) for Master-Detail relationships
- Left-to-right flow for readability
- Simple object nodes (name + record count, no fields)

---

## Quick Reference

### Object Type Colors

| Type | Fill | Stroke | Example |
|------|------|--------|---------|
| Standard | `#bae6fd` | `#0369a1` | Account, Contact |
| Custom (`__c`) | `#fed7aa` | `#c2410c` | Invoice__c |
| External (`__x`) | `#a7f3d0` | `#047857` | SAP_Order__x |

### Relationship Arrows

| Arrow | Type | Meaning |
|-------|------|---------|
| `-->` | Lookup (LK) | Optional parent, no cascade delete |
| `==>` | Master-Detail (MD) | Required parent, cascade delete |
| `-.->` | Special | Conversion, indirect relationship |

### Metadata Annotations

| Annotation | When to Use |
|------------|-------------|
| `LDV[~4M]` | Record count >2M |
| `(317)` | Record count <2M |

---

## Query Org Metadata

Enrich diagrams with live org data:

```bash
python3 ../../scripts/query-org-metadata.py \
    --objects Account,Contact,Opportunity,Case \
    --target-org myorg
```

---

## Mermaid Template (Preferred)

```mermaid
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
    %% ═══════════════════════════════════════════════════════════════
    %% LEGEND: LK = Lookup (-->), MD = Master-Detail (==>)
    %% Colors: Blue = Standard, Orange = Custom, Green = External
    %% ═══════════════════════════════════════════════════════════════

    Account["Account<br/>(317)"]
    Contact["Contact<br/>(346)"]
    Opportunity["Opportunity<br/>(6)"]
    Case["Case<br/>(2)"]

    Account -->|"LK"| Contact
    Account -->|"LK"| Opportunity
    Account -->|"LK"| Case
    Contact -->|"LK"| Case

    %% Standard Objects - Sky Blue
    style Account fill:#bae6fd,stroke:#0369a1,color:#1f2937
    style Contact fill:#bae6fd,stroke:#0369a1,color:#1f2937
    style Opportunity fill:#bae6fd,stroke:#0369a1,color:#1f2937
    style Case fill:#bae6fd,stroke:#0369a1,color:#1f2937
```

---

## ASCII Fallback Template

```text
┌─────────────────────────────────────────────────────────────────────────────┐
│  DATA MODEL (L→R)                                                           │
│  Legend: LK = Lookup (-->), MD = Master-Detail (==>)                        │
└─────────────────────────────────────────────────────────────────────────────┘

┌────────────────┐         ┌────────────────┐         ┌────────────────┐
│    ACCOUNT     │── LK ──>│    CONTACT     │── LK ──>│     CASE       │
│     (317)      │         │     (346)      │         │      (2)       │
└───────┬────────┘         └────────────────┘         └────────────────┘
        │
        │ LK
        ▼
┌────────────────┐
│  OPPORTUNITY   │
│      (6)       │
└────────────────┘
```

---

## Custom Object Example

Shows mixing Standard (blue) and Custom (orange) objects:

```mermaid
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
    %% Standard Objects
    Account["Account<br/>(317)"]
    Product2["Product2<br/>(50)"]

    %% Custom Objects
    Invoice["Invoice__c<br/>(1,200)"]
    InvoiceLine["Invoice_Line_Item__c<br/>(5,400)"]

    Account ==>|"MD"| Invoice
    Invoice ==>|"MD"| InvoiceLine
    Product2 -->|"LK"| InvoiceLine

    %% Standard - Sky Blue
    style Account fill:#bae6fd,stroke:#0369a1,color:#1f2937
    style Product2 fill:#bae6fd,stroke:#0369a1,color:#1f2937

    %% Custom - Orange
    style Invoice fill:#fed7aa,stroke:#c2410c,color:#1f2937
    style InvoiceLine fill:#fed7aa,stroke:#c2410c,color:#1f2937
```

---

## External Object Example

Shows Standard, Custom, and External objects together:

```mermaid
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
    Account["Account<br/>(317)"]
    SAPOrder["SAP_Order__x<br/>(ext)"]
    OrderLine["Order_Line__c<br/>(2,400)"]

    Account -->|"LK"| SAPOrder
    SAPOrder -->|"LK"| OrderLine

    %% Standard - Sky Blue
    style Account fill:#bae6fd,stroke:#0369a1,color:#1f2937

    %% External - Green
    style SAPOrder fill:#a7f3d0,stroke:#047857,color:#1f2937

    %% Custom - Orange
    style OrderLine fill:#fed7aa,stroke:#c2410c,color:#1f2937
```

---

## LDV (Large Data Volume) Example

Objects with >2M records show LDV indicator:

```mermaid
%%{init: {"flowchart": {"nodeSpacing": 50, "rankSpacing": 80}} }%%
flowchart LR
    Account["Account<br/>LDV[~4M]"]
    Contact["Contact<br/>LDV[~8M]"]
    Case["Case<br/>(450K)"]

    Account -->|"LK"| Contact
    Account -->|"LK"| Case
    Contact -->|"LK"| Case

    style Account fill:#bae6fd,stroke:#0369a1,color:#1f2937
    style Contact fill:#bae6fd,stroke:#0369a1,color:#1f2937
    style Case fill:#bae6fd,stroke:#0369a1,color:#1f2937
```

---

## Best Practices

1. **Use `flowchart LR`** - Left-to-right flow is easier to read
2. **Keep objects simple** - Show name + record count only (no fields)
3. **Color code by type** - Blue=Standard, Orange=Custom, Green=External
4. **Use correct arrows** - `-->` for Lookup, `==>` for Master-Detail
5. **Add LDV indicators** - For objects >2M records
6. **Use API names** - Show `Account` not "Accounts"

---

## ERD Conventions

See **[ERD Conventions](../../references/erd-conventions.md)** for full documentation.
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall