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.
assets/oauth/authorization-code.md
View on GitHub# Authorization Code Flow Template
Standard OAuth 2.0 Authorization Code flow for web applications with backend servers.
## When to Use
- Web applications with secure backend servers
- Confidential clients that can protect client_secret
- When you need refresh tokens for long-lived access
## Mermaid Template
```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(165,243,252,0.3) BROWSER/USER
participant U as š¤ User
participant B as š Browser
end
box rgba(221,214,254,0.3) CLIENT APPLICATION
participant A as š„ļø App Server
end
box rgba(167,243,208,0.3) SALESFORCE
participant SF as āļø Salesforce<br/>Authorization Server
end
Note over U,SF: Authorization Code Flow (RFC 6749)
U->>B: 1. Click "Login with Salesforce"
B->>A: 2. Initiate OAuth Login
A->>A: 3. Generate state parameter (CSRF protection)
A->>B: 4. Redirect to Salesforce /authorize
Note over A,B: response_type=code<br/>client_id=CONSUMER_KEY<br/>redirect_uri=CALLBACK_URL<br/>scope=api refresh_token<br/>state=RANDOM_STATE
B->>SF: 5. GET /services/oauth2/authorize
SF->>B: 6. Display Login Page
U->>SF: 7. Enter Username & Password
SF->>SF: 8. Authenticate User
SF->>B: 9. Display Consent Screen
Note over SF,B: "App requests access to:<br/>⢠API Access<br/>⢠Refresh Token"
U->>SF: 10. Grant Consent (Allow)
SF->>SF: 11. Generate Authorization Code
SF->>B: 12. Redirect to callback_uri
Note over SF,B: ?code=AUTH_CODE_123<br/>&state=RANDOM_STATE
B->>A: 13. Deliver Code to App Server
A->>A: 14. Verify state matches
A->>SF: 15. POST /services/oauth2/token
Note over A,SF: grant_type=authorization_code<br/>code=AUTH_CODE_123<br/>client_id=CONSUMER_KEY<br/>client_secret=CONSUMER_SECRET<br/>redirect_uri=CALLBACK_URL
SF->>SF: 16. Validate Code & Client
SF->>A: 17. Return Tokens
Note over SF,A: {<br/> access_token: "...",<br/> refresh_token: "...",<br/> instance_url: "https://...",<br/> token_type: "Bearer",<br/> issued_at: "..."<br/>}
A->>A: 18. Store tokens securely
A->>B: 19. Set user session
B->>U: 20. ā
Successfully Logged In
```
## ASCII Fallback Template
```text
āāāāāāāāāāāā āāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāāāā
ā User/ ā ā Application ā ā Salesforce ā
ā Browser ā ā Server ā ā (Auth Server) ā
āāāāāā¬āāāāāā āāāāāāāāā¬āāāāāāāā āāāāāāāāāāā¬āāāāāāāāāāā
ā ā ā
ā 1. Click Login ā ā
āāāāāāāāāāāāāāāāāāā>ā ā
ā ā ā
ā 2. Redirect to ā ā
ā /authorize ā ā
ā<āāāāāāāāāāāāāāāāāāā ā
ā ā ā
ā 3. GET /authorize (client_id, scope, state) ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā>ā
ā ā ā
ā 4. Login Page ā
ā<āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā ā
ā 5. Enter Credentials ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā>ā
ā ā ā
ā 6. Consent Screen ā
ā<āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā ā
ā 7. Grant Consent (Allow) ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā>ā
ā ā ā
ā 8. Redirect with ?code=ABC123&state=xyz ā
ā<āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā ā
ā 9. Deliver Code ā ā
āāāāāāāāāāāāāāāāāāā>ā ā
ā ā ā
ā ā 10. POST /token ā
ā ā (code, secret) ā
ā āāāāāāāāāāāāāāāāāāāāāāā>ā
ā ā ā
ā ā 11. Access Token + ā
ā ā Refresh Token ā
ā ā<āāāāāāāāāāāāāāāāāāāāāāā
ā ā ā
ā 12. Logged In ā
ā ā
ā<āāāāāāāāāāāāāāāāāāā ā
```
## Key Endpoints
| Endpoint | URL | Purpose |
|----------|-----|---------|
| Authorization | `https://login.salesforce.com/services/oauth2/authorize` | Start OAuth flow |
| Token | `https://login.salesforce.com/services/oauth2/token` | Exchange code for tokens |
## Security Considerations
1. **Always use HTTPS** for redirect_uri in production
2. **Validate state parameter** to prevent CSRF attacks
3. **Store client_secret securely** (never in client-side code)
4. **Use short-lived access tokens** with refresh token rotation
## Customization Points
Replace these placeholders:
- `CONSUMER_KEY` ā Your Connected App's Consumer Key
- `CONSUMER_SECRET` ā Your Connected App's Consumer Secret
- `CALLBACK_URL` ā Your registered callback URL
- `RANDOM_STATE` ā Cryptographically random state value
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 |