Detect unsafe contexts, queries in loops, hardcoded IDs, and more to optimize Salesforce Flows
Table of contentsUsageLightning Flow Scanner VSX is plug-and-play. Open any project with flows and use our side bar or the Command Palette and type
Privacy: Zero user data collected. All processing is client-side. → See our Security Policy.
Default Rules📌Tip: To link directly to a specific rule, use the full GitHub anchor link format. Example: https://flow-scanner.github.io/lightning-flow-scanner/#unsafe-running-context
ProblemsRules that detect issues highly likely to cause runtime errors, security risks, governor limit exceptions, or deployment failures. DML Statement In A LoopExecuting DML operations (insert, update, delete) inside a loop is a high-risk anti-pattern that frequently causes governor limit exceptions. All database operations should be collected and executed once, outside the loop.
Rule ID: Hardcoded IdAvoid hard-coding record IDs, as they are unique to a specific org and will not work in other environments. Instead, store IDs in variables—such as merge-field URL parameters or a Get Records element—to make the Flow portable, maintainable, and flexible.
Rule ID: Hardcoded UrlAvoid hard-coding URLs, as they may change between environments or over time. Instead, store URLs in variables or custom settings to make the Flow adaptable, maintainable, and environment-independent.
Rule ID: Process BuilderProcess Builder is retired. Continuing to use it increases maintenance overhead and risks future compatibility issues. Migrating automation to Flow reduces risk and improves maintainability.
Rule ID: SOQL Query In A LoopRunning SOQL queries inside a loop can rapidly exceed query limits and severely degrade performance. Queries should be executed once, with results reused throughout the loop.
Rule ID: Unsafe Running ContextFlows configured to run in System Mode without Sharing grant access to all data, bypassing user permissions. Avoid this setting to prevent security risks and protect sensitive data.
Rule ID: Duplicate DML OperationWhen a Flow performs database operations across multiple screens, users navigating backward can cause the same actions to run multiple times. To prevent unintended changes, either restrict backward navigation or redesign the Flow so database operations execute in a single, forward-moving step.
Rule ID: Missing Fault PathElements that can fail should include a Fault Path to handle errors gracefully. Without it, failures show generic errors to users. Fault Paths improve reliability and user experience.
Rule ID: Missing Null HandlerGet Records operations return null when no data is found. Without handling these null values, Flows can fail or produce unintended results. Adding a null check improves reliability and ensures the Flow behaves as expected.
Rule ID: Recursive After UpdateAfter-save Flows that update the same record can trigger recursion, causing unintended behavior or performance issues. Avoid updating the triggering record in after-save Flows; use before-save Flows instead to prevent recursion.
Rule ID: SuggestionsRules in this category recommend better patterns and optimizations related to performance, bulkification, trigger behavior, and overall design. Following them improves efficiency and long-term maintainability without affecting correctness. Action Call In A LoopRepeatedly invoking Apex actions inside a loop can exhaust governor limits and lead to performance issues. Where possible, bulkify your logic by moving the action call outside the loop and passing a collection variable instead.
Rule ID: Get Record All FieldsAvoid using Get Records to retrieve all fields unless necessary. This improves performance, reduces processing time, and limits exposure of unnecessary data.
Rule ID: Inactive FlowInactive Flows should be deleted or archived to reduce risk. Even when inactive, they can cause unintended record changes during testing or be activated as subflows. Keeping only active, relevant Flows improves safety and maintainability.
Rule ID: Invalid API VersionFlows running on outdated API versions may behave inconsistently when newer platform features or components are used. From API version 50.0 onward, the API Version attribute explicitly controls Flow runtime behavior. Keeping Flows aligned with a supported API version helps prevent compatibility issues and ensures predictable execution.
Rule ID: Missing Filter Record Trigger
Record-triggered Flows without filters on changed fields or entry conditions execute on every record change. Adding filters ensures the Flow runs only when needed, improving performance.
Rule ID: Same Record Field UpdatesBefore-save Flows can safely update the triggering record directly via $Record, applying changes efficiently without extra DML operations. Using before-save updates improves performance
Rule ID: Excessive Cyclomatic ComplexityHigh numbers of loops and decision elements increase a Flow's cyclomatic complexity. To maintain simplicity and readability, consider using subflows or splitting a Flow into smaller, ordered Flows.
Rule ID: Missing Trigger OrderRecord-triggered Flows without a specified Trigger Order may execute in an unpredictable sequence. Setting a Trigger Order ensures your Flows run in the intended order.
Rule ID: Record ID as String
Flows that use a String variable for a record ID instead of receiving the full record introduce unnecessary complexity and additional Get Records queries. Using the complete record simplifies the Flow and improves performance.
Rule ID: Transform Instead of Loop
Loop elements that perform direct Assignments on each item can slow down Flows. Using Transform elements allows bulk operations on collections, improving performance and reducing complexity.
Rule ID: LayoutRules in this category enforce consistency in naming, documentation, element organization, and visual layout. They help ensure Flows remain readable, well-documented, and structured as automations scale. Flow Naming ConventionUsing clear and consistent Flow names improves readability, discoverability, and maintainability. A good naming convention helps team members quickly understand a Flow's purpose—for example, including a domain and brief description like Service_OrderFulfillment. Adopt a naming pattern that aligns with your organization's standards.
Rule ID: Missing Flow DescriptionFlow descriptions are essential for documentation and maintainability. Include a description for each Flow, explaining its purpose and where it's used.
Rule ID: Missing Metadata Description
Elements and metadata without a description reduce clarity and maintainability. Adding descriptions improves readability and makes your automation easier to understand.
Rule ID: Unclear API NameElements with unclear or duplicated API names, like Copy_X_Of_Element, reduce Flow readability. Make sure to update the API name when copying elements to keep your Flow organized.
Rule ID: Unreachable ElementUnconnected elements never execute and add unnecessary clutter. Remove or connect unused Flow elements to keep Flows clean and efficient.
Rule ID: Unused VariableUnused variables are never referenced and add unnecessary clutter. Remove them to keep Flows efficient and easy to maintain.
Rule ID: Missing Auto LayoutAuto-Layout automatically arranges and aligns Flow elements, keeping the canvas organized and easier to maintain. Enabling it saves time and improves readability.
Rule ID: ConfigurationIt is recommend to configure and define:
Most Lightning Flow Scanner distributions automatically resolve configurations from Configure RulesBy default, all default rules are executed. You can customize individual rules and override the rules to be executed without having to specify every rule. Below is a breakdown of the available attributes of rule configuration:
Configure SeverityWhen the severity is not provided it will be
Override ExpressionsSome rules are configurable and allow overriding their default expressions. You configure these overrides the same way as severity, as shown in the examples below.
Customize MessagesIf not provided,
Disable RulesTo disable a rule, set
Define ExceptionsDefining exceptions allows you to exclude specific scenarios from rule enforcement. Exceptions can be specified at the flow, rule, or result level to provide fine-grained control. Below is a breakdown of the available attributes of exception configuration:
Example
Exclude FlowsExclude by File Path (Node.js only)Use glob patterns to exclude flows based on their file system location. This is useful for excluding entire directories or specific name patterns:
Environment compatibility: Exclude by Flow API Name (Browser-compatible)Exclude specific flows by their unique API names, regardless of their location. This is particularly useful for:
Environment compatibility: Scan ModesBeta ModeNew rules are introduced in Beta mode before being added to the default ruleset. To include current Beta rules, enable the optional betamode parameter in your configuration:
Rule ModeBy default, Lightning Flow Scanner runs all default rules and merges any custom configurations you provide. This means you can override specific rules without having to list every rule to be executed. If instead, you want to run only the rules you explicitly specify, use
Installation
To install via CLI (VS Code)
Development
|