@salesforce/afv-skills 1.29.0 → 1.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/README.md +2 -0
  2. package/package.json +1 -1
  3. package/skills/agentforce-architecture-analyze/README.md +2 -8
  4. package/skills/agentforce-architecture-analyze/SKILL.md +2 -2
  5. package/skills/agentforce-architecture-analyze/references/contract.json +4 -4
  6. package/skills/agentforce-architecture-analyze/references/soql_fields.md +1 -1
  7. package/skills/data360-activate/README.md +0 -1
  8. package/skills/data360-activate/SKILL.md +0 -2
  9. package/skills/data360-code-extension-generate/SKILL.md +15 -2
  10. package/skills/data360-connect/README.md +0 -2
  11. package/skills/data360-connect/SKILL.md +0 -2
  12. package/skills/data360-harmonize/SKILL.md +0 -1
  13. package/skills/data360-orchestrate/README.md +0 -7
  14. package/skills/data360-orchestrate/SKILL.md +0 -2
  15. package/skills/data360-prepare/README.md +0 -1
  16. package/skills/data360-prepare/SKILL.md +0 -1
  17. package/skills/data360-query/README.md +0 -1
  18. package/skills/data360-query/SKILL.md +0 -1
  19. package/skills/data360-segment/README.md +0 -1
  20. package/skills/data360-segment/SKILL.md +0 -2
  21. package/skills/dx-pkg-post-install-configure/SKILL.md +184 -0
  22. package/skills/experience-cms-brand-apply/SKILL.md +47 -16
  23. package/skills/experience-lwc-generate/README.md +3 -2
  24. package/skills/experience-lwc-generate/references/async-notification-patterns.md +1 -1
  25. package/skills/experience-lwc-generate/references/component-patterns.md +3 -3
  26. package/skills/experience-lwc-generate/references/flow-integration-guide.md +1 -1
  27. package/skills/experience-lwc-generate/references/lwc-best-practices.md +4 -4
  28. package/skills/experience-lwc-generate/references/scoring-and-testing.md +1 -1
  29. package/skills/experience-lwc-generate/references/state-management.md +2 -2
  30. package/skills/experience-lwc-generate/references/triangle-pattern.md +3 -3
  31. package/skills/experience-lwc-generate/scripts/post-tool-validate.py +2 -2
  32. package/skills/experience-lwc-generate/scripts/template_validator.py +1 -1
  33. package/skills/experience-ui-bundle-app-coordinate/SKILL.md +198 -34
  34. package/skills/experience-ui-bundle-app-coordinate/scripts/check-hosting-target.sh +26 -0
  35. package/skills/experience-ui-bundle-app-coordinate/scripts/check-sfdx-project.sh +15 -0
  36. package/skills/experience-ui-bundle-metadata-generate/SKILL.md +19 -8
  37. package/skills/experience-ui-bundle-metadata-generate/references/csp-metadata-format.md +2 -2
  38. package/skills/experience-ui-bundle-metadata-generate/scripts/check-api-version.sh +30 -0
  39. package/skills/external-diagram-mermaid-generate/README.md +2 -2
  40. package/skills/external-diagram-mermaid-generate/SKILL.md +1 -3
  41. package/skills/external-diagram-mermaid-generate/assets/agentforce/agent-flow.md +4 -4
  42. package/skills/external-diagram-mermaid-generate/assets/architecture/system-landscape.md +1 -1
  43. package/skills/external-diagram-mermaid-generate/assets/datamodel/b2b-commerce-erd.md +3 -3
  44. package/skills/external-diagram-mermaid-generate/assets/datamodel/campaigns-erd.md +1 -1
  45. package/skills/external-diagram-mermaid-generate/assets/datamodel/consent-erd.md +2 -2
  46. package/skills/external-diagram-mermaid-generate/assets/datamodel/files-erd.md +2 -2
  47. package/skills/external-diagram-mermaid-generate/assets/datamodel/forecasting-erd.md +2 -2
  48. package/skills/external-diagram-mermaid-generate/assets/datamodel/fsl-erd.md +2 -2
  49. package/skills/external-diagram-mermaid-generate/assets/datamodel/party-model-erd.md +1 -1
  50. package/skills/external-diagram-mermaid-generate/assets/datamodel/quote-order-erd.md +3 -3
  51. package/skills/external-diagram-mermaid-generate/assets/datamodel/revenue-cloud-erd.md +2 -2
  52. package/skills/external-diagram-mermaid-generate/assets/datamodel/sales-cloud-erd.md +1 -1
  53. package/skills/external-diagram-mermaid-generate/assets/datamodel/salesforce-erd.md +1 -1
  54. package/skills/external-diagram-mermaid-generate/assets/datamodel/scheduler-erd.md +2 -2
  55. package/skills/external-diagram-mermaid-generate/assets/datamodel/service-cloud-erd.md +3 -3
  56. package/skills/external-diagram-mermaid-generate/assets/datamodel/territory-management-erd.md +1 -1
  57. package/skills/external-diagram-mermaid-generate/assets/integration/api-sequence.md +1 -1
  58. package/skills/external-diagram-mermaid-generate/assets/oauth/authorization-code-pkce.md +1 -1
  59. package/skills/external-diagram-mermaid-generate/assets/oauth/authorization-code.md +1 -1
  60. package/skills/external-diagram-mermaid-generate/assets/oauth/client-credentials.md +1 -1
  61. package/skills/external-diagram-mermaid-generate/assets/oauth/device-authorization.md +2 -2
  62. package/skills/external-diagram-mermaid-generate/assets/oauth/jwt-bearer.md +2 -2
  63. package/skills/external-diagram-mermaid-generate/assets/oauth/refresh-token.md +1 -1
  64. package/skills/external-diagram-mermaid-generate/assets/oauth/user-agent-social-sign-on.md +2 -2
  65. package/skills/external-diagram-mermaid-generate/assets/role-hierarchy/user-hierarchy.md +1 -1
  66. package/skills/external-diagram-mermaid-generate/references/color-palette.md +13 -13
  67. package/skills/external-diagram-mermaid-generate/references/diagram-conventions.md +5 -5
  68. package/skills/external-diagram-mermaid-generate/references/erd-conventions.md +1 -1
  69. package/skills/external-diagram-mermaid-generate/references/mermaid-styling.md +2 -2
  70. package/skills/external-diagram-mermaid-generate/references/preview-guide.md +1 -1
  71. package/skills/external-diagram-mermaid-generate/references/usage-examples.md +9 -9
  72. package/skills/external-diagram-mermaid-generate/scripts/README.md +1 -1
  73. package/skills/integration-connectivity-connected-app-configure/README.md +4 -5
  74. package/skills/integration-connectivity-connected-app-configure/SKILL.md +2 -2
  75. package/skills/integration-connectivity-connected-app-configure/references/example-usage.md +7 -7
  76. package/skills/integration-connectivity-connected-app-configure/references/migration-guide.md +1 -1
  77. package/skills/integration-connectivity-connected-app-configure/references/oauth-flows-reference.md +1 -1
  78. package/skills/integration-connectivity-connected-app-configure/references/testing-validation-guide.md +3 -3
  79. package/skills/integration-connectivity-generate/README.md +1 -1
  80. package/skills/integration-connectivity-generate/SKILL.md +6 -0
  81. package/skills/integration-connectivity-generate/assets/callouts/rest-queueable-callout.cls +1 -1
  82. package/skills/integration-connectivity-generate/assets/external-services/external-service-operations.md +1 -1
  83. package/skills/integration-connectivity-generate/assets/soap/wsdl2apex-guide.md +1 -1
  84. package/skills/integration-connectivity-generate/references/callout-patterns.md +4 -0
  85. package/skills/integration-connectivity-generate/references/cdc-guide.md +2 -2
  86. package/skills/integration-connectivity-generate/references/event-driven-architecture-guide.md +5 -5
  87. package/skills/integration-connectivity-generate/references/event-patterns.md +3 -2
  88. package/skills/integration-connectivity-generate/references/external-services-guide.md +4 -1
  89. package/skills/integration-connectivity-generate/references/messaging-api-v2.md +2 -2
  90. package/skills/integration-connectivity-generate/references/named-credentials-automation.md +1 -1
  91. package/skills/integration-connectivity-generate/references/named-credentials-guide.md +12 -2
  92. package/skills/integration-connectivity-generate/references/platform-events-guide.md +3 -3
  93. package/skills/integration-connectivity-generate/references/rest-callout-patterns.md +1 -1
  94. package/skills/integration-connectivity-generate/references/scoring-rubric.md +1 -1
  95. package/skills/integration-connectivity-generate/references/security-best-practices.md +5 -2
  96. package/skills/integration-connectivity-generate/scripts/configure-named-credential.sh +16 -5
  97. package/skills/integration-connectivity-generate/scripts/set-api-credential.sh +11 -2
  98. package/skills/integration-connectivity-generate/scripts/suggest_credential_setup.py +4 -3
  99. package/skills/integration-connectivity-generate/scripts/validate_integration.py +1 -1
  100. package/skills/omnistudio-callable-apex-generate/README.md +1 -5
  101. package/skills/omnistudio-callable-apex-generate/SKILL.md +14 -4
  102. package/skills/omnistudio-callable-apex-generate/assets/pattern_callable_vanilla.cls +8 -1
  103. package/skills/omnistudio-callable-apex-generate/examples/Test_VlocityOpenInterface2Conversion/TRANSCRIPT.md +1 -1
  104. package/skills/omnistudio-callable-apex-generate/examples/Test_VlocityOpenInterfaceConversion/TRANSCRIPT.md +1 -1
  105. package/skills/omnistudio-datamapper-generate/SKILL.md +1 -1
  106. package/skills/omnistudio-datamapper-generate/assets/completion-summary-template.md +2 -2
  107. package/skills/omnistudio-datamapper-generate/references/best-practices.md +9 -9
  108. package/skills/omnistudio-datamapper-generate/references/naming-conventions.md +6 -6
  109. package/skills/omnistudio-datapacks-deploy/README.md +1 -1
  110. package/skills/omnistudio-datapacks-deploy/examples/business-internet-plus-bundle/deploy-business-internet-plus-bundle.yaml +1 -1
  111. package/skills/omnistudio-dependencies-analyze/SKILL.md +12 -5
  112. package/skills/omnistudio-dependencies-analyze/references/dependency-patterns.md +9 -9
  113. package/skills/omnistudio-dependencies-analyze/references/namespace-guide.md +1 -1
  114. package/skills/omnistudio-epc-catalog-generate/README.md +1 -1
  115. package/skills/omnistudio-flexcard-generate/SKILL.md +11 -4
  116. package/skills/omnistudio-flexcard-generate/references/best-practices.md +6 -6
  117. package/skills/omnistudio-flexcard-generate/references/data-binding-guide.md +9 -9
  118. package/skills/omnistudio-integration-procedure-generate/SKILL.md +9 -1
  119. package/skills/omnistudio-integration-procedure-generate/references/element-types.md +3 -3
  120. package/skills/omnistudio-omniscript-generate/SKILL.md +2 -2
  121. package/skills/omnistudio-omniscript-generate/references/best-practices.md +1 -1
  122. package/skills/omnistudio-omniscript-generate/scripts/check-duplicate-omniscript.sh +8 -0
  123. package/skills/omnistudio-omniscript-generate/scripts/deploy-omniscript.sh +8 -0
  124. package/skills/platform-apex-logs-debug/README.md +2 -2
  125. package/skills/platform-apex-logs-debug/references/cli-commands.md +2 -2
  126. package/skills/platform-apex-logs-debug/references/debug-log-reference.md +16 -16
  127. package/skills/platform-apex-logs-debug/references/log-analysis-tools.md +2 -2
  128. package/skills/platform-apex-test-run/README.md +1 -1
  129. package/skills/platform-apex-test-run/references/test-fix-loop.md +2 -2
  130. package/skills/platform-apex-test-run/references/testing-best-practices.md +3 -3
  131. package/skills/platform-custom-field-generate/SKILL.md +12 -11
  132. package/skills/platform-custom-field-generate/references/advanced-picklists.md +17 -17
  133. package/skills/platform-custom-report-type-generate/SKILL.md +259 -0
  134. package/skills/platform-custom-report-type-generate/examples/AccountProjectsWithTasks.reportType-meta.xml +51 -0
  135. package/skills/platform-custom-report-type-generate/examples/AccountsWithIndustry.reportType-meta.xml +27 -0
  136. package/skills/platform-custom-report-type-generate/examples/AccountsWithProjects.reportType-meta.xml +44 -0
  137. package/skills/platform-custom-report-type-generate/references/category-values.md +32 -0
  138. package/skills/platform-custom-report-type-generate/references/errors-and-troubleshooting.md +24 -0
  139. package/skills/platform-data-manage/README.md +4 -4
  140. package/skills/platform-data-manage/references/bulk-testing-example.md +1 -1
  141. package/skills/platform-data-manage/references/crud-workflow-example.md +2 -2
  142. package/skills/platform-data-manage/references/orchestration.md +6 -6
  143. package/skills/platform-dataspace-access-configure/SKILL.md +318 -0
  144. package/skills/platform-docs-get/SKILL.md +4 -0
  145. package/skills/platform-docs-get/scripts/extract_salesforce_doc.py +78 -13
  146. package/skills/platform-encryption-configure/SKILL.md +122 -0
  147. package/skills/platform-encryption-configure/assets/EncryptionKey.settings-meta.xml +17 -0
  148. package/skills/platform-encryption-configure/assets/PlatformEncryption.settings-meta.xml +15 -0
  149. package/skills/platform-encryption-configure/assets/encrypted-field.field-meta.xml +22 -0
  150. package/skills/platform-encryption-configure/examples/cache-only-keys.settings-meta.xml +11 -0
  151. package/skills/platform-encryption-configure/references/encryption-schemes.md +34 -0
  152. package/skills/platform-encryption-configure/references/key-models.md +34 -0
  153. package/skills/platform-encryption-configure/references/tenant-secret-lifecycle.md +23 -0
  154. package/skills/platform-encryption-configure/scripts/validate-encryption-metadata.sh +54 -0
  155. package/skills/platform-flexipage-generate/SKILL.md +281 -346
  156. package/skills/platform-flexipage-generate/references/cli_commands.md +39 -0
  157. package/skills/platform-flexipage-generate/references/flexipage_fieldSection.md +162 -0
  158. package/skills/platform-flexipage-generate/references/flexipage_richText.md +84 -0
  159. package/skills/platform-flexipage-generate/references/identifiers_and_regions.md +167 -0
  160. package/skills/platform-flexipage-generate/references/mcp_action_examples.md +104 -0
  161. package/skills/platform-flexipage-generate/references/record_flexipage_dynamicHighlights.md +119 -0
  162. package/skills/platform-flexipage-generate/references/xml_rules.md +335 -0
  163. package/skills/platform-flexipage-generate/scripts/resolve-component-instructions.sh +42 -0
  164. package/skills/platform-flexipage-generate/scripts/scan-lwc-components.sh +113 -0
  165. package/skills/platform-metadata-api-context-get/SKILL.md +13 -10
  166. package/skills/platform-metadata-deploy/README.md +2 -2
  167. package/skills/platform-metadata-deploy/references/agent-deployment-guide.md +2 -2
  168. package/skills/platform-metadata-deploy/references/deployment-workflows.md +16 -16
  169. package/skills/platform-metadata-deploy/references/orchestration.md +3 -3
  170. package/skills/platform-metadata-deploy/references/trigger-deployment-safety.md +2 -2
  171. package/skills/platform-models-api-configure/SKILL.md +140 -0
  172. package/skills/platform-models-api-configure/scripts/get-orgjwt.sh +48 -0
  173. package/skills/platform-policy-rule-generate/SKILL.md +260 -0
  174. package/skills/platform-policy-rule-generate/references/deploy-errors.md +54 -0
  175. package/skills/platform-policy-rule-generate/references/fixtures-index.md +29 -0
  176. package/skills/platform-policy-rule-generate/references/policy-schema-full.md +250 -0
  177. package/skills/platform-policy-rule-generate/references/templates-access.md +132 -0
  178. package/skills/platform-policy-rule-generate/references/templates-advanced.md +58 -0
  179. package/skills/platform-policy-rule-generate/references/templates-record.md +75 -0
  180. package/skills/platform-policy-rule-generate/references/templates-transform.md +70 -0
  181. package/skills/platform-policy-rule-generate/references/templates.md +10 -0
  182. package/skills/platform-policy-rule-generate/references/ui-compatibility.md +142 -0
  183. package/skills/platform-soql-query/README.md +1 -1
  184. package/skills/platform-soql-query/SKILL.md +1 -1
  185. package/skills/platform-soql-query/references/anti-patterns.md +1 -1
  186. package/skills/platform-soql-query/references/field-coverage-rules.md +1 -1
  187. package/skills/platform-soql-query/references/query-optimization.md +1 -1
  188. package/skills/platform-soql-query/scripts/post-tool-validate.py +3 -3
  189. package/skills/data360-activate/CREDITS.md +0 -5
  190. package/skills/data360-connect/CREDITS.md +0 -5
  191. package/skills/data360-harmonize/CREDITS.md +0 -3
  192. package/skills/data360-orchestrate/CREDITS.md +0 -15
  193. package/skills/data360-orchestrate/UPSTREAM.md +0 -45
  194. package/skills/data360-prepare/CREDITS.md +0 -7
  195. package/skills/data360-query/CREDITS.md +0 -7
  196. package/skills/data360-segment/CREDITS.md +0 -3
  197. package/skills/experience-lwc-generate/CREDITS.md +0 -5
  198. package/skills/external-diagram-mermaid-generate/CREDITS.md +0 -46
  199. package/skills/external-diagram-visual-generate/CREDITS.md +0 -80
  200. package/skills/external-diagram-visual-generate/README.md +0 -83
  201. package/skills/external-diagram-visual-generate/SKILL.md +0 -207
  202. package/skills/external-diagram-visual-generate/assets/architecture/integration-flow.md +0 -55
  203. package/skills/external-diagram-visual-generate/assets/erd/core-objects.md +0 -131
  204. package/skills/external-diagram-visual-generate/assets/erd/custom-objects.md +0 -60
  205. package/skills/external-diagram-visual-generate/assets/lwc/dashboard-card.md +0 -45
  206. package/skills/external-diagram-visual-generate/assets/lwc/data-table.md +0 -57
  207. package/skills/external-diagram-visual-generate/assets/lwc/record-form.md +0 -60
  208. package/skills/external-diagram-visual-generate/assets/review/apex-review.md +0 -57
  209. package/skills/external-diagram-visual-generate/assets/review/lwc-review.md +0 -48
  210. package/skills/external-diagram-visual-generate/references/architect-aesthetic-guide.md +0 -257
  211. package/skills/external-diagram-visual-generate/references/examples-index.md +0 -35
  212. package/skills/external-diagram-visual-generate/references/gemini-cli-setup.md +0 -65
  213. package/skills/external-diagram-visual-generate/references/interview-questions.md +0 -529
  214. package/skills/external-diagram-visual-generate/references/iteration-workflow.md +0 -173
  215. package/skills/external-diagram-visual-generate/scripts/check-prerequisites.sh +0 -101
  216. package/skills/external-diagram-visual-generate/scripts/generate_image.py +0 -243
  217. package/skills/integration-connectivity-connected-app-configure/CREDITS.md +0 -3
  218. package/skills/integration-connectivity-generate/CREDITS.md +0 -5
  219. package/skills/omnistudio-callable-apex-generate/CREDITS.md +0 -9
  220. package/skills/omnistudio-datamapper-generate/CREDITS.md +0 -5
  221. package/skills/omnistudio-datapacks-deploy/CREDITS.md +0 -5
  222. package/skills/omnistudio-dependencies-analyze/CREDITS.md +0 -5
  223. package/skills/omnistudio-epc-catalog-generate/CREDITS.md +0 -14
  224. package/skills/omnistudio-flexcard-generate/CREDITS.md +0 -5
  225. package/skills/omnistudio-integration-procedure-generate/CREDITS.md +0 -5
  226. package/skills/omnistudio-omniscript-generate/CREDITS.md +0 -5
  227. package/skills/platform-apex-generate/CREDITS.md +0 -5
  228. package/skills/platform-apex-logs-debug/CREDITS.md +0 -22
  229. package/skills/platform-apex-test-generate/CREDITS.md +0 -5
  230. package/skills/platform-apex-test-run/CREDITS.md +0 -22
  231. package/skills/platform-data-manage/CREDITS.md +0 -5
  232. package/skills/platform-metadata-deploy/CREDITS.md +0 -25
  233. package/skills/platform-soql-query/CREDITS.md +0 -21
  234. /package/skills/omnistudio-callable-apex-generate/examples/Test_VlocityOpenInterfaceConversion/{MyCustomVlocityOpenInterface2.cls → MyCustomClass.cls} +0 -0
