跳到正文
cccskills
免费在 GitHub 公开

salesforce-flow-expert

Expert guidance for Salesforce Flow implementation from design through deployment. Use this skill when building Screen Flows, Record-Triggered Flows, Schedule-Triggered Flows, or Autolaunched Flows. Covers Flow design patterns, metadata XML generation, variable/element reference validation, governor limit optimization, and sf CLI deployment. Critical for preventing reference errors (undeclared variables, invalid element references) and deployment failures. Use when creating new Flows, debugging Flow errors, optimizing Flow performance, or deploying Flows to production.

中文简介正在准备中。当前显示原文说明。

集成工具Salesforce

实测评分 未实测

查看安装方法

包含的文件(17)

  • SKILL.md16.0 KB
  • assets/deployment_configs/package_template.xml227 B
  • assets/deployment_configs/sfdx-project_template.json235 B
  • assets/error_reference_table.md11.4 KB
  • assets/flow_metadata_templates/autolaunched_meta_template.xml1.7 KB
  • assets/flow_metadata_templates/record_triggered_meta_template.xml1.7 KB
  • assets/flow_metadata_templates/schedule_triggered_meta_template.xml1.9 KB
  • assets/flow_metadata_templates/screen_flow_meta_template.xml1.3 KB
  • references/deployment_guide.md8.4 KB
  • references/flow_types_guide.md9.0 KB
  • references/governor_limits_optimization.md14.2 KB
  • references/metadata_xml_reference.md8.2 KB
  • references/variable_reference_patterns.md25.1 KB
  • scripts/deploy_flow.py12.3 KB
  • scripts/extract_flow_elements.py8.3 KB
  • scripts/generate_flow_metadata.py7.9 KB
  • scripts/validate_flow.py25.6 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Salesforce Flow Expert

Overview

This skill provides comprehensive guidance for Salesforce Flow implementation, from initial design through production deployment. It emphasizes preventing the most common Flow errors—particularly variable and element reference issues—through automated validation, proper metadata generation, and deployment best practices. Use this skill to build robust, error-free Flows that deploy successfully on the first attempt.

When to Use This Skill

Invoke this skill when:

  • Flow Development: Creating new Screen Flows, Record-Triggered Flows, Schedule-Triggered Flows, or Autolaunched Flows
  • Error Prevention: Validating Flows before deployment to catch reference errors, type mismatches, or undeclared variables
  • Debugging: Troubleshooting "Element not found", "Variable not declared", or type mismatch errors
  • Deployment: Deploying Flows to sandbox or production using sf CLI with proper error handling
  • Optimization: Identifying governor limit issues (DML in loops, SOQL in loops) and implementing bulkification patterns
  • Metadata Management: Generating or troubleshooting Flow-meta.xml files with correct structure and API versions

Core Capabilities

1. Flow Design & Pattern Selection

Choose the right Flow type and design pattern for your requirements.

Flow Type Decision Matrix:

Flow TypeTriggerBest ForUser Interaction
Screen FlowUser clicks button/linkGuided processes, data collectionYes
Record-TriggeredRecord create/update/deleteAutomated business logicNo
Schedule-TriggeredTime-based scheduleBatch processing, cleanupNo
AutolaunchedCalled by other automationReusable logic, sub-flowsNo

Common Design Patterns:

Pattern 1: Wizard Pattern (Screen Flow)

Screen 1 (Input) → Decision → Screen 2A/2B → Assignment → Create Records → Screen 3 (Confirmation)

Pattern 2: Before-Save Trigger (Record-Triggered)

Trigger: Before Update → Decision → Assignment (Update Fields) → End

Pattern 3: Batch Processing (Schedule-Triggered)

Start → Get Records (Filter) → Loop → Update Records (Batch) → End

Variable Naming Conventions:

  • Use camelCase for variables: totalAmount, selectedAccount, recordCount
  • Use PascalCase for elements: Screen_Input_Details, Assignment_Calculate_Total
  • Prefix collections with col: colAccounts, colOpportunities
  • Prefix boolean variables with is or has: isApproved, hasError

