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

references/usage-examples.md

View on GitHub
<!-- Parent: external-diagram-mermaid-generate/SKILL.md -->
# sf-diagram Usage Examples

Real-world examples of using the sf-diagram skill.

---

## Example 1: OAuth Flow Diagram

### Request
```text
"Create a JWT Bearer OAuth flow diagram for our CI/CD pipeline integration"
```

### Generated Output

#### Mermaid Diagram
```mermaid
%%{init: {'theme': 'base', 'themeVariables': {
  'actorBkg': '#ddd6fe',
  'actorTextColor': '#1f2937',
  'actorBorder': '#6d28d9',
  'signalColor': '#334155',
  'signalTextColor': '#1f2937',
  'noteBkgColor': '#f8fafc',
  'noteTextColor': '#1f2937',
  'noteBorderColor': '#334155'
}}}%%
sequenceDiagram
    autonumber

    box rgba(221,214,254,0.3) CI/CD PIPELINE
        participant GH as šŸ”§ GitHub Actions
        participant K as šŸ” Secrets Manager
    end

    box rgba(167,243,208,0.3) SALESFORCE
        participant SF as ā˜ļø Salesforce
    end

    Note over GH,SF: JWT Bearer Flow for CI/CD

    GH->>K: 1. Retrieve private key
    K->>GH: 2. Return encrypted key

    GH->>GH: 3. Create JWT
    Note over GH: iss: consumer_key<br/>sub: deploy@company.com<br/>aud: login.salesforce.com

    GH->>GH: 4. Sign with private key

    GH->>SF: 5. POST /token (JWT assertion)

    SF->>SF: 6. Verify signature
    SF->>SF: 7. Validate claims

    SF->>GH: 8. Access token

    GH->>SF: 9. sf project deploy start
    SF->>GH: 10. Deployment result
```

#### ASCII Fallback
```text
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”     ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│   GitHub Actions      │     │     Salesforce     │
│   (Private Key)       │     │   (Certificate)    │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜     ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
            │                           │
            │  1. Create JWT            │
            │  2. Sign with key         │
            │                           │
            │  3. POST /token           │
            │──────────────────────────>│
            │                           │
            │  4. Verify signature      │
            │  5. Return access_token   │
            │<──────────────────────────│
            │                           │
            │  6. sf project deploy start       │
            │──────────────────────────>│
```

### Score
```yaml
Score: 72/80 ⭐⭐⭐⭐⭐ Excellent
ā”œā”€ Accuracy: 20/20     āœ“ All JWT Bearer steps correct
ā”œā”€ Clarity: 18/20      āœ“ Clear labels, good flow
ā”œā”€ Completeness: 14/15 āœ“ Includes CI/CD context
ā”œā”€ Styling: 12/15      āœ“ Proper theming
└─ Best Practices: 8/10 āœ“ Good annotations
```

---

## Example 2: Data Model ERD

### Request
```text
"Create an ERD for our custom Invoice system with Invoice__c, Invoice_Line_Item__c, and relationships to Account and Product"
```

### Generated Output

#### Mermaid Diagram
```mermaid
%%{init: {'theme': 'base', 'themeVariables': {
  'primaryColor': '#a5f3fc',
  'primaryTextColor': '#1f2937',
  'primaryBorderColor': '#0e7490',
  'lineColor': '#334155',
  'tertiaryColor': '#f8fafc'
}}}%%
erDiagram
    Account ||--o{ Invoice__c : "billed to"
    Account ||--o{ Contact : "has"
    Invoice__c ||--|{ Invoice_Line_Item__c : "contains"
    Product2 ||--o{ Invoice_Line_Item__c : "included in"

    Account {
        Id Id PK
        Text Name "Required"
        Text BillingStreet
        Text BillingCity
        Text BillingState
        Text BillingPostalCode
    }

    Contact {
        Id Id PK
        Lookup AccountId FK "Account"
        Text FirstName
        Text LastName "Required"
        Email Email
    }

    Invoice__c {
        Id Id PK
        AutoNumber Name "INV-00001"
        MasterDetail Account__c FK "Account"
        Lookup Billing_Contact__c FK "Contact"
        Date Invoice_Date__c "Required"
        Date Due_Date__c "Required"
        Picklist Status__c "Draft, Sent, Paid, Overdue"
        Currency Total_Amount__c "Roll-Up SUM"
        Currency Paid_Amount__c
        Formula Amount_Due__c "Total - Paid"
        Text External_Id__c UK "Integration Key"
    }

    Invoice_Line_Item__c {
        Id Id PK
        AutoNumber Name "LI-00001"
        MasterDetail Invoice__c FK "Invoice__c"
        Lookup Product__c FK "Product2"
        Number Quantity__c "Required"
        Currency Unit_Price__c "Required"
        Formula Line_Total__c "Qty Ɨ Price"
        TextArea Description__c
    }

    Product2 {
        Id Id PK
        Text Name "Required"
        Text ProductCode
        Currency UnitPrice
        Checkbox IsActive
    }
```