@@ -1,8 +1,12 @@
1
1
  ---
2
2
  name: platform-flexipage-generate
3
- description: "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."
3
+ description: "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. DO NOT TRIGGER when users ask about Visualforce pages, Aura components without FlexiPage context, page layout assignments in the UI, or Lightning Web Component development that does not involve placing components on a FlexiPage."
4
+ allowed-tools: Bash Read Write
4
5
  metadata:
5
- version: "1.0"
6
+ version: "1.1"
7
+ cliTools:
8
+ - tool: ["sf"]
9
+ semver: ">=2.126.4"
6
10
  ---
7
11
 
8
12
  ## When to Use This Skill
@@ -18,8 +22,6 @@ Use this skill when you need to:
18
22
 
19
23
  ## Specification
20
24
 
21
- # FlexiPage Generation Guide
22
-
23
25
  ## Overview
24
26
 
25
27
  **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.
@@ -34,6 +36,8 @@ Generate Lightning pages (RecordPage, AppPage, HomePage) using CLI bootstrapping
34
36
 
35
37
  **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.
36
38
 
39
+ **`<packageDirectory>`** = the `path` value from `sfdx-project.json` → `packageDirectories[0]` (e.g., `force-app`). Read it from the project file before running commands.
40
+
37
41
  ```bash
38
42
  sf template generate flexipage \
39
43
  --name <PageName> \
@@ -42,7 +46,7 @@ sf template generate flexipage \
42
46
  --primary-field <Field1> \
43
47
  --secondary-fields <Field2,Field3> \
44
48
  --detail-fields <Field4,Field5,Field6,Field7> \
45
- --output-dir force-app/main/default/flexipages
49
+ --output-dir <packageDirectory>/main/default/flexipages
46
50
  ```
