次のような場合に使用: ユーザーがSalesforce Lightning ページ(複数のコンポーネントを配置可能なカスタマイズ型ページ)を作成、生成、変更、または検証する場合。以下の場面で発動します: - RecordPage(レコード詳細ページ)、AppPage(アプリケーションページ)、HomePage(ホームページ)、Lightning ページ - ページへのコンポーネント追加 - ページのカスタマイズ(例: 「レコードページをカスタマイズする」) - .flexipage-meta.xml ファイル(領域、コンポーネント、デプロイメントエラーに関連するもの) **発動しない場合:** Visualforce ページ、UI内のページレイアウト割り当て、UI Bundle/Experience Cloud サイトページ、FlexiPage の文脈のない Aura/Lightning Web Component(カスタムコンポーネント)の開発は対象外です。
Use when users create, generate, modify, or validate Salesforce Lightning pages (FlexiPages). Trigger on RecordPage, AppPage, HomePage, Lightning pages, adding components to a page, page customization (e.g. 'customize the record page'), or .flexipage-meta.xml files (regions, components, deployment errors). DO NOT TRIGGER for Visualforce pages, page layout assignments in the UI, UI Bundle/Experience Cloud site pages, or Aura/Lightning Web Component development without FlexiPage context.
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.
<packageDirectory> = the path value from sfdx-project.json → packageDirectories[0] (e.g., force-app). Read it from the project file before running commands.
sf template generate flexipage \
--name <PageName> \
--template <RecordPage|AppPage|HomePage> \
--sobject <SObject> \
--primary-field <Field1> \
--secondary-fields <Field2,Field3> \
--detail-fields <Field4,Field5,Field6,Field7> \
--output-dir <packageDirectory>/main/default/flexipages
CRITICAL: If the sf template generate flexipage command fails, STOP.
sf plugins install templates
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 to validate the page and dependencies (use the default package directory from sfdx-project.json):
sf project deploy start --dry-run -d "<packageDirectory>/main/default" --test-level NoTestRun --wait 10 --json
Critical: Fix any deployment errors before proceeding. The page must validate successfully.
After the base page deploys successfully, if the user wants additional components, follow the Adding Components Dynamically workflow below. All component additions MUST go through the discovery and inference pipeline — never write component XML from memory alone.
Read references/xml_rules.md for all XML encoding rules, field reference format, region/facet types, fieldInstance structure, unique identifier requirements, and common deployment error resolutions.
Key rules (quick reminder):
<value> tags: & first, then <, >, ", 'Record.{FieldApiName} (never Object.Field)<identifier> and region <name> must be unique across the file<itemInstances>Read references/identifiers_and_regions.md for the identifier generation algorithm, facet naming patterns (named vs UUID), region selection rules, and container component facet structure.
Location: header region only. See references/record_flexipage_dynamicHighlights.md for full structure.
CLI generates Facets automatically from --primary-field and --secondary-fields.
Use for: Displaying fields in columns. Three-level nesting: Region → Column Facets → Field Facets.
See references/flexipage_fieldSection.md for full structure and XML example.
Critical: The columns property value is a Facet name, not a number.
See references/flexipage_richText.md for encoding rules and XML structure.
Identifier: flexipage_richText or flexipage_richText_{N}
<FlexiPage xmlns="http://soap.sforce.com/2006/04/metadata">
<flexiPageRegions>
<!-- Regions and components here -->
</flexiPageRegions>
<masterLabel>Page Label</masterLabel>
<template>
<name>flexipage:recordHomeTemplateDesktop</name>
</template>
<type>RecordPage</type>
<sobjectType>Object__c</sobjectType> <!-- RecordPage only -->
</FlexiPage>
Page Types:
RecordPage - requires <sobjectType>AppPage - no sobjectTypeHomePage - no sobjectType<identifier> values unique across entire file<name> values unique across entire file<itemInstances>Record.{Field} formatfieldInstanceProperties with uiBehavior<itemInstances> wrapper<type>Region</type>; component facets use <type>Facet</type><mode> tags (only where component patterns require them)__c suffix in page namesRead references/cli_commands.md for full CLI examples (RecordPage, AppPage, HomePage) and available options.
MANDATORY WORKFLOW: ALL component additions to a FlexiPage MUST follow this workflow. Do not write component XML from memory or skip discovery. This applies to standard OOTB components, custom LWC components, and any other component type.
When the user requests components (e.g., "add a related list of contacts and a report"), follow this pipeline:
1. Parse Intent → identify ALL requested components
2. Discover ALL → batch components through 3-tier discovery
3. Infer Properties → run 3-step inference for EACH discovered component
4. Generate XML → produce valid XML for all components together
5. Validate → check identifiers, regions, property completeness
Key rule: Discover ALL components as a batch first (one scan, one MCP call), THEN infer properties for each. Do not invoke discovery steps per-component or interleave discovery and inference.
Extract every component request from the user's utterance. Examples:
Complete each tier for ALL components before moving to the next tier — do NOT run Tier 1→2→3 per component:
| Tier | Source | When | Calls |
|---|---|---|---|
| 1 | Local workspace scan | Always first — run for ALL components | 0 (local only) |
| 2 | discoverUiComponents MCP action |
Single call for all components unresolved after Tier 1 | 1 |
| 3 | Generate new LWC bundle | Only for components still unresolved after Tier 2 + user confirms | 0 |
After Tier 1 completes for all components, collect only the unresolved ones and pass them to Tier 2 in a single MCP call. Only components still unresolved after Tier 2 proceed to Tier 3.
See Local Workspace Scanner and MCP Action Integration sections below for details.
For EACH discovered component, infer properties using the 3-step strategy:
getUiComponentSchemas; for Tier 1 (local), extract @api props from sourcereferences/<name>.md exists, read and follow its inference rulesSee Hybrid Property Inference Strategy below for full details.
What you CANNOT do:
Read references/xml_rules.md before writing any XML. Follow all element naming and structure rules defined there.
Produce <itemInstances> XML for all resolved components:
<componentInstanceProperties> for every property (NOT <properties>)Check the complete FlexiPage for:
Deploy with dry-run (use default package directory from sfdx-project.json):
sf project deploy start --dry-run -d "<packageDirectory>/main/default" --test-level NoTestRun --wait 10 --json
Read references/mcp_action_examples.md for full input/output examples and parameter tables.
Two MCP actions via execute_metadata_action:
| Action | Purpose | When |
|---|---|---|
DISCOVER_UI_COMPONENTS |
Find components for a page type | Tier 2 discovery — single call for all unresolved components |
GET_UI_COMPONENT_SCHEMAS |
Get property schemas | Property inference Step 1 (Tier 2 org components only) |
Key conventions:
namespace/blockName (forward-slash) in MCP calls, namespace:blockName (colon) in XMLpageContext with entityName is required for RECORD_PAGEgetUiComponentSchemas supports partial failures — check each component's success booleanScans the local SFDX project for custom LWC components before making any MCP calls (Tier 1 discovery).
Run the scanner for each component query (local scan — no network calls):
scripts/scan-lwc-components.sh "<query>" [packageDirectory]
The script scans <packageDirectory>/**/lwc/*/, tokenizes camelCase component names, scores them against user intent keywords, and returns a JSON array of matches with confidence tiers:
Run Tier 1 for ALL components before moving any to Tier 2. Collect all unresolved components from Tier 1, then pass them to Tier 2 in a single MCP call.
For medium-confidence matches (40-69%) or multiple high-confidence matches:
.js-meta.xml for <description> and <targetConfigs>Skip local scan when:
<packageDirectory> directory exists in the workspaceFor EACH discovered component, populate its properties using this 3-step strategy in order:
Call getUiComponentSchemas only when the component does not exist on the local machine (i.e., Tier 2 org-discovered components). For local components (Tier 1), extract @api properties directly from the source code instead.
When to call:
@api properties from the component's .js source fileRun scripts/resolve-component-instructions.sh <namespace:component> — it returns the instructions file path if it exists, or empty string.
Examples:
record_flexipage:dynamicHighlights → references/record_flexipage_dynamicHighlights.mdflexipage:fieldSection → references/flexipage_fieldSection.mdc:expenseTracker → (empty — no file)If a file is returned: read and follow its inference rules, XML patterns, and defaults. If empty: skip directly to Step 3.
Instructions files augment the schema — they provide how to derive values from user intent. Any properties in the schema not covered by the instructions file are resolved in Step 3.
For any properties not yet resolved, apply in this priority order:
3a. Smart Default Heuristics:
| Property Pattern | Default Value |
|---|---|
recordId |
{!recordId} |
objectApiName / sObjectName |
Page's <sobjectType> value |
show* / visible* / display* |
true |
hide* / hidden* / disabled* |
false |
| Boolean without prefix | false |
Schema specifies "default" |
Use schema default |
3b. LLM Inference:
Use the component schema + user intent + page context to infer reasonable values. Example: user says "report showing top opportunities" → infer reportName should reference an opportunities report.
3c. User Prompts (last resort): Only prompt the user for critical required properties that cannot be inferred. If user says "skip", omit the component entirely.
| Tier | Extra Step | Schema Call | Instructions |
|---|---|---|---|
| Tier 1 (local) | Extract @api props from source |
No (use source) | If exists |
| Tier 2 (org) | — | Yes | If exists |
| Tier 3 (generated) | Extract @api from just-generated source |
No (just created) | No |
When no component is found locally (Tier 1) or in the org (Tier 2), offer to generate a new LWC.
Always confirm before creating. Explain: component name. If user declines: skip, continue with other components.
After creating the LWC bundle:
@api properties from the generated sourcerecordId and objectApiNamec:{componentName} as the componentNamecustomerHealthScorecustomerHealthScore/| File | When to read |
|---|---|
references/xml_rules.md |
Before writing or editing any FlexiPage XML — encoding, field refs, identifiers, deployment errors |
references/identifiers_and_regions.md |
When adding components — identifier algorithm, facet naming, region selection, container pattern |
references/cli_commands.md |
When bootstrapping new pages — full CLI examples for RecordPage, AppPage, HomePage |
references/mcp_action_examples.md |
When calling MCP actions — full input/output JSON for discoverUiComponents and getUiComponentSchemas |
references/flexipage_fieldSection.md |
When adding a Field Section with columns |
references/record_flexipage_dynamicHighlights.md |
When adding a Dynamic Highlights panel |
references/flexipage_richText.md |
When adding a Rich Text component |
scripts/scan-lwc-components.sh |
Tier 1 local workspace scan — tokenizes and scores LWC component names against user query |
scripts/resolve-component-instructions.sh |
Property inference Step 2 — resolves component definition to instructions file path |
To add a new component pattern: Create references/<namespace>_<componentName>.md following the structure in existing files. The skill automatically checks for the file during Step 2 of property inference.
After generating XML for dynamically added components, verify ALL of the following before deployment:
<identifier> values from the entire FlexiPage file_2, _3, etc.)record_flexipage:dynamicHighlights → header onlyflexipage:fieldSection → main or tab facetsflexipage:richText → any region<value> tags (must be entity-encoded)<flexiPageRegions> block<flexiPageRegions> block with multiple <itemInstances>原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。