Example - Screen Flow Variable Setup:

<variables>
    <name>selectedAccountId</name>
    <dataType>String</dataType>
    <isInput>false</isInput>
    <isOutput>false</isOutput>
</variables>

<variables>
    <name>colOpportunities</name>
    <dataType>SObject</dataType>
    <isCollection>true</isCollection>
    <objectType>Opportunity</objectType>
</variables>

Reference: Load references/flow_types_guide.md for detailed patterns, examples, and best practices for each Flow type.

2. Flow Metadata XML Generation

Generate correct Flow-meta.xml files with proper structure and API version compatibility.

Why Metadata Matters: Flow deployment requires both the Flow definition (.flow) and metadata file (.flow-meta.xml). Incorrect metadata structure causes deployment failures even if the Flow logic is perfect.

Use the Generation Script:

cd scripts/
python3 generate_flow_metadata.py ../MyFlow.flow \
  --type recordTriggeredFlow \
  --api-version 60.0 \
  --status Draft \
  --output ../MyFlow.flow-meta.xml

Manual Metadata Structure (when needed):

<?xml version="1.0" encoding="UTF-8"?>
<Flow xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>60.0</apiVersion>
    <status>Draft</status>
    <processType>AutoLaunchedFlow</processType>
    <label>My Flow Label</label>
    <description>Flow description</description>
</Flow>

Key Metadata Fields:

  • apiVersion: Must match your org's API version (typically 58.0-61.0)
  • status: Draft or Active
  • processType: Must match Flow type (see reference guide)
  • label: Human-readable name (required)

Reference: Load references/metadata_xml_reference.md for complete metadata structure, required vs optional elements, API version differences, and troubleshooting common metadata errors.

3. Pre-Deployment Validation

CRITICAL: Validate Flows before deployment to catch 90%+ of errors upfront, especially variable/element reference errors.

Use the Validation Script:

cd scripts/
python3 validate_flow.py ../MyFlow.flow-meta.xml --format markdown

Validation Categories:

3.1 Reference Validation (Priority 1)

The #1 cause of Flow deployment failures. The validator detects:

Error Type 1: Undeclared Variable

[E001] Undeclared Variable: 'totalAmout' referenced in Assignment_1
       → Did you mean 'totalAmount'? (declared on line 45)
       → Fix: Rename 'totalAmout' to 'totalAmount' in Assignment_1

Error Type 2: Invalid Element Reference

[E002] Invalid Element Reference: 'Screen_2' in Connector but element not found
       → Available elements: Screen_Input, Screen_Confirm, Assignment_1
       → Fix: Update Connector to reference existing element name

Error Type 3: Type Mismatch

[E003] Type Mismatch: Variable 'count' (Text) assigned Number value
       → Variable type: Text
       → Assignment value type: Number
       → Fix: Change variable 'count' to Number type or convert value to Text

Error Type 4: Collection vs Single Value

[E004] Collection/Single Value Mismatch: 'colAccounts' (Collection) used in single value context
       → Variable 'colAccounts' is a collection (isCollection=true)
       → Used in: Assignment expects single Account object
       → Fix: Use Loop to iterate or Get Records with FIRST operator

3.2 Governor Limit Validation

Critical Patterns to Avoid:

DML in Loop (ERROR):

<!-- BAD: DML inside Loop -->
<loops>
    <name>Loop_Through_Accounts</name>
    <recordUpdates>
        <name>Update_Account</name>  <!-- ❌ Causes governor limit error -->
    </recordUpdates>
</loops>

Correct Pattern:

<!-- GOOD: Collect in loop, DML after -->
<loops>
    <name>Loop_Through_Accounts</name>
    <assignments>
        <name>Add_To_Collection</name>  <!-- ✅ Collect changes -->
    </assignments>