47
51
 
48
52
  **CRITICAL:** If the `sf template generate flexipage` command fails, **STOP**.
@@ -84,439 +88,370 @@ Do NOT continue to Step 2 until the template command succeeds. The generated XML
84
88
 
85
89
  ### Step 2: Deploy Base Page
86
90
 
87
- Run a **dry-run** deployment of the entire project to validate the page and dependencies:
91
+ Run a **dry-run** deployment to validate the page and dependencies (use the default package directory from `sfdx-project.json`):
88
92
  ```bash
89
- sf project deploy start --dry-run -d "force-app/main/default" --test-level NoTestRun --wait 10 --json
93
+ sf project deploy start --dry-run -d "<packageDirectory>/main/default" --test-level NoTestRun --wait 10 --json
90
94
  ```
91
95
 
92
96
  **Critical:** Fix any deployment errors before proceeding. The page must validate successfully.
93
97
 
94
- ### Step 3: **STOP - No Further Modifications**
98
+ ### Step 3: Add Components Dynamically (if requested)
95
99
 
96
- **MANDATORY: Stop after Step 2. Do not add components or edit the FlexiPage XML.**
100
+ 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.
97
101
 
98
- This applies even if the user requested:
99
- - Additional components
100
- - Page customization
101
- - Component configuration
102
+ ---
102
103
 
103
- What you CAN do:
104
- - Suggest what components would be useful
105
- - Explain what enhancements are possible
106
- - Document what would need to be added manually
104
+ ## Critical XML Rules
107
105
 
108
- What you CANNOT do:
109
- - Modify the XML file
110
- - Add any components
111
- - Make any enhancements
106
+ **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.
107
+
108
+ **Key rules (quick reminder):**
109
+ - Encode HTML in `<value>` tags: `&` first, then `<`, `>`, `"`, `'`
110
+ - Field references: `Record.{FieldApiName}` (never `Object.Field`)
111
+ - Every `<identifier>` and region `<name>` must be unique across the file
112
+ - Multiple components in same facet → combine in ONE region with multiple `<itemInstances>`
112
113
 
113
114
  ---
114
115
 
115
- ## Critical XML Rules
116
+ ### Identifiers, Regions, and Containers
116
117
 
117
- ### 1. Property Value Encoding (MOST COMMON ERROR)
118
+ **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.
118
119
 
119
- **Any property value with HTML/XML characters MUST be manually encoded in the following order** (wrong order causes double-encoding corruption):
120
+ ---
120
121
 
121
- ```
122
- 1. & → &amp; (FIRST! Encode this before others)
123
- 2. < → &lt;
124
- 3. > → &gt;
125
- 4. " → &quot;
126
- 5. ' → &apos;
127
- ```
122
+ ## Component-Specific Tips
128
123
 
129
- **Wrong:**
130
- ```xml
131
- <value><b>Important</b> text</value>
132
- ```
124
+ ### dynamicHighlights (RecordPage Header)
125
+ **Location:** `header` region only. See `references/record_flexipage_dynamicHighlights.md` for full structure.
126
+ CLI generates Facets automatically from `--primary-field` and `--secondary-fields`.
127
+
128
+ ### fieldSection
129
+ **Use for:** Displaying fields in columns. Three-level nesting: Region → Column Facets → Field Facets.
130
+ See `references/flexipage_fieldSection.md` for full structure and XML example.
131
+ **Critical:** The `columns` property value is a Facet name, not a number.
132
+
133
+ ### richText
134
+ See `references/flexipage_richText.md` for encoding rules and XML structure.
135
+ Identifier: `flexipage_richText` or `flexipage_richText_{N}`
136
+
137
+ ---
138
+ ## Required Metadata Structure
133
139
 
134
- **Correct:**
135
140
  ```xml
136
- <value>&lt;b&gt;Important&lt;/b&gt; text</value>
141
+ <FlexiPage xmlns="http://soap.sforce.com/2006/04/metadata">
142
+ <flexiPageRegions>
143
+ <!-- Regions and components here -->
144
+ </flexiPageRegions>
145
+ <masterLabel>Page Label</masterLabel>
146
+ <template>
147
+ <name>flexipage:recordHomeTemplateDesktop</name>
148
+ </template>
149
+ <type>RecordPage</type>
150
+ <sobjectType>Object__c</sobjectType> <!-- RecordPage only -->
151
+ </FlexiPage>
137
152
  ```
138
153
 
139
- **Check your XML:** Search for `<value>` tags - they should never contain raw `<` or `>` characters.
154
+ **Page Types:**
155
+ - `RecordPage` - requires `<sobjectType>`
156
+ - `AppPage` - no sobjectType
157
+ - `HomePage` - no sobjectType
140
158
 
141
- ### 2. Field References
159
+ ---
142
160
 
143
- **ALWAYS:** `Record.{FieldApiName}`
144
- **NEVER:** `{ObjectName}.{FieldApiName}`
161
+ ## Validation Checklist
145
162
 
