$npx -y skills add forcedotcom/sf-skills --skill automation-flow-generateGenerate Salesforce Flows using the MCP tool execute_metadata_action. Use when the user asks to create, build, or generate a flow — including Screen, Autolaunched, Record-Triggered (before/after-save), Scheduled. Also trigger for flow-like requests such as \"when a record is crea
| 1 | ## Goal |
| 2 | |
| 3 | Generate Salesforce Flow metadata by running the required 3-step MCP pipeline (fetchGroundedObjectMetadata → flowElementSelection → flowElementGeneration) and return the flow XML. |
| 4 | |
| 5 | ## When to Use This Skill |
| 6 | |
| 7 | Use this skill when you need to: |
| 8 | - Create any type of Flow (Screen, Autolaunched, Record-Triggered, Scheduled) |
| 9 | - Generate Flow metadata XML |
| 10 | - Automate business processes without code |
| 11 | - Build user-guided workflows or background automation |
| 12 | - Troubleshoot deployment errors related to Flows |
| 13 | |
| 14 | ## Specification |
| 15 | |
| 16 | # Flow Metadata Specification |
| 17 | |
| 18 | ## Overview |
| 19 | Salesforce Flows are powerful automation tools that enable complex business process automation without code. Flows can collect and process data through interactive screens, execute logic and calculations, manipulate records, call external services, and trigger based on various events. Flow types include Screen Flows (user-guided), Autolaunched Flows (background processing), Record-Triggered Flows (database events) and Scheduled Flows (time-based). |
| 20 | |
| 21 | ## Purpose |
| 22 | - Automate complex business processes with declarative logic and branching |
| 23 | - Guide users through multi-step data collection and decision workflows via Screen Flows |
| 24 | - Perform CRUD operations on Salesforce records automatically |
| 25 | - Execute background processing and integrations via Autolaunched Flows |
| 26 | - React to record changes in real-time with Record-Triggered Flows |
| 27 | - Schedule recurring tasks and batch operations with Scheduled Flows |
| 28 | - Create reusable, maintainable automation that admins can modify without code |
| 29 | |
| 30 | ## Flow Generation Pipeline |
| 31 | |
| 32 | **MANDATORY: You MUST follow this exact 3-step pipeline. No exceptions. No shortcuts. No skipping steps. Do NOT manually create flow metadata XML or attempt to generate flow metadata outside of this pipeline. Do NOT attempt to use any other tool, API, or method to generate flow metadata. This pipeline is the ONLY supported way to generate flows. Any deviation will produce invalid or broken metadata.** |
| 33 | |
| 34 | ### MCP Connection Details |
| 35 | |
| 36 | **All 3 pipeline steps MUST be called using this MCP tool:** |
| 37 | - **MCP Tool Name:** `execute_metadata_action` |
| 38 | - **The `action` parameter** selects which pipeline step to run: `"fetchGroundedObjectMetadata"`, `"flowElementSelection"`, or `"flowElementGeneration"` |
| 39 | |
| 40 | |
| 41 | Flow generation is a **strict 3-step pipeline**. ALL steps must be called in order. Every step is required. **There is no alternative approach — this is the only way to generate flow metadata:** |
| 42 | |
| 43 | ### Step 1 (REQUIRED): Fetch Grounded Object Metadata (`fetchGroundedObjectMetadata`) |
| 44 | Fetches org schema metadata relevant to the flow generation request. This step is **mandatory** and must always be called first. |
| 45 | |
| 46 | **Inputs (all required):** |
| 47 | - **userPrompt** (STRING, REQUIRED): The user's natural language request |
| 48 | - **inflightMetadata** (ARRAY, REQUIRED): Custom objects/fields from local sfdx project. Use empty array `[]` if none needed. |
| 49 | |
| 50 | **Outputs:** |
| 51 | - **groundingMetadata** (STRING): Grounded object metadata for org schema relevant to the request, returned as a JSON string. **You must pass this directly to Step 2 — it is already a string and does not need to be serialized again.** |
| 52 | |
| 53 | ### Step 2 (REQUIRED): Flow Element Selection (`flowElementSelection`) |
| 54 | Selects flow elements (assignments, decisions, record ops, etc.) and their connections based on the user prompt and grounded metadata. This step is **mandatory** and must be called after Step 1. |
| 55 | |
| 56 | **Inputs (all required):** |
| 57 | - **userPrompt** (STRING, REQUIRED): The user's natural language request (**must be the same value as Step 1**) |
| 58 | - **groundingMetadata** (STRING, REQUIRED): Org schema metadata (**must be the exact string returned from Step 1 output** — pass it directly, do NOT serialize it again) |
| 59 | - **operationId** (STRING, REQUIRED): Operation ID (use empty string `""` for first call) |
| 60 | |
| 61 | **Outputs:** |
| 62 | - **operationId** (STRING): Operation ID. **You must pass this to Step 3.** |
| 63 | - **userOutput** (STRING): Reasoning for next steps. You can show this to the user. |
| 64 | |
| 65 | ### Step 3 (REQUIRED): Flow Element Generation (`flowElementGeneration`) |
| 66 | Generates flow metadata element by element. This step is **mandatory** and must be called after Step 2. **Must be called repeatedly in a loop until `isComplete` is `true`.** |
| 67 | |
| 68 | **Inputs (all required):** |
| 69 | - **operationId** (STRING, REQUIRED): Operation ID **from Step 2 output** |
| 70 | - **requestSource** (STRING, REQUIRED): The source of the request. Use **`"A4V"`** to get flow metada |