</loops>
<recordUpdates>
    <name>Update_All_Accounts</name>  <!-- ✅ Batch update after loop -->
</recordUpdates>

SOQL in Loop (WARNING):

[W001] SOQL in Loop: Get_Records element 'Get_Related_Opportunities' inside Loop_Through_Accounts
       → Risk: May exceed 100 SOQL query limit
       → Recommendation: Move Get Records before loop and filter in memory

3.3 Metadata Validation

  • API version compatibility check
  • Required fields present (apiVersion, status, processType, label)
  • Element ordering validation
  • XML structure correctness

3.4 Naming Convention Check

[W002] Naming Convention: Variable 'var1' should use camelCase (e.g., 'myVariable')
[W003] Naming Convention: Element 'screen1' should use PascalCase (e.g., 'Screen_Input')

Example Validation Report:

=== Flow Validation Report ===
Flow: MyScreenFlow.flow-meta.xml
API Version: 60.0
Status: ❌ FAILED (3 errors, 2 warnings)

ERRORS:
[E001] Undeclared Variable: 'totalAmout' referenced in Assignment_Calculate_Total
       → Did you mean 'totalAmount'?
[E002] Invalid Element Reference: 'Screen_2' in Connector_After_Input
[E003] Type Mismatch: Variable 'recordCount' (Text) assigned Number value

WARNINGS:
[W001] SOQL in Loop: Get_Records inside Loop_Process_Accounts
[W002] Naming Convention: Variable 'amt' should use descriptive camelCase

✅ Validation complete. Fix 3 errors before deployment.

Reference: Load references/variable_reference_patterns.md for comprehensive error catalog (Top 10 errors), root cause analysis, fix patterns, and prevention checklists.

4. Deployment & Troubleshooting

Deploy validated Flows using sf CLI with proper error handling and rollback capabilities.

Prerequisites:

# Verify sf CLI installed
sf --version

# Authenticate to org
sf org login web --alias my-sandbox

Deployment Workflow:

Option 1: Manual Deployment (Quick)

# Deploy single Flow
sf project deploy start --source-dir force-app/main/default/flows/MyFlow.flow-meta.xml --target-org my-sandbox

# Check deployment status
sf project deploy report --target-org my-sandbox

Option 2: Automated Deployment with Validation (Recommended)

cd scripts/
python3 deploy_flow.py \
  --source-dir ../flows/ \
  --target-org my-sandbox \
  --validate-only  # Dry run first

# If validation passes, deploy for real
python3 deploy_flow.py \
  --source-dir ../flows/ \
  --target-org my-sandbox

Common Deployment Errors:

Error: "INVALID_TYPE_ON_FIELD_IN_RECORD"

Cause: Variable type doesn't match field type
Fix: Check variable dataType matches target object field type
Example: Text variable assigned to Number field

Error: "INVALID_FIELD_OR_REFERENCE"

Cause: Referencing non-existent field or variable
Fix: Run validate_flow.py to find undeclared references

Error: "FLOW_ACTIVE_VERSION_NOT_FOUND"

Cause: No active version exists when trying to run Flow
Fix: Activate Flow version after deployment: Setup → Flows → [Flow Name] → Activate

Rollback Procedure:

# If deployment fails, rollback to previous version
sf project deploy start \
  --source-dir backups/flows_backup_20250109/ \
  --target-org my-sandbox

Reference: Load references/deployment_guide.md for complete sf CLI command reference, advanced deployment workflows, error handling patterns, and rollback procedures.

Workflow: Design to Deployment

Follow this end-to-end workflow for error-free Flow implementation:

Phase 1: Design (10-20 minutes)

  1. Determine Flow type using decision matrix (Capability 1)
  2. Sketch Flow logic on paper or whiteboard
  3. Define variables with proper naming conventions
  4. Identify data operations (Get, Create, Update, Delete)

