npx skills add ...
npx skills add forcedotcom/sf-skills --skill generating-flexipage
Use this skill when users need to create, generate, modify, or validate Salesforce Lightning pages (FlexiPages). Trigger when users mention RecordPage, AppPage, HomePage, Lightning pages, page layouts, adding components to pages, or page customization. Also use when users say things like 'create a Lightning page', 'add a component to a page', 'customize the record page', 'generate a FlexiPage', or when they're working with FlexiPage XML files and need help with components, regions, or deployment errors. Always use this skill for any FlexiPage-related work, even if they just mention 'page' in the context of Salesforce.
npx skills add forcedotcom/sf-skills --skill generating-flexipage
Use this skill when you need to:
CRITICAL: When creating NEW FlexiPages, you MUST ALWAYS start with the CLI template command. Never create FlexiPage XML from scratch - the CLI provides valid structure, proper regions, and correct component configuration that prevents deployment errors.
Generate Lightning pages (RecordPage, AppPage, HomePage) using CLI bootstrapping for component discovery and configuration.
MANDATORY FOR NEW PAGES: This step is NOT optional. Always use the CLI template command when creating a new FlexiPage. The CLI generates valid XML structure, proper regions, and correct metadata that prevents common deployment errors. Only skip this step if you're editing an existing FlexiPage file.
CRITICAL: If the sf template generate flexipage command fails, STOP.
sf template generate flexipage commandDo NOT continue to Step 2 until the template command succeeds. The generated XML is required for the entire workflow.
RecordPage:
--sobject (e.g., Account, Custom_Object__c)--primary-field: Most important identifying field (e.g., Name)--secondary-fields: Record summary (recommended 4-6, max 12)--detail-fields: Full record details, including required fields (e.g., Name)AppPage:
HomePage:
Name (not FirstName/LastName), BillingAddress (not BillingStreet/BillingCity/BillingState), MailingAddress, etc. when availableName) in the --detail-fields parameter, even if they're also used in --primary-field or --secondary-fieldsRun a dry-run deployment of the entire project to validate the page and dependencies:
Critical: Fix any deployment errors before proceeding. The page must validate successfully.
MANDATORY: Stop after Step 2. Do not add components or edit the FlexiPage XML.
This applies even if the user requested:
What you CAN do:
What you CANNOT do:
Any property value with HTML/XML characters MUST be manually encoded in the following order (wrong order causes double-encoding corruption):
Wrong:
Correct:
Check your XML: Search for <value> tags - they should never contain raw < or > characters.
ALWAYS: Record.{FieldApiName}
NEVER: {ObjectName}.{FieldApiName}
Template Regions (header, main, sidebar):
Component Facets (internal slots like fieldSection columns):
Rule: If it's a template region name → Region. If it's a component slot → Facet.
Every fieldInstance requires:
Rules:
<itemInstances> wrapperfieldInstanceProperties with uiBehaviorRecord.{Field} formatEVERY identifier and region/facet name MUST be unique across the entire FlexiPage file.
Critical Rules:
<flexiPageRegions> blocks with the same <name><itemInstances><identifier> valueWrong - This WILL FAIL with duplicate name error:
Correct - Combine itemInstances in ONE region:
When to combine vs separate:
detailTabContent vs relatedTabContent)Cause: Invalid field API name - field doesn't exist on the object or has incorrect spelling Fix: Use MCP tools or describe commands to discover valid fields, then update the field reference (see Field Selection Rules)
Cause: Used ObjectName.Field instead of Record.Field
Fix: Change to Record.{FieldApiName}
Cause: Multiple fieldInstances in one itemInstances
Fix: Each fieldInstance needs its own <itemInstances> wrapper
Cause: No uiBehavior specified
Fix: Add fieldInstanceProperties with uiBehavior
Cause: Facet defined but not referenced by any component
Fix: Remove Facet or reference it in a component property
Cause: Unencoded HTML/XML in property values
Fix: Manually encode <, >, &, ", ' in all <value> tags
Cause: Invalid page name (don't use __c suffix in page names)
Fix: Use "Volunteer_Record_Page" not "Volunteer__c_Record_Page"
Cause: Added <mode> tag to region
Fix: Remove <mode> tags - they're not needed for standard regions
CRITICAL: Before generating ANY new identifier or facet name, follow the rules in section 5 of "Critical XML Rules" above.
Identifier Generation Algorithm:
Examples:
relatedList_contacts_1relatedList_contacts_2richText_header_1fieldSection_details_1Facet Naming - Two Patterns:
Named facets (for major content areas):
detailTabContent (detail tab content)maintabs (main tab container)sidebartabs (sidebar tab container)UUID facets (for internal structure):
Facet-{8hex}-{4hex}-{4hex}-{4hex}-{12hex}Facet-66d5a4b3-bf14-4665-ba75-1ceaa71b2cdeWhen adding components to existing files:
<itemInstances> to that existing region (see section 5 above for details)Parse regions from file - don't hardcode names. Templates vary:
flexipage:recordHomeTemplateDesktop → header, main, sidebarruntime_service_fieldservice:... → header, main, footerDefault placement: End of target region (after last <itemInstances>)
Insertion pattern:
Components like tabs, accordions, field sections require facets.
Pattern:
Location: Must be in header region.
Explicit Fields (via CLI): Use the most important fields to show a summary of the record. The single primary field is used to identify the record, like a name. The secondary fields (max 12, recommended 6) are used as a summary of the record.
CLI generates Facets with field references automatically.
Use for: Displaying fields in columns. Structure: Three-level nesting:
Component name: flexipage:richText
Use for: Displaying HTML-formatted rich text content with support for text formatting, headings, lists, tables, images, links, forms, and multimedia elements. Preserves styling and layout. Escape all special characters in the default text.
Location: Can be used in any region on any page type (Home, Record, App, Community pages).
CLI generates the component directly without nested structures.
User: "Add a rich text component to force-app/.../Account_Record_Page.flexipage-meta.xml"
Structure: Single-level component (no facets):
XML Structure Example:
Identifier Pattern: flexipage_richText or flexipage_richText_{sequence}
Page Types:
RecordPage - requires <sobjectType>AppPage - no sobjectTypeHomePage - no sobjectTypeBefore deploying:
<identifier> values anywhere in file<name> values in <flexiPageRegions><itemInstances>, NOT separate regions with same nameRecord.{Field} formatfieldInstanceProperties with uiBehavior<itemInstances> wrapper<type>Region</type><type>Facet</type><mode> tags in regions__c suffix in page namesAll templates support:
--output-dir (default: current directory)--api-version (default: latest)--label (default: page name)--description*_