#### ASCII Fallback
```text
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”       ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│        ACCOUNT          │       │        CONTACT          │
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤       ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
│ Id (PK)                 │       │ Id (PK)                 │
│ Name (Required)         │──┐    │ AccountId (FK) ─────────│───┐
│ BillingStreet           │  │    │ FirstName               │   │
│ BillingCity             │  │    │ LastName (Required)     │   │
│ BillingState            │  │    │ Email                   │   │
│ BillingPostalCode       │  │    ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜   │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜  │                                  │
              │               │                                  │
              │ 1:N           ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
              ā–¼
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│      INVOICE__C         │
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
│ Id (PK)                 │
│ Name (Auto: INV-00001)  │
│ Account__c (MD)         │
│ Billing_Contact__c (LK) │
│ Invoice_Date__c (Req)   │
│ Due_Date__c (Req)       │
│ Status__c (Picklist)    │
│ Total_Amount__c (Roll)  │
│ Amount_Due__c (Formula) │
│ External_Id__c (UK)     │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
              │
              │ 1:N (Master-Detail)
              ā–¼
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”       ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│  INVOICE_LINE_ITEM__C   │       │       PRODUCT2          │
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤       ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
│ Id (PK)                 │       │ Id (PK)                 │
│ Name (Auto: LI-00001)   │       │ Name (Required)         │
│ Invoice__c (MD) ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”‚ā”€ā”€ā”˜    │ ProductCode             │
│ Product__c (LK) ────────│──────>│ UnitPrice               │
│ Quantity__c (Req)       │       │ IsActive                │
│ Unit_Price__c (Req)     │       ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
│ Line_Total__c (Formula) │
│ Description__c          │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
```

### Score
```yaml
Score: 74/80 ⭐⭐⭐⭐⭐ Excellent
ā”œā”€ Accuracy: 20/20     āœ“ All relationships correct
ā”œā”€ Clarity: 19/20      āœ“ Clear field annotations
ā”œā”€ Completeness: 15/15 āœ“ All objects included
ā”œā”€ Styling: 13/15      āœ“ Good layout
└─ Best Practices: 7/10  ⚠ Could add more field comments
```

---

## Example 3: Integration Sequence

### Request
```text
"Diagram our real-time Order sync from Salesforce to SAP using Platform Events"
```

### Generated Output

#### Mermaid Diagram
```mermaid
%%{init: {'theme': 'base', 'themeVariables': {
  'actorBkg': '#ddd6fe',
  'actorTextColor': '#1f2937',
  'actorBorder': '#6d28d9',
  'signalColor': '#334155',
  'signalTextColor': '#1f2937',
  'noteBkgColor': '#f8fafc',
  'noteTextColor': '#1f2937',
  'noteBorderColor': '#334155'
}}}%%
sequenceDiagram
    autonumber

    box rgba(167,243,208,0.3) SALESFORCE
        participant T as šŸ”„ Order Trigger
        participant PE as šŸ“¢ Order_Sync__e
    end

    box rgba(254,215,170,0.3) INTEGRATION
        participant MW as šŸ”„ MuleSoft
    end

    box rgba(165,243,252,0.3) SAP
        participant SAP as šŸ­ SAP S/4HANA
    end

    Note over T,SAP: Real-time Order Sync (Platform Events)

    T->>T: 1. Order record saved
    Note over T: Status changed to 'Approved'

    T->>PE: 2. Publish Platform Event
    Note over T,PE: EventBus.publish(<br/>  new Order_Sync__e(<br/>    Order_Id__c,<br/>    Action__c='CREATE'<br/>  )<br/>)

    PE-)MW: 3. Event delivered (CometD)
    Note over PE,MW: /event/Order_Sync__e

    activate MW

    MW->>MW: 4. Transform to SAP format
    Note over MW: Map SF Order → SAP Sales Order

    MW->>SAP: 5. POST /sap/api/salesorders
    Note over MW,SAP: IDOC or REST API

    alt Success
        SAP->>MW: 6a. 201 Created
        Note over SAP,MW: SAP Order #: 4500012345

        MW->>PE: 7a. Publish confirmation
        Note over MW,PE: Order_Sync_Status__e<br/>Status='SUCCESS'

    else Validation Error
        SAP->>MW: 6b. 400 Bad Request
        Note over SAP,MW: Missing required field

        MW->>PE: 7b. Publish error
        Note over MW,PE: Order_Sync_Status__e<br/>Status='ERROR'
    end

    deactivate MW

    Note over T: Flow updates Order<br/>with SAP reference
```

### Score
```yaml
Score: 70/80 ⭐⭐⭐⭐ Very Good
ā”œā”€ Accuracy: 19/20     āœ“ Platform Event pattern correct
ā”œā”€ Clarity: 18/20      āœ“ Good error handling shown
ā”œā”€ Completeness: 13/15 āœ“ Main paths covered
ā”œā”€ Styling: 12/15      āœ“ Good use of boxes
└─ Best Practices: 8/10 āœ“ Shows async pattern
```

---

## Example 4: Combined Request

### Request
```text
"I need to document our partner portal authentication.
Create: 1) The OAuth flow for partner login, 2) The data model showing Partner Account, Portal User, and Opportunities they can see"
```

### Generated Output

The skill generates two diagrams:

1. **OAuth Authorization Code + PKCE Flow** (for the portal)
2. **ERD showing Partner Access Model**

Both with Mermaid and ASCII versions.

---

## Tips for Best Results

1. **Be specific** - "JWT Bearer for CI/CD" is better than just "OAuth"
2. **Name your systems** - "Salesforce to SAP" produces clearer diagrams
3. **Mention custom objects** - Include `__c` suffix so we know they're custom
4. **Request both formats** - If you need ASCII fallback, mention it explicitly
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