forcedotcom/sf-skills / skills/external-diagram-mermaid-generate
external-diagram-mermaid-generate
UnverifiedSalesforce 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.
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
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| 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: 472k | Updated | Claude CodeCodex | Verified | Install |
| 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: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| 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 available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |