tools-libraries
Purpose
Salesforce Flow metadata stored as XML contains extensive verbose metadata that consumes LLM context windows and makes it difficult for AI agents to parse flow logic. This research identifies available tools and approaches for simplifying, compressing, or visualizing flow metadata to make it more LLM-friendly.
Key Findings
Problem Statement
- Salesforce Flow XML is verbose and complex, containing extensive metadata
- Wastes LLM context window tokens on structural metadata rather than business logic
- Makes it difficult for AI agents to understand flow behavior and logic
- No dedicated “Salesforce Flow metadata compression for LLMs” tool exists as of 2026
Existing Tools & Libraries
1. salesforce-flow-visualiser (npm) ⭐ Most Relevant
Purpose: Parse Salesforce Flow meta.xml to text-based graphical formats (Mermaid, PlantUML)
- GitHub: toddhalfpenny/salesforce-flow-visualiser
- Install:
npm i salesforce-flow-visualiser - Usage:
import { parseFlow } from 'salesforce-flow-visualiser';const mermaidStr = await parseFlow(xmlString, 'mermaid', { outputAsMarkdown: true });
- Benefits for LLMs: Converts verbose XML to compact visual diagram syntax that LLMs can parse more efficiently
- Supports: Mermaid and PlantUML output formats
2. Lightning Flow Scanner (embedded library)
Purpose: XML parser and rule engine with 20+ rules for flow analysis
- Part of: Salesforce Inspector Reloaded
- Usage:
const flowObject = new Flow(xmlData);const scanResults = scanner.scan(flowObject, userConfig);
- Benefits for LLMs: Provides structured parsing of flow XML into JavaScript objects
- Use Case: Quality checking, linting, and extracting structured flow components
3. JSForce Metadata API (npm)
Purpose: JavaScript library for Salesforce Metadata API access
- Docs: JSForce Documentation
- GitHub Tools: jsforce-metadata-tools
- Usage:
conn.metadata.retrieve({ packageNames: ['My Package'] }).stream().pipe(fs.createWriteStream("./package.zip"));
- Benefits for LLMs: Programmatic retrieval and manipulation of flow metadata
- Note: Flows have special handling quirks (version numbers appended to filenames)
4. sf-metadata (npm)
Purpose: General Salesforce metadata file reader/writer
- npm: sf-metadata
- Features: Read, write, process Salesforce metadata files using
xml2js - Supports: Glob patterns like
**/*.flow-meta.xml - Benefits for LLMs: Baseline XML parsing utilities
5. metadata-xml-tool (CLI)
Purpose: CLI tool for processing Salesforce Metadata XML files
- GitHub: amtrack/metadata-xml-tool
- Install:
npm install -g metadata-xml-tool - Commands:
remove-element,remove-element-matching,replace-tag-value - Benefits for LLMs: Strip unnecessary metadata elements before feeding to LLM
6. Salesforce Flow MetaData Downloader (Chrome Extension)
Purpose: Download/copy flow metadata as JSON directly from Salesforce Lightning
- Chrome Store: Flow Metadata Downloader
- Features:
- One-click download from Flow Builder or Flow List
- Built-in prompt for extracting flows for LLM tools
- Uses Salesforce Tooling API
- Benefits for LLMs: Quick extraction with LLM-friendly prompts
Salesforce Native Features
Einstein for Flow (LLM-Powered Flow Generation)
- Announced: 2023, powered by Salesforce’s CodeGen LLM
- Feature: Natural language flow generation
- Input: Text prompt describing desired flow
- Output: Fully built flow in seconds
- Docs: Einstein for Flow
Spring ‘26: LLM-Powered Iterative Flow Builder
- Announced: Spring ‘26 release
- Feature: Agentforce-like iterative builder for flows
- Benefit: Work with LLM using natural language for flow modifications
- Similar to: Firebase Studio with Gemini
- Source: 10 New Salesforce Flow Features
Recommended Approaches
For Reducing Flow XML Context Size
-
Use salesforce-flow-visualiser
- Convert XML to Mermaid diagram syntax
- Feed compact visual representation to LLM
- LLM can reason about flow logic without verbose XML
-
Use metadata-xml-tool to strip metadata
- Remove unnecessary XML elements (e.g., position coordinates, UI metadata)
- Keep only logic-relevant elements (decisions, assignments, queries)
-
Parse with Lightning Flow Scanner
- Extract structured flow components as JSON
- Feed JSON structure to LLM instead of raw XML
For LLM-Powered Flow Development
-
Einstein for Flow (Native)
- Generate flows from natural language prompts
- Uses Salesforce’s CodeGen LLM
-
Spring ‘26 Iterative Builder (Coming Soon)
- Natural language flow modifications
- Iterative refinement with LLM assistance
Comparison Matrix
| Tool | Flow-Specific | npm Available | Parse XML | Visualize | Simplify for LLM |
|---|---|---|---|---|---|
| salesforce-flow-visualiser | ✅ | ✅ | ✅ | ✅ (Mermaid) | ✅ High |
| lightning-flow-scanner | ✅ | ✅ | ✅ | ❌ | ✅ Medium |
| JSForce | ❌ (general) | ✅ | ✅ | ❌ | ❌ Low |
| sf-metadata | ❌ (general) | ✅ | ✅ | ❌ | ❌ Low |
| metadata-xml-tool | ❌ (general) | ✅ CLI | ✅ | ❌ | ✅ Medium |
| Flow Metadata Downloader | ✅ | ❌ (Chrome) | ❌ | ❌ | ✅ Low |
Implementation Strategy
Quick Win: Mermaid Conversion Pipeline
# 1. Install toolnpm i salesforce-flow-visualiser
# 2. Parse flow XML to Mermaidimport { parseFlow } from 'salesforce-flow-visualiser';const mermaidDiagram = await parseFlow(flowXml, 'mermaid');
# 3. Feed to LLMconst llmInput = `Analyze this Salesforce Flow:\n\n${mermaidDiagram}`;Estimated Context Reduction: 60-80% compared to raw XML
Advanced: Custom Metadata Stripper
// Use metadata-xml-tool to remove UI positioningmetadata-xml-tool remove-element-matching "locationX|locationY|connector"
// Keep only logic elementsconst logicElements = ['decisions', 'assignments', 'recordLookups', 'loops'];Related Technologies
Agentforce & Metadata-Driven LLM Pipelines
- Data 360: All pipeline stages support LLM processing with custom prompts
- Metadata-Driven: Configuration without code changes
- Cloud Table Abstraction: Adds semantic metadata (column names, relationships, compression)
- Source: Data 360 Architecture
Einstein Trust Layer & LLM Data Masking
- Purpose: Secure LLM integrations with data/privacy controls
- Feature: RAG (Retrieval Augmented Generation) with customer data
- Security: Data masking for sensitive information
- Source: LLM Data Masking
Future Opportunities
Custom Tool Development
Potential: Build a specialized “Flow-to-LLM” preprocessor that:
- Strips all UI metadata (coordinates, connectors, descriptions)
- Extracts only decision logic, formulas, and data operations
- Outputs as structured JSON or compact DSL
- Integrates with Claude Code or other AI coding tools
Estimated Effort: 1-2 weeks for MVP
Tech Stack:
xml2jsfor parsing- Custom AST transformation
- Output to JSON or custom DSL
Sources
- Salesforce Flow Visualiser - GitHub
- Lightning Flow Scanner - Salesforce Inspector Reloaded
- JSForce Metadata Tools - GitHub
- JSForce Documentation
- sf-metadata - npm
- metadata-xml-tool - GitHub
- Salesforce Flow MetaData Downloader - Chrome Extension
- Einstein for Flow - Salesforce Admins
- 10 New Salesforce Flow Features in Spring ‘26 - Salesforce Ben
- How to Create LLM with Salesforce Data - Airbyte
- Metadata Your Admin Blueprint for Building Better Agents - Salesforce Admins
- Agentforce Metadata Deployment - Accelirate
- Scaling Metadata for Agentic AI - Salesforce News
- Data 360 Architecture - Salesforce Architects
- LLM Data Masking - Salesforce Blog