Phase 2: Build (30-60 minutes) 5. Create Flow in Flow Builder (Setup → Flows → New Flow) 6. Implement business logic following design patterns 7. Test manually in sandbox with sample data 8. Export Flow files (.flow and .flow-meta.xml)

Phase 3: Validate (5 minutes) 9. Run validation script:

python3 scripts/validate_flow.py MyFlow.flow-meta.xml --format markdown > validation_report.md
  1. Review validation report and fix all errors
  2. Re-run validation until clean (0 errors)

Phase 4: Deploy (5-10 minutes) 12. Deploy to sandbox with validation: bash python3 scripts/deploy_flow.py --source-dir flows/ --target-org sandbox --validate-only 13. If validation passes, deploy for real: bash python3 scripts/deploy_flow.py --source-dir flows/ --target-org sandbox 14. Activate Flow in target org 15. Test Flow in sandbox before promoting to production

Phase 5: Production (10 minutes) 16. Repeat validation and deployment for production org 17. Monitor Flow runs: Setup → Flows → [Flow Name] → Run History 18. Set up Debug Logs if issues occur

Best Practices

Security

  1. Use $Setup variables for system context: $Setup.User.Id, $Setup.Organization.Name
  2. Respect record-level security: Flow runs in system context by default (respects OWD but not sharing rules)
  3. Validate user input in Screen Flows before DML operations
  4. Use Apex @InvocableMethod for sensitive operations requiring with sharing

Performance

  1. Bulkify all operations: Design Flows to handle up to 200 records per transaction
  2. Avoid SOQL in loops: Query once before loop, filter in memory
  3. Batch DML operations: Collect records in loop, update outside loop
  4. Use Fast Field Updates for simple field changes in Record-Triggered Flows (Before-Save triggers)
  5. Limit Flow depth: Avoid nesting Flows more than 2 levels deep

Maintainability

  1. Use descriptive names: Assignment_Calculate_Total_With_Tax not Assignment_1
  2. Add descriptions to all elements explaining their purpose
  3. Version control: Store Flow files in Git with meaningful commit messages
  4. Document decisions: Add Flow description explaining business logic and assumptions
  5. Test with bulk data: Always test with 200 records to validate governor limits

Error Handling

  1. Use Fault Connectors on elements that can fail (Get Records, Create Records)
  2. Create error variables: hasError (Boolean), errorMessage (Text)
  3. Display error screens to users in Screen Flows
  4. Log errors to custom Error_Log__c object for debugging
  5. Set default values for variables to prevent null reference errors

Resources

This skill includes comprehensive scripts and reference documentation:

scripts/

validate_flow.py (Primary Script)

  • Comprehensive pre-deployment validation
  • Detects variable/element reference errors
  • Governor limit analysis
  • Generates detailed reports (text, JSON, markdown)
  • Use before every deployment to catch 90%+ of errors

generate_flow_metadata.py

  • Creates Flow-meta.xml files with correct structure
  • Handles API version compatibility
  • Supports all Flow types
  • Use when metadata is missing or corrupted

deploy_flow.py

  • Automated deployment via sf CLI
  • Pre-deployment validation checks
  • Error parsing and rollback support
  • Use for CI/CD pipelines and batch deployments

extract_flow_elements.py

  • Parses Flow XML to extract structure
  • Lists variables, elements, connections
  • Generates dependency graphs
  • Use for documentation and analysis

references/

variable_reference_patterns.md (Most Important)

  • Top 10 most common variable/element reference errors
  • Each error includes: frequency, message, root cause, fix pattern, prevention checklist
  • Variable declaration best practices
  • Scope and visibility rules
  • Comprehensive troubleshooting guide

flow_types_guide.md

  • Detailed guide for each Flow type (Screen, Record-Triggered, Schedule-Triggered, Autolaunched)
  • Design patterns with complete examples
  • When to use each type
  • Common pitfalls and how to avoid them

metadata_xml_reference.md

  • Complete Flow-meta.xml structure reference
  • Element ordering requirements (critical for deployment success)
  • API version differences
  • Common metadata errors and fixes