146
- ```xml
147
- <!-- Correct -->
148
- <fieldItem>Record.Name</fieldItem>
163
+ ### Structure (new pages)
164
+ - [ ] Used CLI to bootstrap — never create FlexiPage XML from scratch
149
165
 
150
- <!-- Wrong -->
151
- <fieldItem>Account.Name</fieldItem>
152
- ```
166
+ ### Identifiers & Regions
167
+ - [ ] All `<identifier>` values unique across entire file
168
+ - [ ] All region/facet `<name>` values unique across entire file
169
+ - [ ] Multiple components in same facet combined in ONE region with multiple `<itemInstances>`
153
170
 
154
- ### 3. Region vs Facet Types
171
+ ### Field Instances
172
+ - [ ] All field references use `Record.{Field}` format
173
+ - [ ] Each fieldInstance has `fieldInstanceProperties` with `uiBehavior`
174
+ - [ ] Each fieldInstance in its own `<itemInstances>` wrapper
155
175
 
156
- **Template Regions** (header, main, sidebar):
157
- ```xml
158
- <name>header</name>
159
- <type>Region</type>
160
- ```
176
+ ### Types & Encoding
177
+ - [ ] Template regions use `<type>Region</type>`; component facets use `<type>Facet</type>`
178
+ - [ ] Property values with HTML/XML are entity-encoded
179
+ - [ ] No unnecessary `<mode>` tags (only where component patterns require them)
180
+ - [ ] No `__c` suffix in page names
181
+ - [ ] Each Facet referenced by exactly one component property
161
182
 
162
- **Component Facets** (internal slots like fieldSection columns):
163
- ```xml
164
- <name>Facet-12345</name>
165
- <type>Facet</type>
166
- ```
183
+ ---
167
184
 
168
- **Rule:** If it's a template region name → `Region`. If it's a component slot → `Facet`.
185
+ ## Quick Reference: CLI Command
169
186
 
170
- ### 4. fieldInstance Structure
187
+ **Read `references/cli_commands.md`** for full CLI examples (RecordPage, AppPage, HomePage) and available options.
171
188
 
172
- Every fieldInstance requires:
173
- ```xml
174
- <itemInstances>
175
- <fieldInstance>
176
- <fieldInstanceProperties>
177
- <name>uiBehavior</name>
178
- <value>none</value> <!-- none|readonly|required -->
179
- </fieldInstanceProperties>
180
- <fieldItem>Record.FieldName__c</fieldItem>
181
- <identifier>RecordFieldName_cField</identifier>
182
- </fieldInstance>
183
- </itemInstances>
184
- ```
189
+ ---
185
190
 
186
- **Rules:**
187
- - Each fieldInstance in its own `<itemInstances>` wrapper
188
- - Must have `fieldInstanceProperties` with `uiBehavior`
189
- - Use `Record.{Field}` format
191
+ ## Adding Components Dynamically
190
192
 
191
- ### 5. Unique Identifiers and Region Names (CRITICAL - PREVENTS DUPLICATE ERRORS)
193
+ > **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.
192
194
 
193
- **EVERY identifier and region/facet name MUST be unique across the entire FlexiPage file.**
195
+ ### Overview
194
196
 
195
- **Critical Rules:**
196
- - ❌ **NEVER create two `<flexiPageRegions>` blocks with the same `<name>`**
197
- - ✅ **If multiple components belong to same facet, combine them in ONE region with multiple `<itemInstances>`**
198
- - ❌ **NEVER reuse the same `<identifier>` value**
199
- - ✅ **Always read entire file first and extract ALL existing identifiers and names**
197
+ When the user requests components (e.g., "add a related list of contacts and a report"), follow this pipeline:
200
198
 
201
- **Wrong - This WILL FAIL with duplicate name error:**
202
- ```xml
203
- <!-- First field section in detail tab -->
204
- <flexiPageRegions>
205
- <itemInstances>
206
- <componentInstance>
207
- <identifier>flexipage_property_details_fieldSection</identifier>
208
- ...
209
- </componentInstance>
210
- </itemInstances>
211
- <name>detailTabContent</name> <!-- ❌ DUPLICATE NAME -->
212
- <type>Facet</type>
213
- </flexiPageRegions>
214
-
215
- <!-- Second field section in detail tab -->
216
- <flexiPageRegions>
217
- <itemInstances>
218
- <componentInstance>
219
- <identifier>flexipage_pricing_fieldSection</identifier>
220
- ...
221
- </componentInstance>
222
- </itemInstances>
223
- <name>detailTabContent</name> <!-- ❌ DUPLICATE NAME - DEPLOYMENT FAILS -->
224
- <type>Facet</type>
225
- </flexiPageRegions>
199
+ ```text
200
+ 1. Parse Intent → identify ALL requested components
201
+ 2. Discover ALL batch components through 3-tier discovery
202
+ 3. Infer Properties → run 3-step inference for EACH discovered component
203
+ 4. Generate XML → produce valid XML for all components together
204
+ 5. Validate → check identifiers, regions, property completeness
226
205
  ```
227
206
 
228
- **Correct - Combine itemInstances in ONE region:**
229
- ```xml
230
- <!-- Both field sections in same detail tab facet -->
231
- <flexiPageRegions>
232
- <itemInstances>
233
- <componentInstance>
234
- <identifier>flexipage_property_details_fieldSection</identifier>
235
- ...
236
- </componentInstance>
237
- </itemInstances>
238
- <itemInstances>
239
- <componentInstance>
240
- <identifier>flexipage_pricing_fieldSection</identifier>
241
- ...
242
- </componentInstance>
243
- </itemInstances>
244
- <name>detailTabContent</name> <!-- ✅ ONE REGION, MULTIPLE COMPONENTS -->
245
- <type>Facet</type>
246
- </flexiPageRegions>
247
- ```
207
+ **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.
248
208
 
249
- **When to combine vs separate:**
250
- - **Combine**: Components that logically belong to same tab/section (e.g., multiple field sections in detail tab)
251
- - **Separate**: Components that belong to different tabs/sections (e.g., `detailTabContent` vs `relatedTabContent`)
209
+ ### Step 1: Parse User Intent
252
210
 
253
- ---
211
+ Extract every component request from the user's utterance. Examples:
212
+ - "Create Account page with a report and related contacts" → 2 components: report, related list
213
+ - "Add activities, chatter, and a DRL of Cases" → 3 components: activities, chatter, dynamic related list
254
214
 
255
- ## Common Deployment Errors
215
+ ### Step 2: 3-Tier Component Discovery
256
216
 
257
- ### "We couldn't retrieve or load the information on the field"
258
- **Cause:** Invalid field API name - field doesn't exist on the object or has incorrect spelling
259
- **Fix:** Use MCP tools or describe commands to discover valid fields, then update the field reference (see Field Selection Rules)
217
+ Complete each tier for ALL components before moving to the next tier — do NOT run Tier 1→2→3 per component:
260
218
 
261
- ### "Invalid field reference"
262
- **Cause:** Used `ObjectName.Field` instead of `Record.Field`
263
- **Fix:** Change to `Record.{FieldApiName}`
219
+ | Tier | Source | When | Calls |
220
+ |------|--------|------|-------|
221
+ | **1** | Local workspace scan | Always first — run for ALL components | 0 (local only) |
222
+ | **2** | `discoverUiComponents` MCP action | Single call for all components unresolved after Tier 1 | 1 |
223
+ | **3** | Generate new LWC bundle | Only for components still unresolved after Tier 2 + user confirms | 0 |
264
224
 
265
- ### "Element fieldInstance is duplicated"
266
- **Cause:** Multiple fieldInstances in one itemInstances
267
- **Fix:** Each fieldInstance needs its own `<itemInstances>` wrapper
225
+ 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.
268
226
 
269
- ### "Missing fieldInstanceProperties"
270
- **Cause:** No uiBehavior specified
271
- **Fix:** Add `fieldInstanceProperties` with `uiBehavior`
227
+ See **Local Workspace Scanner** and **MCP Action Integration** sections below for details.
272
228
 
273
- ### "Unused Facet"
274
- **Cause:** Facet defined but not referenced by any component
275
- **Fix:** Remove Facet or reference it in a component property
229
+ ### Step 3: Property Inference (per component)
276
230
 
277
- ### "XML parsing error"
278
- **Cause:** Unencoded HTML/XML in property values
279
- **Fix:** Manually encode `<`, `>`, `&`, `"`, `'` in all `<value>` tags
231
+ For EACH discovered component, infer properties using the 3-step strategy:
280
232
 
