external-diagram-mermaid-generate: Salesforce Diagram Generation
Use this skill when the user needs text-based diagrams: Mermaid diagrams for architecture, OAuth, integration flows, ERDs, or Agentforce structure, plus ASCII fallback when plain-text compatibility matters.
Scope
In Scope
Use external-diagram-mermaid-generate when the user wants:
- Mermaid output
- ASCII fallback diagrams
- architecture, sequence, flowchart, or ERD views in markdown-friendly form
- diagrams that can live directly in docs, READMEs, or issues
Out of Scope — Delegate elsewhere when the user wants:
Supported Diagram Families
| Type |
Preferred Mermaid form |
Typical use |
| OAuth / auth flows |
sequenceDiagram |
Authorization Code, JWT, PKCE, Device Flow |
| ERD / data model |
flowchart LR |
object relationships and sharing context |
| integration sequence |
sequenceDiagram |
request/response or event choreography |
| system landscape |
flowchart |
high-level architecture |
| role / access hierarchy |
flowchart |
users, profiles, permissions |
| Agentforce behavior map |
flowchart |
agent → topic → action relationships |
Required Context to Gather First
Ask for or infer:
- diagram type
- scope and entities / systems involved
- output preference: Mermaid only, ASCII only, or both
- whether styling should be minimal, documentation-first, or presentation-friendly
- for ERDs: whether org metadata is available for grounding
Recommended Workflow
1. Pick the right diagram structure
- use
sequenceDiagram for time-ordered interactions
- use
flowchart LR for ERDs and capability maps
- keep a single primary story per diagram when possible
2. Gather data
For ERDs and grounded diagrams:
3. Generate Mermaid first
Apply:
- accurate labels
- simple readable node text
- consistent relationship notation
- restrained styling that renders cleanly in markdown viewers
4. Add ASCII fallback when useful
Provide an ASCII version when the user wants terminal compatibility or plaintext documentation.
5. Explain the diagram briefly
Call out the key relationships, flow direction, and any assumptions.
High-Signal Rules
For sequence diagrams
- use
autonumber when step order matters
- distinguish requests vs responses clearly
- use notes sparingly for protocol detail
For ERDs
- prefer
flowchart LR
- keep object cards simple
- use clear relationship arrows
- avoid field overload unless the user explicitly asks for field-level detail
- color-code object types only when it improves readability
For ASCII output
- keep width reasonable
- align arrows and boxes consistently
- optimize for readability over decoration
Output Format
## <Diagram Title>
### Mermaid Diagram
```mermaid
<diagram>
```
### ASCII Fallback
```text
<ascii>
```
### Notes
- <key point>
- <assumption or limitation>
Cross-Skill Integration
Gotchas
| Issue |
Resolution |
| Mermaid renderer not available |
Provide ASCII fallback automatically; note that the Mermaid block still carries the diagram for copy-paste into a renderer |
| ERD becomes unreadable with too many objects |
Split into sub-diagrams by domain (Sales, Service, etc.) and link them in prose |
| Sequence diagram step order unclear |
Use autonumber directive to make step ordering explicit |
| OAuth flow actors differ by grant type |
Read the relevant asset template first before generating to avoid actor mismatch |
Reference File Index
Conventions & rules — read before generating
- references/diagram-conventions.md — consistency rules for all diagram types
- references/mermaid-reference.md — Mermaid syntax quick reference
- references/usage-examples.md — worked examples per diagram type
Styling
- references/mermaid-styling.md — theming and annotation patterns
- references/color-palette.md — color-blind-friendly palette with hex values
- references/erd-conventions.md — ERD-specific layout and notation rules
Preview
- references/preview-guide.md — how to render Mermaid locally
- scripts/README.md — setup and usage instructions for all scripts in this skill
- scripts/mermaid_preview.py — live-reload preview server; run to preview diagrams in browser
- scripts/query-org-metadata.py — queries org schema to ground ERD generation
OAuth flow templates — load the matching template when generating OAuth diagrams
- assets/oauth/authorization-code.md — Authorization Code grant
- assets/oauth/authorization-code-pkce.md — PKCE variant for mobile/SPA
- assets/oauth/jwt-bearer.md — JWT Bearer server-to-server
- assets/oauth/client-credentials.md — Client Credentials service accounts
- assets/oauth/device-authorization.md — Device Flow for CLI/IoT
- assets/oauth/refresh-token.md — Refresh Token renewal flow
- assets/oauth/user-agent-social-sign-on.md — User-Agent / Social Sign-On
Data model ERD templates — load the matching template when generating ERDs
- assets/datamodel/salesforce-erd.md — core Salesforce objects
- assets/datamodel/sales-cloud-erd.md — Sales Cloud objects
- assets/datamodel/service-cloud-erd.md — Service Cloud objects
- assets/datamodel/b2b-commerce-erd.md — B2B Commerce objects
- assets/datamodel/campaigns-erd.md — Campaigns and campaign member model
- assets/datamodel/consent-erd.md — Consent and privacy objects
- assets/datamodel/files-erd.md — Files and ContentDocument model
- assets/datamodel/forecasting-erd.md — Forecasting objects
- assets/datamodel/fsl-erd.md — Field Service Lightning objects
- assets/datamodel/party-model-erd.md — Party model objects
- assets/datamodel/quote-order-erd.md — Quote and Order objects
- assets/datamodel/revenue-cloud-erd.md — Revenue Cloud objects
- assets/datamodel/scheduler-erd.md — Scheduler objects
- assets/datamodel/territory-management-erd.md — Territory Management objects
Other diagram templates
- assets/architecture/system-landscape.md — system landscape overview template
- assets/integration/api-sequence.md — API callout sequence template
- assets/agentforce/agent-flow.md — Agentforce agent → topic → action flow
- assets/role-hierarchy/user-hierarchy.md — role and permission hierarchy template
Output Expectations
Deliverables produced by this skill for each request:
- Mermaid code block — fenced
```mermaid block ready to paste into GitHub, Confluence, or any Mermaid-capable renderer
- ASCII fallback (when requested or when Mermaid renderer is unavailable) — text-only diagram using box/arrow characters
- Brief explanation — 2-5 bullet points calling out key relationships, flow direction, and any assumptions or limitations in the diagram
- For ERDs: object cards with field labels and relationship type annotations
- For sequence diagrams: numbered steps (
autonumber) with clear actor labels
Score Guide
| Score |
Meaning |
| 72–80 |
production-ready diagram |
| 60–71 |
clear and useful with minor polish left |
| 48–59 |
functional but could be clearer |
| 35–47 |
needs structural improvement |
| < 35 |
inaccurate or incomplete |
1---
2name: external-diagram-mermaid-generate
3description: "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."
4metadata:
5 cliTools:
6 - tool: ["curl"]
7 semver: ">=7.0.0"
8 - tool: ["jq"]
9 semver: ">=1.6.0"
10 - tool: ["python"]
11 semver: ">=3.10.0"
12 - tool: ["python3"]
13 semver: ">=3.10.0"
14 - tool: ["sf"]
15 semver: ">=2.0.0"
16 relatedSkills:
17 - "agentforce-generate"
18 - "automation-flow-generate"
19 - "integration-connectivity-connected-app-configure"
20 - "integration-connectivity-generate"
21 - "platform-apex-generate"
22 - "platform-custom-field-generate"
23 - "platform-custom-object-generate"
24 - "platform-data-manage"
25 - "platform-metadata-deploy"
26 version: "1.0"
27 domains: ["External"]
28---
29
30# external-diagram-mermaid-generate: Salesforce Diagram Generation
31
32Use this skill when the user needs **text-based diagrams**: Mermaid diagrams for architecture, OAuth, integration flows, ERDs, or Agentforce structure, plus ASCII fallback when plain-text compatibility matters.
33
34## Scope
35
36### In Scope
37Use `external-diagram-mermaid-generate` when the user wants:
38- Mermaid output
39- ASCII fallback diagrams
40- architecture, sequence, flowchart, or ERD views in markdown-friendly form
41- diagrams that can live directly in docs, READMEs, or issues
42
43### Out of Scope — Delegate elsewhere when the user wants:
44- non-Salesforce systems only → use a more general diagramming skill
45- object discovery before an ERD → [platform-custom-object-generate](../platform-custom-object-generate/SKILL.md) or [platform-custom-field-generate](../platform-custom-field-generate/SKILL.md)
46
47---
48
49## Supported Diagram Families
50
51| Type | Preferred Mermaid form | Typical use |
52|---|---|---|
53| OAuth / auth flows | `sequenceDiagram` | Authorization Code, JWT, PKCE, Device Flow |
54| ERD / data model | `flowchart LR` | object relationships and sharing context |
55| integration sequence | `sequenceDiagram` | request/response or event choreography |
56| system landscape | `flowchart` | high-level architecture |
57| role / access hierarchy | `flowchart` | users, profiles, permissions |
58| Agentforce behavior map | `flowchart` | agent → topic → action relationships |
59
60---
61
62## Required Context to Gather First
63
64Ask for or infer:
65- diagram type
66- scope and entities / systems involved
67- output preference: Mermaid only, ASCII only, or both
68- whether styling should be minimal, documentation-first, or presentation-friendly
69- for ERDs: whether org metadata is available for grounding
70
71---
72
73## Recommended Workflow
74
75### 1. Pick the right diagram structure
76- use `sequenceDiagram` for time-ordered interactions
77- use `flowchart LR` for ERDs and capability maps
78- keep a single primary story per diagram when possible
79
80### 2. Gather data
81For ERDs and grounded diagrams:
82- use [platform-custom-object-generate](../platform-custom-object-generate/SKILL.md) or [platform-custom-field-generate](../platform-custom-field-generate/SKILL.md) when real schema discovery is needed
83- optionally use the local metadata helper script for counts / relationship context when appropriate
84
85### 3. Generate Mermaid first
86Apply:
87- accurate labels
88- simple readable node text
89- consistent relationship notation
90- restrained styling that renders cleanly in markdown viewers
91
92### 4. Add ASCII fallback when useful
93Provide an ASCII version when the user wants terminal compatibility or plaintext documentation.
94
95### 5. Explain the diagram briefly
96Call out the key relationships, flow direction, and any assumptions.
97
98---
99
100## High-Signal Rules
101
102### For sequence diagrams
103- use `autonumber` when step order matters
104- distinguish requests vs responses clearly
105- use notes sparingly for protocol detail
106
107### For ERDs
108- prefer `flowchart LR`
109- keep object cards simple
110- use clear relationship arrows
111- avoid field overload unless the user explicitly asks for field-level detail
112- color-code object types only when it improves readability
113
114### For ASCII output
115- keep width reasonable
116- align arrows and boxes consistently
117- optimize for readability over decoration
118
119---
120
121## Output Format
122
123````markdown
124## <Diagram Title>
125
126### Mermaid Diagram
127```mermaid
128<diagram>
129```
130
131### ASCII Fallback
132```text
133<ascii>
134```
135
136### Notes
137- <key point>
138- <assumption or limitation>
139````
140
141---
142
143## Cross-Skill Integration
144
145| Need | Delegate to | Reason |
146|---|---|---|
147| real object / field definitions | [platform-custom-object-generate](../platform-custom-object-generate/SKILL.md) / [platform-custom-field-generate](../platform-custom-field-generate/SKILL.md) | grounded ERD generation |
148| connected-app auth setup context | [integration-connectivity-connected-app-configure](../integration-connectivity-connected-app-configure/SKILL.md) | accurate OAuth flows |
149| Agentforce logic visualization | [agentforce-generate](../agentforce-generate/SKILL.md) | source-of-truth behavior details |
150| Flow behavior diagrams | [automation-flow-generate](../automation-flow-generate/SKILL.md) | actual Flow logic grounding |
151
152---
153
154## Gotchas
155
156| Issue | Resolution |
157|---|---|
158| Mermaid renderer not available | Provide ASCII fallback automatically; note that the Mermaid block still carries the diagram for copy-paste into a renderer |
159| ERD becomes unreadable with too many objects | Split into sub-diagrams by domain (Sales, Service, etc.) and link them in prose |
160| Sequence diagram step order unclear | Use `autonumber` directive to make step ordering explicit |
161| OAuth flow actors differ by grant type | Read the relevant asset template first before generating to avoid actor mismatch |
162
163---
164
165## Reference File Index
166
167### Conventions & rules — read before generating
168- [references/diagram-conventions.md](references/diagram-conventions.md) — consistency rules for all diagram types
169- [references/mermaid-reference.md](references/mermaid-reference.md) — Mermaid syntax quick reference
170- [references/usage-examples.md](references/usage-examples.md) — worked examples per diagram type
171
172### Styling
173- [references/mermaid-styling.md](references/mermaid-styling.md) — theming and annotation patterns
174- [references/color-palette.md](references/color-palette.md) — color-blind-friendly palette with hex values
175- [references/erd-conventions.md](references/erd-conventions.md) — ERD-specific layout and notation rules
176
177### Preview
178- [references/preview-guide.md](references/preview-guide.md) — how to render Mermaid locally
179- [scripts/README.md](scripts/README.md) — setup and usage instructions for all scripts in this skill
180- [scripts/mermaid_preview.py](scripts/mermaid_preview.py) — live-reload preview server; run to preview diagrams in browser
181- [scripts/query-org-metadata.py](scripts/query-org-metadata.py) — queries org schema to ground ERD generation
182
183### OAuth flow templates — load the matching template when generating OAuth diagrams
184- [assets/oauth/authorization-code.md](assets/oauth/authorization-code.md) — Authorization Code grant
185- [assets/oauth/authorization-code-pkce.md](assets/oauth/authorization-code-pkce.md) — PKCE variant for mobile/SPA
186- [assets/oauth/jwt-bearer.md](assets/oauth/jwt-bearer.md) — JWT Bearer server-to-server
187- [assets/oauth/client-credentials.md](assets/oauth/client-credentials.md) — Client Credentials service accounts
188- [assets/oauth/device-authorization.md](assets/oauth/device-authorization.md) — Device Flow for CLI/IoT
189- [assets/oauth/refresh-token.md](assets/oauth/refresh-token.md) — Refresh Token renewal flow
190- [assets/oauth/user-agent-social-sign-on.md](assets/oauth/user-agent-social-sign-on.md) — User-Agent / Social Sign-On
191
192### Data model ERD templates — load the matching template when generating ERDs
193- [assets/datamodel/salesforce-erd.md](assets/datamodel/salesforce-erd.md) — core Salesforce objects
194- [assets/datamodel/sales-cloud-erd.md](assets/datamodel/sales-cloud-erd.md) — Sales Cloud objects
195- [assets/datamodel/service-cloud-erd.md](assets/datamodel/service-cloud-erd.md) — Service Cloud objects
196- [assets/datamodel/b2b-commerce-erd.md](assets/datamodel/b2b-commerce-erd.md) — B2B Commerce objects
197- [assets/datamodel/campaigns-erd.md](assets/datamodel/campaigns-erd.md) — Campaigns and campaign member model
198- [assets/datamodel/consent-erd.md](assets/datamodel/consent-erd.md) — Consent and privacy objects
199- [assets/datamodel/files-erd.md](assets/datamodel/files-erd.md) — Files and ContentDocument model
200- [assets/datamodel/forecasting-erd.md](assets/datamodel/forecasting-erd.md) — Forecasting objects
201- [assets/datamodel/fsl-erd.md](assets/datamodel/fsl-erd.md) — Field Service Lightning objects
202- [assets/datamodel/party-model-erd.md](assets/datamodel/party-model-erd.md) — Party model objects
203- [assets/datamodel/quote-order-erd.md](assets/datamodel/quote-order-erd.md) — Quote and Order objects
204- [assets/datamodel/revenue-cloud-erd.md](assets/datamodel/revenue-cloud-erd.md) — Revenue Cloud objects
205- [assets/datamodel/scheduler-erd.md](assets/datamodel/scheduler-erd.md) — Scheduler objects
206- [assets/datamodel/territory-management-erd.md](assets/datamodel/territory-management-erd.md) — Territory Management objects
207
208### Other diagram templates
209- [assets/architecture/system-landscape.md](assets/architecture/system-landscape.md) — system landscape overview template
210- [assets/integration/api-sequence.md](assets/integration/api-sequence.md) — API callout sequence template
211- [assets/agentforce/agent-flow.md](assets/agentforce/agent-flow.md) — Agentforce agent → topic → action flow
212- [assets/role-hierarchy/user-hierarchy.md](assets/role-hierarchy/user-hierarchy.md) — role and permission hierarchy template
213
214---
215
216## Output Expectations
217
218Deliverables produced by this skill for each request:
219
220- **Mermaid code block** — fenced ` ```mermaid ` block ready to paste into GitHub, Confluence, or any Mermaid-capable renderer
221- **ASCII fallback** (when requested or when Mermaid renderer is unavailable) — text-only diagram using box/arrow characters
222- **Brief explanation** — 2-5 bullet points calling out key relationships, flow direction, and any assumptions or limitations in the diagram
223- For ERDs: object cards with field labels and relationship type annotations
224- For sequence diagrams: numbered steps (`autonumber`) with clear actor labels
225
226---
227
228## Score Guide
229
230| Score | Meaning |
231|---|---|
232| 72–80 | production-ready diagram |
233| 60–71 | clear and useful with minor polish left |
234| 48–59 | functional but could be clearer |
235| 35–47 | needs structural improvement |
236| < 35 | inaccurate or incomplete |