governor_limits_optimization.md

  • DML and SOQL optimization patterns
  • Anti-patterns vs correct patterns with code examples
  • Bulkification checklist
  • Performance monitoring queries

deployment_guide.md

  • sf CLI command reference
  • Deployment workflows (manual, automated, CI/CD)
  • Error handling and troubleshooting
  • Rollback procedures

Load these references as needed to inform your Flow development and troubleshooting.

assets/

flow_metadata_templates/

  • XML templates for each Flow type
  • Use as starting point for manual metadata creation

deployment_configs/

  • package.xml template for deployment
  • sfdx-project.json template for SFDX projects

error_reference_table.md

  • Quick lookup table mapping error messages to solutions
  • Use when troubleshooting specific deployment errors

Note: Always test Flows in a sandbox environment before deploying to production. Use the validation script before every deployment to catch errors early. Follow your organization's change management and deployment processes.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Track and update action item status from natural language updates like 'Seanのメールには返信しておいた' or 'Lu対応予定'. Integrates with daily-comms-ops workflow. Use when managing action items across communication channels.

中文简介正在准备中。当前显示原文说明。

takusaotome/claude-skills-library102026年10月23日 更新

AI活用提案の専門コンサルタントスキル。LLM・AIエージェントの活用事例知識を基に、業界別、部門別、シーン別に最適なAI導入提案を行います。システム化、業務改善、効率化を得意とし、具体的な活用事例、期待効果、導入ステップを含む実践的な提案を提供します。Use when proposing AI/LLM adoption strategies for specific industries, departments, or business scenarios.

中文简介正在准备中。当前显示原文说明。

takusaotome/claude-skills-library102026年10月23日 更新

Generate AI-powered BPO service proposals for Japanese companies in the US market. Use when creating outsourcing proposals with AI service menus, ROI estimation, implementation roadmaps, and bilingual (JA/EN) proposal documents for 在米日系企業向けAI実装.

中文简介正在准备中。当前显示原文说明。

takusaotome/claude-skills-library102026年10月23日 更新

AI(LLM)が生成した日本語テキストの「AI臭」を検出・診断し、人間らしい文章にリライトするスキル。 Use when: 「AIっぽい文章を直して」「人間らしくリライトして」「AI臭を消して」「この文章をもっと自然にして」 「テキストのAI感を減らして」「機械っぽさを取りたい」 "make this sound more human", "remove AI tone", "humanize this text", "detect if this is AI-generated". 6つのAI特有パターン(視覚的マーカー、単調なリズム、マニュアル的構成、非コミット姿勢、抽象語の濫用、 定型メタファー)を正規表現ベースで検出し、0-100のAI臭スコアを算出。3つの人間化技法 (バランスを崩す・客観を崩す・論理を崩す)でリライトを実行する。 Note: 検出スクリプトは日本語テキスト専用。英語テキストの場合はClaude自身がreferences/を参照して分析・リライトする。

中文简介正在准备中。当前显示原文说明。

takusaotome/claude-skills-library102026年10月23日 更新

Generate audit-ready internal control design documents from As-Is business process inventories. Produces control IDs, assertion mappings, procedures, SoD analysis, KPIs, materiality thresholds, and implementation roadmaps. Use when building internal controls for new audit engagements, SOX/J-SOX compliance, or process improvement initiatives.

中文简介正在准备中。当前显示原文说明。

takusaotome/claude-skills-library102026年10月23日 更新

Review audit-related documents (control design documents, bottleneck analyses, requirements definitions, etc.) for quality, scoring them 0-100 with a severity-rated findings list. Use when reviewing audit documents, checking control design quality, or verifying cross-document consistency. Supports documents governed by US GAAP, IFRS, or J-GAAP.

中文简介正在准备中。当前显示原文说明。

takusaotome/claude-skills-library102026年10月23日 更新

查看 takusaotome 的全部技能

报告此技能的问题