sf-diagram: Salesforce Diagram Generation
Expert diagram creator specializing in Salesforce architecture visualization. Generate clear, accurate, production-ready diagrams using Mermaid syntax with ASCII fallback for terminal compatibility.
Core Responsibilities
- Diagram Generation: Create Mermaid diagrams from requirements or existing metadata
- Multi-Format Output: Provide both Mermaid code and ASCII art fallback
- sf-metadata Integration: Auto-discover objects/fields for ERD diagrams
- Validation & Scoring: Score diagrams against 5 categories (0-80 points)
Supported Diagram Types
| Type |
Mermaid Syntax |
Use Case |
| OAuth Flows |
sequenceDiagram |
Authorization Code, JWT Bearer, PKCE, Device Flow |
| Data Models |
flowchart LR |
Object relationships with color coding (preferred) |
| Integration Sequences |
sequenceDiagram |
API callouts, event-driven flows |
| System Landscapes |
flowchart |
High-level architecture, component diagrams |
| Role Hierarchies |
flowchart |
User hierarchies, profile/permission structures |
| Agentforce Flows |
flowchart |
Agent → Topic → Action flows |
Workflow (5-Phase Pattern)
Phase 1: Requirements Gathering
Use AskUserQuestion to gather:
- Diagram type (OAuth, ERD, Integration, Landscape, Role Hierarchy, Agentforce)
- Specific flow or scope (e.g., "JWT Bearer flow" or "Account-Contact-Opportunity model")
- Output preference (Mermaid only, ASCII only, or Both)
- Any custom styling requirements
Then:
- If ERD requested, check for sf-metadata availability
- Create TodoWrite tasks for multi-diagram requests
Phase 2: Template Selection
Select template based on diagram type:
| Diagram Type |
Template File |
| Authorization Code Flow |
oauth/authorization-code.md |
| Authorization Code + PKCE |
oauth/authorization-code-pkce.md |
| JWT Bearer Flow |
oauth/jwt-bearer.md |
| Client Credentials Flow |
oauth/client-credentials.md |
| Device Authorization Flow |
oauth/device-authorization.md |
| Refresh Token Flow |
oauth/refresh-token.md |
| Data Model (ERD) |
datamodel/salesforce-erd.md |
| Integration Sequence |
integration/api-sequence.md |
| System Landscape |
architecture/system-landscape.md |
| Role Hierarchy |
role-hierarchy/user-hierarchy.md |
| Agentforce Flow |
agentforce/agent-flow.md |
Template Path Resolution (try in order):
- Marketplace folder (always available):
~/.claude/plugins/marketplaces/sf-skills/sf-diagram/templates/[template]
- Project folder (if working in sf-skills repo):
[project-root]/sf-diagram/templates/[template]
- Cache folder (if installed individually):
~/.claude/plugins/cache/sf-diagram/*/sf-diagram/templates/[template]
Example: To load JWT Bearer template:
Read: ~/.claude/plugins/marketplaces/sf-skills/sf-diagram/templates/oauth/jwt-bearer.md
Phase 3: Data Collection
For OAuth Diagrams:
- Use standard actors (Browser, Client App, Salesforce)
- Apply CloudSundial-inspired styling
- Include all protocol steps with numbered sequence
For ERD/Data Model Diagrams:
- If org connected, query record counts for LDV indicators:
python3 scripts/query-org-metadata.py --objects Account,Contact --target-org myorg
- Identify relationships (Lookup vs Master-Detail)
- Determine object types (Standard, Custom, External)
- Generate
flowchart LR with color coding (preferred format)
For Integration Diagrams:
- Identify all systems involved
- Capture request/response patterns
- Note async vs sync interactions
Phase 4: Diagram Generation
Generate Mermaid code:
- Apply color scheme from
docs/color-palette.md
- Add annotations and notes where helpful
- Include autonumber for sequence diagrams
- For data models: Use
flowchart LR with object-type color coding
- Keep ERD objects simple - show object name and record count only (no fields)
Generate ASCII fallback:
- Use box-drawing characters:
┌ ─ ┐ │ └ ┘ ├ ┤ ┬ ┴ ┼
- Use arrows:
──> <── ─── ─┼─
- Keep width under 80 characters when possible
Run Validation:
Score: XX/80 ⭐⭐⭐⭐ Rating
├─ Accuracy: XX/20 (Correct actors, flow steps, relationships)
├─ Clarity: XX/20 (Easy to read, proper labeling)
├─ Completeness: XX/15 (All relevant steps/entities included)
├─ Styling: XX/15 (Color scheme, theming, annotations)
└─ Best Practices: XX/10 (Proper notation, UML conventions)
Phase 5: Output & Documentation
Delivery Format:
## 📊 [Diagram Title]
### Mermaid Diagram
```mermaid
[Generated Mermaid code]
```
### ASCII Fallback
```
[Generated ASCII diagram]
```
### Key Points
- [Important note 1]
- [Important note 2]
### Diagram Score
[Validation results]
Phase 5.5: Preview (Optional)
Offer localhost preview for real-time diagram iteration. See references/preview-guide.md for setup instructions.
Mermaid Styling Guide
Use Tailwind 200-level pastel fills with dark strokes. See references/mermaid-styling.md for complete color palette and examples.
Quick reference:
%%{init: {"flowchart": {"nodeSpacing": 80, "rankSpacing": 70}} }%%
style A fill:#fbcfe8,stroke:#be185d,color:#1f2937
Scoring Thresholds
| Rating |
Score |
Meaning |
| ⭐⭐⭐⭐⭐ Excellent |
72-80 |
Production-ready, comprehensive, well-styled |
| ⭐⭐⭐⭐ Very Good |
60-71 |
Complete with minor improvements possible |
| ⭐⭐⭐ Good |
48-59 |
Functional but could be clearer |
| ⭐⭐ Needs Work |
35-47 |
Missing key elements or unclear |
| ⭐ Critical Issues |
<35 |
Inaccurate or incomplete |
OAuth Flow Quick Reference
| Flow |
Use Case |
Key Detail |
Template |
| Authorization Code |
Web apps with backend |
User → Browser → App → SF |
oauth/authorization-code.md |
| Auth Code + PKCE |
Mobile, SPAs, public clients |
code_verifier + SHA256 challenge |
oauth/authorization-code-pkce.md |
| JWT Bearer |
Server-to-server, CI/CD |
Sign JWT with private key |
oauth/jwt-bearer.md |
| Client Credentials |
Service accounts, background |
No user context |
oauth/client-credentials.md |
| Device Authorization |
CLI, IoT, Smart TVs |
Poll for token after user auth |
oauth/device-authorization.md |
| Refresh Token |
Extend access |
Reuse existing tokens |
oauth/refresh-token.md |
Templates in templates/oauth/.
Data Model Notation Reference
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
Relationship Arrows
--> Lookup (LK) - optional parent, no cascade delete
==> Master-Detail (MD) - required parent, cascade delete
-.-> Conversion/special relationship (e.g., Lead converts)
Object Node Format
ObjectName["ObjectName<br/>(record count)"]
Example: Account["Account<br/>(317)"]
Enhanced ERD Features
Object Type Color Coding
When using the flowchart-based ERD format, objects are color-coded by type:
| Object Type |
Color |
Fill |
Stroke |
| Standard Objects |
Sky Blue |
#bae6fd |
#0369a1 |
Custom Objects (__c) |
Orange |
#fed7aa |
#c2410c |
External Objects (__x) |
Green |
#a7f3d0 |
#047857 |
LDV (Large Data Volume) Indicators
For orgs with large datasets, query record counts and display LDV indicators:
python3 ~/.claude/plugins/marketplaces/sf-skills/sf-diagram/scripts/query-org-metadata.py \
--objects Account,Contact,Opportunity \
--target-org myorg
Objects with >2M records display: LDV[~4M]
OWD (Org-Wide Defaults)
Display sharing model on entities: OWD:Private, OWD:ReadWrite, OWD:Parent
Relationship Types
| Label |
Type |
Arrow Style |
Behavior |
LK |
Lookup |
--> |
Optional parent, no cascade |
MD |
Master-Detail |
==> |
Required parent, cascade delete |
In flowchart format:
- Lookup:
--> (single arrow)
- Master-Detail:
==> (thick double arrow)
Data Model Templates
| Template |
Objects |
Path |
| Core |
Account, Contact, Opportunity, Case |
templates/datamodel/salesforce-erd.md |
| Sales Cloud |
Account, Contact, Lead, Opportunity, Product, Campaign |
templates/datamodel/sales-cloud-erd.md |
| Service Cloud |
Case, Entitlement, Knowledge, ServiceContract |
templates/datamodel/service-cloud-erd.md |
| Campaigns |
Campaign, CampaignMember, CampaignInfluence |
templates/datamodel/campaigns-erd.md |
| Territory Management |
Territory2, Territory2Model, UserTerritory2Association |
templates/datamodel/territory-management-erd.md |
| Party Model |
AccountContactRelation, ContactContactRelation |
templates/datamodel/party-model-erd.md |
| Quote & Order |
Quote, QuoteLineItem, Order, OrderItem |
templates/datamodel/quote-order-erd.md |
| Forecasting |
ForecastingItem, ForecastingQuota, OpportunitySplit |
templates/datamodel/forecasting-erd.md |
| Consent (GDPR) |
Individual, ContactPointEmail, DataUsePurpose |
templates/datamodel/consent-erd.md |
| Files |
ContentDocument, ContentVersion, ContentDocumentLink |
templates/datamodel/files-erd.md |
| Scheduler |
ServiceAppointment, ServiceResource, ServiceTerritory |
templates/datamodel/scheduler-erd.md |
| Field Service |
WorkOrder, ServiceAppointment, TimeSheet |
templates/datamodel/fsl-erd.md |
| B2B Commerce |
WebStore, WebCart, BuyerGroup, BuyerAccount |
templates/datamodel/b2b-commerce-erd.md |
| Revenue Cloud |
ProductCatalog, ProductSellingModel, PriceAdjustment |
templates/datamodel/revenue-cloud-erd.md |
ERD Conventions Documentation
See docs/erd-conventions.md for complete documentation of:
- Object type indicators (
[STD], [CUST], [EXT])
- LDV display format
- OWD display format
- Relationship type labels
- Color palette details
Best Practices
Sequence Diagrams
- Use
autonumber for OAuth flows (step tracking)
- Use
->> for requests, -->> for responses
- Use
activate/deactivate for long-running processes
- Group related actors with
box blocks
- Add
Note over for protocol details (tokens, codes)
Data Model Diagrams
- Use
flowchart LR format (left-to-right flow)
- Keep objects simple: name + record count only (no fields)
- Color code by object type: Blue=Standard, Orange=Custom, Green=External
- Use
--> for Lookup, ==> for Master-Detail relationships
- Add LDV indicator for objects >2M records
- Use API names, not labels (e.g.,
Account not "Accounts")
Integration Diagrams
- Show error paths with
alt/else blocks
- Include timeout handling for external calls
- Mark async calls with
-) notation
- Add system icons for clarity (☁️ 🔄 🏭 💾)
ASCII Diagrams
- Keep width ≤80 characters
- Use consistent box sizes
- Align arrows clearly
- Add step numbers for sequences
Cross-Skill Integration
| Skill |
When to Use |
Example |
| sf-metadata |
Get real object/field definitions for ERD |
Skill(skill="sf-metadata") → "Describe Lead object" |
| sf-connected-apps |
Link OAuth flow to Connected App setup |
"Generate JWT Bearer diagram for this Connected App" |
| sf-ai-agentforce |
Visualize Agentforce agent architecture |
"Create flow diagram for FAQ Agent" |
| sf-flow |
Document Flow logic as flowchart |
"Diagram the approval process flow" |
Dependencies
Optional: sf-metadata (for ERD auto-discovery)
Example Usage
1. OAuth Flow Request
User: "Create a JWT Bearer OAuth flow diagram"
You should:
1. Load templates/oauth/jwt-bearer.md
2. Generate Mermaid sequenceDiagram
3. Generate ASCII fallback
4. Score and deliver
2. Data Model Request
User: "Create an ERD for Account, Contact, Opportunity, and Case"
You should:
1. If org connected: Query record counts via query-org-metadata.py
2. Load templates/datamodel/salesforce-erd.md (or cloud-specific template)
3. Generate Mermaid flowchart LR with:
- Object nodes (name + record count, no fields)
- Color coding by object type (Standard=Blue, Custom=Orange)
- Relationship arrows (LK=-->, MD===>)
4. Generate ASCII fallback
5. Score and deliver
3. Integration Diagram Request
User: "Diagram our Salesforce to SAP integration flow"
You should:
1. Ask clarifying questions (sync/async, trigger, protocol)
2. Load templates/integration/api-sequence.md
3. Generate Mermaid sequenceDiagram
4. Generate ASCII fallback
5. Score and deliver
Notes
- Mermaid Rendering: Works in GitHub, VS Code, Notion, Confluence, and most modern tools
- ASCII Purpose: Terminal compatibility, documentation that needs plain text
- Color Accessibility: Palette designed for color-blind accessibility
- Template Customization: Templates are starting points; customize per requirements
License
MIT License. See LICENSE file.
Copyright (c) 2024-2025 Jag Valaiyapathy
1---2name: sf-diagram3description: Creates Salesforce architecture diagrams using Mermaid with ASCII fallback. Use when visualizing OAuth flows, data models (ERDs), integration sequences, system landscapes, role hierarchies, or Agentforce agent architectures.4license: MIT5---6
7# sf-diagram: Salesforce Diagram Generation
8
9Expert diagram creator specializing in Salesforce architecture visualization. Generate clear, accurate, production-ready diagrams using Mermaid syntax with ASCII fallback for terminal compatibility.
10
11## Core Responsibilities
12
131. **Diagram Generation**: Create Mermaid diagrams from requirements or existing metadata
142. **Multi-Format Output**: Provide both Mermaid code and ASCII art fallback
153. **sf-metadata Integration**: Auto-discover objects/fields for ERD diagrams
164. **Validation & Scoring**: Score diagrams against 5 categories (0-80 points)
17
18## Supported Diagram Types
19
20| Type | Mermaid Syntax | Use Case |
21|------|---------------|----------|
22| OAuth Flows | `sequenceDiagram` | Authorization Code, JWT Bearer, PKCE, Device Flow |
23| Data Models | `flowchart LR` | Object relationships with color coding (preferred) |
24| Integration Sequences | `sequenceDiagram` | API callouts, event-driven flows |
25| System Landscapes | `flowchart` | High-level architecture, component diagrams |
26| Role Hierarchies | `flowchart` | User hierarchies, profile/permission structures |
27| Agentforce Flows | `flowchart` | Agent → Topic → Action flows |
28
29## Workflow (5-Phase Pattern)
30
31### Phase 1: Requirements Gathering
32
33Use **AskUserQuestion** to gather:
34- Diagram type (OAuth, ERD, Integration, Landscape, Role Hierarchy, Agentforce)
35- Specific flow or scope (e.g., "JWT Bearer flow" or "Account-Contact-Opportunity model")
36- Output preference (Mermaid only, ASCII only, or Both)
37- Any custom styling requirements
38
39**Then**:
401. If ERD requested, check for sf-metadata availability
412. Create TodoWrite tasks for multi-diagram requests
42
43### Phase 2: Template Selection
44
45**Select template based on diagram type**:
46
47| Diagram Type | Template File |
48|--------------|---------------|
49| Authorization Code Flow | `oauth/authorization-code.md` |
50| Authorization Code + PKCE | `oauth/authorization-code-pkce.md` |
51| JWT Bearer Flow | `oauth/jwt-bearer.md` |
52| Client Credentials Flow | `oauth/client-credentials.md` |
53| Device Authorization Flow | `oauth/device-authorization.md` |
54| Refresh Token Flow | `oauth/refresh-token.md` |
55| Data Model (ERD) | `datamodel/salesforce-erd.md` |
56| Integration Sequence | `integration/api-sequence.md` |
57| System Landscape | `architecture/system-landscape.md` |
58| Role Hierarchy | `role-hierarchy/user-hierarchy.md` |
59| Agentforce Flow | `agentforce/agent-flow.md` |
60
61**Template Path Resolution** (try in order):
621. **Marketplace folder** (always available): `~/.claude/plugins/marketplaces/sf-skills/sf-diagram/templates/[template]`
632. **Project folder** (if working in sf-skills repo): `[project-root]/sf-diagram/templates/[template]`
643. **Cache folder** (if installed individually): `~/.claude/plugins/cache/sf-diagram/*/sf-diagram/templates/[template]`
65
66**Example**: To load JWT Bearer template:
67```
68Read: ~/.claude/plugins/marketplaces/sf-skills/sf-diagram/templates/oauth/jwt-bearer.md
69```
70
71### Phase 3: Data Collection
72
73**For OAuth Diagrams**:
74- Use standard actors (Browser, Client App, Salesforce)
75- Apply CloudSundial-inspired styling
76- Include all protocol steps with numbered sequence
77
78**For ERD/Data Model Diagrams**:
791. If org connected, query record counts for LDV indicators:
80 ```bash
81 python3 scripts/query-org-metadata.py --objects Account,Contact --target-org myorg
82 ```
832. Identify relationships (Lookup vs Master-Detail)
843. Determine object types (Standard, Custom, External)
854. Generate `flowchart LR` with color coding (preferred format)
86
87**For Integration Diagrams**:
88- Identify all systems involved
89- Capture request/response patterns
90- Note async vs sync interactions
91
92### Phase 4: Diagram Generation
93
94**Generate Mermaid code**:
951. Apply color scheme from `docs/color-palette.md`
962. Add annotations and notes where helpful
973. Include autonumber for sequence diagrams
984. For data models: Use `flowchart LR` with object-type color coding
995. Keep ERD objects simple - show object name and record count only (no fields)
100
101**Generate ASCII fallback**:
1021. Use box-drawing characters: `┌ ─ ┐ │ └ ┘ ├ ┤ ┬ ┴ ┼`
1032. Use arrows: `──>` `<──` `───` `─┼─`
1043. Keep width under 80 characters when possible
105
106**Run Validation**:
107```
108Score: XX/80 ⭐⭐⭐⭐ Rating
109├─ Accuracy: XX/20 (Correct actors, flow steps, relationships)
110├─ Clarity: XX/20 (Easy to read, proper labeling)
111├─ Completeness: XX/15 (All relevant steps/entities included)
112├─ Styling: XX/15 (Color scheme, theming, annotations)
113└─ Best Practices: XX/10 (Proper notation, UML conventions)
114```
115
116### Phase 5: Output & Documentation
117
118**Delivery Format**:
119
120````markdown
121## 📊 [Diagram Title]
122
123### Mermaid Diagram
124```mermaid
125[Generated Mermaid code]
126```
127
128### ASCII Fallback
129```
130[Generated ASCII diagram]
131```
132
133### Key Points
134- [Important note 1]
135- [Important note 2]
136
137### Diagram Score
138[Validation results]
139````
140
141### Phase 5.5: Preview (Optional)
142
143Offer localhost preview for real-time diagram iteration. See [references/preview-guide.md](references/preview-guide.md) for setup instructions.
144
145---
146
147## Mermaid Styling Guide
148
149Use Tailwind 200-level pastel fills with dark strokes. See [references/mermaid-styling.md](references/mermaid-styling.md) for complete color palette and examples.
150
151**Quick reference**:
152```
153%%{init: {"flowchart": {"nodeSpacing": 80, "rankSpacing": 70}} }%%
154style A fill:#fbcfe8,stroke:#be185d,color:#1f2937
155```
156
157---
158
159## Scoring Thresholds
160
161| Rating | Score | Meaning |
162|--------|-------|---------|
163| ⭐⭐⭐⭐⭐ Excellent | 72-80 | Production-ready, comprehensive, well-styled |
164| ⭐⭐⭐⭐ Very Good | 60-71 | Complete with minor improvements possible |
165| ⭐⭐⭐ Good | 48-59 | Functional but could be clearer |
166| ⭐⭐ Needs Work | 35-47 | Missing key elements or unclear |
167| ⭐ Critical Issues | <35 | Inaccurate or incomplete |
168
169---
170
171## OAuth Flow Quick Reference
172
173| Flow | Use Case | Key Detail | Template |
174|------|----------|------------|----------|
175| **Authorization Code** | Web apps with backend | User → Browser → App → SF | `oauth/authorization-code.md` |
176| **Auth Code + PKCE** | Mobile, SPAs, public clients | code_verifier + SHA256 challenge | `oauth/authorization-code-pkce.md` |
177| **JWT Bearer** | Server-to-server, CI/CD | Sign JWT with private key | `oauth/jwt-bearer.md` |
178| **Client Credentials** | Service accounts, background | No user context | `oauth/client-credentials.md` |
179| **Device Authorization** | CLI, IoT, Smart TVs | Poll for token after user auth | `oauth/device-authorization.md` |
180| **Refresh Token** | Extend access | Reuse existing tokens | `oauth/refresh-token.md` |
181
182Templates in `templates/oauth/`.
183
184---
185
186## Data Model Notation Reference
187
188### Preferred Format: `flowchart LR`
189
190Use `flowchart LR` (left-to-right) for data model diagrams. This format supports:
191- Individual node color coding by object type
192- Thick arrows (`==>`) for Master-Detail relationships
193- Left-to-right flow for readability
194
195### Relationship Arrows
196```
197--> Lookup (LK) - optional parent, no cascade delete
198==> Master-Detail (MD) - required parent, cascade delete
199-.-> Conversion/special relationship (e.g., Lead converts)
200```
201
202### Object Node Format
203```
204ObjectName["ObjectName<br/>(record count)"]
205```
206
207Example: `Account["Account<br/>(317)"]`
208
209---
210
211## Enhanced ERD Features
212
213### Object Type Color Coding
214
215When using the flowchart-based ERD format, objects are color-coded by type:
216
217| Object Type | Color | Fill | Stroke |
218|-------------|-------|------|--------|
219| Standard Objects | Sky Blue | `#bae6fd` | `#0369a1` |
220| Custom Objects (`__c`) | Orange | `#fed7aa` | `#c2410c` |
221| External Objects (`__x`) | Green | `#a7f3d0` | `#047857` |
222
223### LDV (Large Data Volume) Indicators
224
225For orgs with large datasets, query record counts and display LDV indicators:
226
227```bash
228python3 ~/.claude/plugins/marketplaces/sf-skills/sf-diagram/scripts/query-org-metadata.py \
229 --objects Account,Contact,Opportunity \
230 --target-org myorg
231```
232
233Objects with >2M records display: `LDV[~4M]`
234
235### OWD (Org-Wide Defaults)
236
237Display sharing model on entities: `OWD:Private`, `OWD:ReadWrite`, `OWD:Parent`
238
239### Relationship Types
240
241| Label | Type | Arrow Style | Behavior |
242|-------|------|-------------|----------|
243| `LK` | Lookup | `-->` | Optional parent, no cascade |
244| `MD` | Master-Detail | `==>` | Required parent, cascade delete |
245
246In flowchart format:
247- Lookup: `-->` (single arrow)
248- Master-Detail: `==>` (thick double arrow)
249
250### Data Model Templates
251
252| Template | Objects | Path |
253|----------|---------|------|
254| **Core** | Account, Contact, Opportunity, Case | `templates/datamodel/salesforce-erd.md` |
255| **Sales Cloud** | Account, Contact, Lead, Opportunity, Product, Campaign | `templates/datamodel/sales-cloud-erd.md` |
256| **Service Cloud** | Case, Entitlement, Knowledge, ServiceContract | `templates/datamodel/service-cloud-erd.md` |
257| **Campaigns** | Campaign, CampaignMember, CampaignInfluence | `templates/datamodel/campaigns-erd.md` |
258| **Territory Management** | Territory2, Territory2Model, UserTerritory2Association | `templates/datamodel/territory-management-erd.md` |
259| **Party Model** | AccountContactRelation, ContactContactRelation | `templates/datamodel/party-model-erd.md` |
260| **Quote & Order** | Quote, QuoteLineItem, Order, OrderItem | `templates/datamodel/quote-order-erd.md` |
261| **Forecasting** | ForecastingItem, ForecastingQuota, OpportunitySplit | `templates/datamodel/forecasting-erd.md` |
262| **Consent (GDPR)** | Individual, ContactPointEmail, DataUsePurpose | `templates/datamodel/consent-erd.md` |
263| **Files** | ContentDocument, ContentVersion, ContentDocumentLink | `templates/datamodel/files-erd.md` |
264| **Scheduler** | ServiceAppointment, ServiceResource, ServiceTerritory | `templates/datamodel/scheduler-erd.md` |
265| **Field Service** | WorkOrder, ServiceAppointment, TimeSheet | `templates/datamodel/fsl-erd.md` |
266| **B2B Commerce** | WebStore, WebCart, BuyerGroup, BuyerAccount | `templates/datamodel/b2b-commerce-erd.md` |
267| **Revenue Cloud** | ProductCatalog, ProductSellingModel, PriceAdjustment | `templates/datamodel/revenue-cloud-erd.md` |
268
269### ERD Conventions Documentation
270
271See `docs/erd-conventions.md` for complete documentation of:
272- Object type indicators (`[STD]`, `[CUST]`, `[EXT]`)
273- LDV display format
274- OWD display format
275- Relationship type labels
276- Color palette details
277
278---
279
280## Best Practices
281
282### Sequence Diagrams
283- Use `autonumber` for OAuth flows (step tracking)
284- Use `->>` for requests, `-->>` for responses
285- Use `activate`/`deactivate` for long-running processes
286- Group related actors with `box` blocks
287- Add `Note over` for protocol details (tokens, codes)
288
289### Data Model Diagrams
290- Use `flowchart LR` format (left-to-right flow)
291- Keep objects simple: name + record count only (no fields)
292- Color code by object type: Blue=Standard, Orange=Custom, Green=External
293- Use `-->` for Lookup, `==>` for Master-Detail relationships
294- Add LDV indicator for objects >2M records
295- Use API names, not labels (e.g., `Account` not "Accounts")
296
297### Integration Diagrams
298- Show error paths with `alt`/`else` blocks
299- Include timeout handling for external calls
300- Mark async calls with `-)` notation
301- Add system icons for clarity (☁️ 🔄 🏭 💾)
302
303### ASCII Diagrams
304- Keep width ≤80 characters
305- Use consistent box sizes
306- Align arrows clearly
307- Add step numbers for sequences
308
309---
310
311## Cross-Skill Integration
312
313| Skill | When to Use | Example |
314|-------|-------------|---------|
315| sf-metadata | Get real object/field definitions for ERD | `Skill(skill="sf-metadata")` → "Describe Lead object" |
316| sf-connected-apps | Link OAuth flow to Connected App setup | "Generate JWT Bearer diagram for this Connected App" |
317| sf-ai-agentforce | Visualize Agentforce agent architecture | "Create flow diagram for FAQ Agent" |
318| sf-flow | Document Flow logic as flowchart | "Diagram the approval process flow" |
319
320## Dependencies
321
322**Optional**: sf-metadata (for ERD auto-discovery)
323
324---
325
326## Example Usage
327
328### 1. OAuth Flow Request
329```
330User: "Create a JWT Bearer OAuth flow diagram"
331
332You should:
3331. Load templates/oauth/jwt-bearer.md
3342. Generate Mermaid sequenceDiagram
3353. Generate ASCII fallback
3364. Score and deliver
337```
338
339### 2. Data Model Request
340```
341User: "Create an ERD for Account, Contact, Opportunity, and Case"
342
343You should:
3441. If org connected: Query record counts via query-org-metadata.py
3452. Load templates/datamodel/salesforce-erd.md (or cloud-specific template)
3463. Generate Mermaid flowchart LR with:
347 - Object nodes (name + record count, no fields)
348 - Color coding by object type (Standard=Blue, Custom=Orange)
349 - Relationship arrows (LK=-->, MD===>)
3504. Generate ASCII fallback
3515. Score and deliver
352```
353
354### 3. Integration Diagram Request
355```
356User: "Diagram our Salesforce to SAP integration flow"
357
358You should:
3591. Ask clarifying questions (sync/async, trigger, protocol)
3602. Load templates/integration/api-sequence.md
3613. Generate Mermaid sequenceDiagram
3624. Generate ASCII fallback
3635. Score and deliver
364```
365
366---
367
368## Notes
369
370- **Mermaid Rendering**: Works in GitHub, VS Code, Notion, Confluence, and most modern tools
371- **ASCII Purpose**: Terminal compatibility, documentation that needs plain text
372- **Color Accessibility**: Palette designed for color-blind accessibility
373- **Template Customization**: Templates are starting points; customize per requirements
374
375---
376
377## License
378
379MIT License. See [LICENSE](LICENSE) file.
380Copyright (c) 2024-2025 Jag Valaiyapathy