281
- ### "Cannot create component with namespace"
282
- **Cause:** Invalid page name (don't use `__c` suffix in page names)
283
- **Fix:** Use "Volunteer_Record_Page" not "Volunteer__c_Record_Page"
233
+ 1. **Fetch schema or read source** — For Tier 2 (org) components, call `getUiComponentSchemas`; for Tier 1 (local), extract `@api` props from source
234
+ 2. **Apply component instructions** If `references/<name>.md` exists, read and follow its inference rules
235
+ 3. **Resolve remaining** Smart defaults → LLM inference → user prompts (last resort)
284
236
 
285
- ### "Region specifies mode that parent doesn't support"
286
- **Cause:** Added `<mode>` tag to region
287
- **Fix:** Remove `<mode>` tags - they're not needed for standard regions
237
+ See **Hybrid Property Inference Strategy** below for full details.
288
238
 
289
- ---
239
+ ### Step 4: Generate XML
240
+
241
+ What you CANNOT do:
242
+ - Modify top level structure in the XML file
243
+ - Add any components from memory which is not resolved from 3-Tier Component Discovery
244
+ - Make any enhancements
290
245
 
291
- ### Generating Unique Identifiers
246
+ **Read `references/xml_rules.md` before writing any XML.** Follow all element naming and structure rules defined there.
292
247
 
293
- **CRITICAL: Before generating ANY new identifier or facet name, follow the rules in section 5 of "Critical XML Rules" above.**
248
+ Produce `<itemInstances>` XML for all resolved components:
249
+ - Use `<componentInstanceProperties>` for every property (NOT `<properties>`)
250
+ - Assign unique identifiers across the full set (see references/identifiers_and_regions.md)
251
+ - Insert into appropriate regions (header, main, sidebar, or facets)
252
+ - Follow each component's XML structure from its instructions file or schema
294
253
 
295
- **Identifier Generation Algorithm**:
296
- ```
297
- 1. Extract ALL existing <identifier> AND <name> values from XML
298
- 2. Generate base name: {componentType}_{context}
299
- Examples: "relatedList_contacts", "richText_header", "tabs_main"
300
- 3. Find first available number:
301
- - Try "{base}_1"
302
- - If exists, try "{base}_2", "{base}_3", etc.
303
- - Use first available
254
+ ### Step 5: Validate
255
+
256
+ Check the complete FlexiPage for:
257
+ - Identifier uniqueness (no duplicates across entire file)
258
+ - Region validity (components in correct regions)
259
+ - Property completeness (all required properties populated)
260
+ - XML encoding (HTML values entity-encoded)
261
+ - Element name correctness (see references/xml_rules.md §6)
262
+
263
+ Deploy with dry-run (use default package directory from `sfdx-project.json`):
264
+ ```bash
265
+ sf project deploy start --dry-run -d "<packageDirectory>/main/default" --test-level NoTestRun --wait 10 --json
304
266
  ```
305
267
 
306
- **Examples**:
307
- - First contacts related list: `relatedList_contacts_1`
308
- - Second contacts related list: `relatedList_contacts_2`
309
- - Rich text in header: `richText_header_1`
310
- - Field section: `fieldSection_details_1`
268
+ ---
269
+
270
+ ## MCP Action Integration
311
271
 
312
- **Facet Naming - Two Patterns**:
272
+ **Read `references/mcp_action_examples.md`** for full input/output examples and parameter tables.
313
273
 
314
- 1. **Named facets** (for major content areas):
315
- - `detailTabContent` (detail tab content)
316
- - `maintabs` (main tab container)
317
- - `sidebartabs` (sidebar tab container)
318
- - Use when facet represents meaningful content area
274
+ Two MCP actions via `execute_metadata_action`:
319
275
 
320
- 2. **UUID facets** (for internal structure):
321
- - Format: `Facet-{8hex}-{4hex}-{4hex}-{4hex}-{12hex}`
322
- - Example: `Facet-66d5a4b3-bf14-4665-ba75-1ceaa71b2cde`
323
- - Use for field section columns, nested containers, anonymous slots
276
+ | Action | Purpose | When |
277
+ |--------|---------|------|
278
+ | `DISCOVER_UI_COMPONENTS` | Find components for a page type | Tier 2 discovery — single call for all unresolved components |
279
+ | `GET_UI_COMPONENT_SCHEMAS` | Get property schemas | Property inference Step 1 (Tier 2 org components only) |
324
280
 
325
- **When adding components to existing files:**
326
- - Check if target facet name already exists
327
- - If exists: Add new `<itemInstances>` to that existing region (see section 5 above for details)
328
- - If doesn't exist: Create new region with unique name
281
+ **Key conventions:**
282
+ - Component definition format: `namespace/blockName` (forward-slash) in MCP calls, `namespace:blockName` (colon) in XML
283
+ - `pageContext` with `entityName` is required for RECORD_PAGE
284
+ - `getUiComponentSchemas` supports partial failures check each component's `success` boolean
329
285
 
330
286
  ---
331
287
 
332
- ### Region Selection
288
+ ## Local Workspace Scanner
333
289
 
334
- **Parse regions from file** - don't hardcode names. Templates vary:
335
- - `flexipage:recordHomeTemplateDesktop` → `header`, `main`, `sidebar`
336
- - `runtime_service_fieldservice:...` → `header`, `main`, `footer`
337
- - Others may have different region names
290
+ Scans the local SFDX project for custom LWC components before making any MCP calls (Tier 1 discovery).
338
291
 
339
- **Default placement**: End of target region (after last `<itemInstances>`)
292
+ ### Algorithm
340
293
 
341
- **Insertion pattern**:
342
- ```xml
343
- <flexiPageRegions>
344
- <name>main</name> <!-- or whatever region name exists -->
345
- <type>Region</type>
346
- <itemInstances><!-- Existing component 1 --></itemInstances>
347
- <itemInstances><!-- Existing component 2 --></itemInstances>
348
- <itemInstances>
349
- <!-- INSERT NEW COMPONENT HERE -->
350
- </itemInstances>
351
- </flexiPageRegions>
294
+ Run the scanner for each component query (local scan — no network calls):
295
+
296
+ ```bash
297
+ scripts/scan-lwc-components.sh "<query>" [packageDirectory]
352
298
  ```
353
299
 
354
- ---
300
+ 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:
355
301
 
356
- ### Container Components with Facets
302
+ - **High confidence (≥70%):** auto-select, confirm with user
303
+ - **Medium confidence (40-69%):** present ranked list for user selection
304
+ - **Low confidence (<40%):** skip, proceed to Tier 2
357
305
 
358
- Components like tabs, accordions, field sections require facets.
306
+ 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.
359
307
 
360
- **Pattern**:
361
- ```xml
362
- <!-- 1. Component in region -->
363
- <flexiPageRegions>
364
- <itemInstances>
365
- <componentInstance>
366
- <componentName>flexipage:tabset2</componentName>
367
- <identifier>tabs_main_1</identifier>
368
- <componentInstanceProperties>
369
- <name>tabs</name>
370
- <value>tab1_content</value>
371
- <value>tab2_content</value>
372
- </componentInstanceProperties>
373
- </componentInstance>
374
- </itemInstances>
375
- <name>main</name>
376
- <type>Region</type>
377
- </flexiPageRegions>
378
-
379
- <!-- 2. Facets (siblings of region, NOT nested inside) -->
380
- <flexiPageRegions>
381
- <itemInstances><!-- Tab 1 content --></itemInstances>
382
- <name>tab1_content</name>
383
- <type>Facet</type>
384
- </flexiPageRegions>
385
-
386
- <flexiPageRegions>
387
- <itemInstances><!-- Tab 2 content --></itemInstances>
388
- <name>tab2_content</name>
389
- <type>Facet</type>
390
- </flexiPageRegions>
391
- ```
308
+ ### Disambiguation
309
+
310
+ For medium-confidence matches (40-69%) or multiple high-confidence matches:
311
+ 1. Read each candidate's `.js-meta.xml` for `<description>` and `<targetConfigs>`
312
+ 2. Present ranked list to user with component name + description
313
+ 3. User selects or says "none of these" (→ proceed to Tier 2)
314
+
315
+ ### When to Skip
316
+
317
+ Skip local scan when:
318
+ - User explicitly mentions an org-level component ("use the standard report component")
319
+ - User intent clearly maps to a known standard component (DRL, richText, etc.)
320
+ - No `<packageDirectory>` directory exists in the workspace
392
321
 
393
- **Critical**: Facet regions are siblings of template regions at the same level, not nested inside them.
394
322
  ---
395
- ## Component-Specific Tips
396
- ### dynamicHighlights (RecordPage Header)
397
- **Location:** Must be in `header` region.
398
- **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.
399
- ```bash
400
- --primary-field Name
401
- --secondary-fields Phone,Industry,AnnualRevenue
402
- ```
403
- CLI generates Facets with field references automatically.
404
- ### fieldSection
405
- **Use for:** Displaying fields in columns.
406
- **Structure:** Three-level nesting:
407
- 1. Template Region (Region type)
408
- 2. Column Facets (Facet type)
409
- 3. Field Facets (Facet type)
410
- **Referenced in component property:**
411
- ```xml
412
- <componentInstanceProperties>
413
- <name>columns</name>
414
- <value>Facet-{uuid}</value>
415
- </componentInstanceProperties>
416
- ```
417
323
 
418
- ### rich Text component
324
+ ## Hybrid Property Inference Strategy
419
325
 
420
- Component name: flexipage:richText
326
+ For EACH discovered component, populate its properties using this 3-step strategy in order:
421
327
 
422
- 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.
328
+ ### Step 1: Fetch Latest Schema (conditional)
423
329
 
424
- Location: Can be used in any region on any page type (Home, Record, App, Community pages).
330
+ 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.
425
331
 
332
+ **When to call:**
333
+ - Tier 2 (org discovery): Always — the schema is the only source of property info
334
+ - Tier 1 (local): Skip — read `@api` properties from the component's `.js` source file
335
+ - Tier 3 (generated): Skip — you just created the source, so properties are already known
426
336
 
427
- CLI generates the component directly without nested structures.
337
+ ### Step 2: Apply Component Instructions (if present)
428
338
 
429
- User: "Add a rich text component to force-app/.../Account_Record_Page.flexipage-meta.xml"
339
+ Run `scripts/resolve-component-instructions.sh <namespace:component>` it returns the instructions file path if it exists, or empty string.
430
340
 
431
- Structure: Single-level component (no facets):
432
- 1. Component instance (flexipage:richText) with direct properties
341
+ Examples:
342
+ - `record_flexipage:dynamicHighlights` `references/record_flexipage_dynamicHighlights.md`
343
+ - `flexipage:fieldSection` → `references/flexipage_fieldSection.md`
344
+ - `c:expenseTracker` → (empty — no file)
433
345
 
434
- XML Structure Example:
435
- ```xml
436
- <itemInstances>
437
- <componentInstance>
438
- <componentInstanceProperties>
439
- <name>decorate</name>
440
- <value>true</value>
441
- </componentInstanceProperties>
442
- <componentName>flexipage:richText</componentName>
443
- <identifier>flexipage_richText</identifier>
444
- </componentInstance>
445
- </itemInstances>
446
- ```
346
+ If a file is returned: read and follow its inference rules, XML patterns, and defaults.
347
+ If empty: skip directly to Step 3.
348
+
349
+ 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.
350
+
351
+ ### Step 3: Resolve Remaining Properties
352
+
353
+ For any properties not yet resolved, apply in this priority order:
354
+
355
+ **3a. Smart Default Heuristics:**
356
+
357
+ | Property Pattern | Default Value |
358
+ |-----------------|---------------|
359
+ | `recordId` | `{!recordId}` |
360
+ | `objectApiName` / `sObjectName` | Page's `<sobjectType>` value |
361
+ | `show*` / `visible*` / `display*` | `true` |
362
+ | `hide*` / `hidden*` / `disabled*` | `false` |
363
+ | Boolean without prefix | `false` |
364
+ | Schema specifies `"default"` | Use schema default |
365
+
366
+ **3b. LLM Inference:**
367
+ 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.
368
+
369
+ **3c. User Prompts (last resort):**
370
+ Only prompt the user for critical required properties that cannot be inferred. If user says "skip", omit the component entirely.
371
+
372
+ ### Tier-Specific Behavior
447
373
 
448
- Identifier Pattern: flexipage_richText or flexipage_richText_{sequence}
374
+ | Tier | Extra Step | Schema Call | Instructions |
375
+ |------|-----------|-------------|--------------|
376
+ | Tier 1 (local) | Extract `@api` props from source | No (use source) | If exists |
377
+ | Tier 2 (org) | — | Yes | If exists |
378
+ | Tier 3 (generated) | Extract `@api` from just-generated source | No (just created) | No |
449
379
 
450
380
  ---
451
- ## Required Metadata Structure
452
381
 
453
- ```xml
454
- <FlexiPage xmlns="http://soap.sforce.com/2006/04/metadata">
455
- <flexiPageRegions>
456
- <!-- Regions and components here -->
457
- </flexiPageRegions>
458
- <masterLabel>Page Label</masterLabel>
459
- <template>
460
- <name>flexipage:recordHomeTemplateDesktop</name>
461
- </template>
462
- <type>RecordPage</type>
463
- <sobjectType>Object__c</sobjectType> <!-- RecordPage only -->
464
- </FlexiPage>
465
- ```
382
+ ## New LWC Generation (Tier 3)
466
383
 
467
- **Page Types:**
468
- - `RecordPage` - requires `<sobjectType>`
469
- - `AppPage` - no sobjectType
470
- - `HomePage` - no sobjectType
384
+ When no component is found locally (Tier 1) or in the org (Tier 2), offer to generate a new LWC.
385
+
386
+ ### Trigger Conditions
387
+
388
+ - Tier 1 and Tier 2 both miss or user rejected all candidates
389
+ - User has not explicitly said "skip" or "don't create"
390
+
391
+ ### Confirmation
392
+
393
+ Always confirm before creating. Explain: component name. If user declines: skip, continue with other components.
394
+
395
+ ### Post-Generation
396
+
397
+ After creating the LWC bundle:
398
+ 1. Treat as a Tier 1 local component immediately
399
+ 2. Extract `@api` properties from the generated source
400
+ 3. Apply smart defaults for `recordId` and `objectApiName`
401
+ 4. Generate FlexiPage XML with `c:{componentName}` as the componentName
402
+
403
+ ### Naming Convention
404
+
405
+ - Derive from user intent: "customer health score" → `customerHealthScore`
406
+ - camelCase, no hyphens, no underscores in the JS class name
407
+ - Folder name matches class name (lowercase first letter): `customerHealthScore/`
471
408
 
472
409
  ---
473
410
 
474
- ## Validation Checklist
411
+ ## Reference File Index
475
412
 
476
- Before deploying:
477
- - [ ] **[NEW PAGES ONLY]** Used CLI to bootstrap - NEVER create FlexiPage XML from scratch
478
- - [ ] **ALL identifiers are unique** - no duplicate `<identifier>` values anywhere in file
479
- - [ ] **ALL region/facet names are unique** - no duplicate `<name>` values in `<flexiPageRegions>`
480
- - [ ] **Multiple components in same facet are combined** - ONE region with multiple `<itemInstances>`, NOT separate regions with same name
481
- - [ ] All field references use `Record.{Field}` format
482
- - [ ] Each fieldInstance has `fieldInstanceProperties` with `uiBehavior`
483
- - [ ] Each fieldInstance in own `<itemInstances>` wrapper
484
- - [ ] Template regions use `<type>Region</type>`
485
- - [ ] Component facets use `<type>Facet</type>`
486
- - [ ] Property values with HTML/XML are manually encoded
487
- - [ ] No `<mode>` tags in regions
488
- - [ ] No `__c` suffix in page names
489
- - [ ] Each Facet referenced by exactly one component property
413
+ | File | When to read |
414
+ |------|-------------|
415
+ | `references/xml_rules.md` | Before writing or editing any FlexiPage XML encoding, field refs, identifiers, deployment errors |
416
+ | `references/identifiers_and_regions.md` | When adding components identifier algorithm, facet naming, region selection, container pattern |
417
+ | `references/cli_commands.md` | When bootstrapping new pages full CLI examples for RecordPage, AppPage, HomePage |
418
+ | `references/mcp_action_examples.md` | When calling MCP actions full input/output JSON for discoverUiComponents and getUiComponentSchemas |
419
+ | `references/flexipage_fieldSection.md` | When adding a Field Section with columns |
420
+ | `references/record_flexipage_dynamicHighlights.md` | When adding a Dynamic Highlights panel |
421
+ | `references/flexipage_richText.md` | When adding a Rich Text component |
422
+ | `scripts/scan-lwc-components.sh` | Tier 1 local workspace scan — tokenizes and scores LWC component names against user query |
423
+ | `scripts/resolve-component-instructions.sh` | Property inference Step 2 resolves component definition to instructions file path |
424
+
425
+ **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.
490
426
 
491
427
  ---
492
428
 
493
- ## Quick Reference: CLI Command
429
+ ## Validation Rules for Dynamic Components
494
430
 
495
- ```bash
496
- # RecordPage with fields
497
- sf template generate flexipage \
498
- --name Account_Custom_Page \
499
- --template RecordPage \
500
- --sobject Account \
501
- --primary-field Name \
502
- --secondary-fields Phone,Industry,AnnualRevenue \
503
- --detail-fields Street,City,State,Name,Phone,Email
504
-
505
- # AppPage
506
- sf template generate flexipage \
507
- --name Sales_Dashboard \
508
- --template AppPage \
509
- --label "Sales Dashboard"
431
+ After generating XML for dynamically added components, verify ALL of the following before deployment:
510
432
 
511
- # HomePage
512
- sf template generate flexipage \
513
- --name Custom_Home \
514
- --template HomePage \
515
- --description "Custom home for sales team"
516
- ```
433
+ ### Identifier Uniqueness
434
+ - Extract ALL `<identifier>` values from the entire FlexiPage file
435
+ - Confirm zero duplicates
436
+ - If conflict: auto-increment suffix (`_2`, `_3`, etc.)
437
+
438
+ ### Region Validity
439
+ - Components placed in correct regions for their type:
440
+ - `record_flexipage:dynamicHighlights` → `header` only
441
+ - `flexipage:fieldSection` → `main` or tab facets
442
+ - `flexipage:richText` → any region
443
+
444
+ ### Property Completeness
445
+ - All properties marked required in schema have values
446
+ - All values match expected types (String, Boolean, valueList, Integer)
447
+ - No raw HTML in `<value>` tags (must be entity-encoded)
448
+
449
+ ### Structural Integrity
450
+ - Every Facet referenced by a component property exists as a `<flexiPageRegions>` block
451
+ - No orphan Facets (every Facet is referenced by exactly one component)
452
+ - Multiple components in same region use ONE `<flexiPageRegions>` block with multiple `<itemInstances>`
517
453
 
518
- **All templates support:**
519
- - `--output-dir` (default: current directory)
520
- - `--api-version` (default: latest)
521
- - `--label` (default: page name)
522
- - `--description`
454
+ ### Cross-Component Consistency
455
+ - For multi-component additions: identifiers are unique across ALL new components
456
+ - Facet UUIDs don't collide between components
457
+ - Components that require singleton placement (dynamicHighlights, recordDetailPanelMobile) are not duplicated