- Add hard gate at top of Generation Workflow to redirect widget requests to widget-rendition.md before any planning - Reorder step 4 so widget pattern appears before custom LWC pattern, with explicit decision gate - Clarify custom LWC pattern is only for non-widget use cases - Add checklist item asserting widget renderer must use tile/mosaic UEM tree not a custom LWC - Add forEach/forItem and conditional rendering sections with examples to widget-rendition.md - Add step 5 decision logic: single-object schema skips root forEach; collection schema wraps repeating block - Fix conflicting forEach default assumption; defer root-level iteration decision to step 5 - Add container-vs-child forEach example to prevent misplacing meta directive on container block
20 KiB
| name | description | metadata | ||
|---|---|---|---|---|
| generating-custom-lightning-type | Use this skill when users need to create Custom Lightning Types (CLTs) for Einstein Agent actions or structured input/output schemas. Trigger when users mention CLT, Custom Lightning Types, custom lightning type with widget renderer, custom lightning type with widget, CLT with widget renderer, CLT with widget, JSON schemas for agents, type definitions, lightning__objectType, or editor/renderer configurations. When a widget renderer is requested, you MUST first read the widget-rendition.md reference file in this skill's references/ directory and follow its complete workflow. This is complex - always use this skill for CLT work. |
|
When to Use This Skill
Use this skill when you need to:
- Create Custom Lightning Types (CLTs) for structured inputs/outputs
- Generate JSON Schema-based type definitions for Lightning Platform
- Configure CLTs for Einstein Agent actions
- Set up editor and renderer configurations for custom UI
- Create CLTs with widget/mosaic/fragment rendition
- Troubleshoot deployment errors related to Custom Lightning Types
Specification
CustomLightningType Metadata Specification
Overview & Purpose
Custom Lightning Types (CLTs) are JSON Schema-based type definitions used by the Lightning Platform (including Einstein Agent actions) to describe structured inputs/outputs and drive editor/renderer experiences.
Configuration
- Choose referenced CLT pattern for nested objects - When you need a reusable or separately deployed nested type, create a CLT for that shape and reference it with
"lightning:type": "c__<CLTName>". That string is the referenced type’slightning:typevalue / FQN / registered identifier — not the JSON Schematitle. - Choose standard Lightning types when the structure is simple and can be expressed with properties and supported primitive
lightning:typeidentifiers. - Choose Apex class types (
@apexClassType/...) when the structure already exists server-side and you want the Apex class to define the shape. - Include editor/renderer config only when you need custom UI behavior (custom LWC input/output components). Otherwise, omit.
- Widget rendition: After
schema.jsonis drafted, you must read references/widget-rendition.md and follow the "Widget renderer pattern" section below for complete guidance. Do NOT attempt widget generation without reading the reference file first.
Critical Rules (Read First)
- Root object schemas MUST include:
"type": "object""title""lightning:type": "lightning__objectType""unevaluatedProperties": false
"unevaluatedProperties"is enforced asfalseby the CLT metaschema. Do not set it totrue.- Root object schemas MUST NOT include
"examples"when"unevaluatedProperties": falseis set. - Nested objects (inside
properties) MUST NOT set"lightning:type": "lightning__objectType".- Nested objects can be: references to other CLTs using
c__<CLTName>syntax.
- Nested objects can be: references to other CLTs using
- List/array properties are highly restricted by the CLT metaschema:
- CRITICAL LIMITATION: the CLT metaschema may reject the
itemskeyword entirely. Treatitemsas disallowed by default. - Root-level arrays (direct children of the root
properties):- MUST include
"lightning:type": "lightning__listType" - MUST NOT include
"items" - OPTIONAL
"type": "array"
- MUST include
- Nested arrays (arrays inside nested objects) are the most common failure:
- MUST include
"type": "array" - MUST NOT include
"lightning:type": "lightning__listType" - MUST NOT include
"items"
- MUST include
- CRITICAL LIMITATION: the CLT metaschema may reject the
- When
"unevaluatedProperties": falseis set, any unknown keyword will fail validation. Prefer removing keywords over relaxing strictness. - Apex class CLTs are minimal:
- Include only
title,description(optional), andlightning:typeset to@apexClassType/.... - Do not add
type,properties,required, orunevaluatedProperties.
- Include only
Additional CLT Metaschema Validations
- Org namespace validation: titles/descriptions and other string fields may be validated to ensure you are not using an org namespace in places that are disallowed.
- Lightning type validation: CLTs are validated to prevent referencing internal namespaces (for example, disallowing types from internal namespaces like
sfdc_cmswhere not permitted). - Object type validation: the CLT root is validated to ensure
lightning:typeis exactlylightning__objectType.
Primitive Types & Constraints
lightning__textType- Max length 255
lightning__multilineTextType- Max length 2000
lightning__richTextType- Max length 100000
lightning__urlType- Max length 2000
- Optional
lightning:allowedUrlSchemesenum values:https,http,relative,mailto,tel
lightning__dateType- Data pattern: YYYY-MM-DD
lightning__timeType- Data pattern: HH:MM:SS.sssZ
lightning__dateTimeType- Data shape is an object with required
dateTimeand optionaltimeZone
- Data shape is an object with required
lightning__numberType- Decimal numbers; optional
maximum,minimum,multipleOf
- Decimal numbers; optional
lightning__integerType- Whole numbers only; optional
maximum,minimum
- Whole numbers only; optional
lightning__booleanType- true/false
Allowed Property-Level Keywords
When strict validation is enabled (unevaluatedProperties: false), keep each property minimal and prefer only keywords known to be allowed:
title,description,einstein:descriptiontype(when used, ensure it matches the chosenlightning:type)lightning:typemaximum,minimum,multipleOf(numeric)maxLength,minLength(string)const,enumlightning:textIndexed,lightning:supportsPersonalization,lightning:localizablelightning:uiOptions,lightning:allowedUrlSchemeslightning:tags(metaschema restricts values; currentlyflowis the only known allowed tag)
Generation Workflow
⚠️ Widget renderer requested? STOP before step 1. If the user requested a "widget renderer", "mosaic", "widget", or "fragment": you MUST read
references/widget-rendition.mdNOW before doing anything else — before drafting schema, before creating any files, before planning steps. The API context examples showc/<componentName>renderers — those are the custom LWC pattern, NOT the widget pattern. Do not follow them for widget rendition.
- Confirm the CLT approach
- If referencing Apex: capture the exact class reference (
@apexClassType/namespace__ClassName$InnerClass). - If using standard primitives: list the fields, their Lightning primitive types, and which fields are required.
- If referencing Apex: capture the exact class reference (
- Draft
schema.json- Start with the root object structure (required root fields).
- Add
propertiesusing valid primitivelightning:typeidentifiers. - For nested-object properties, use CLT Reference pattern:
"lightning:type": "c__<CLTName>"to reference another CLT- The referenced CLT must be deployed to the org before the parent CLT.
- For Apex-based nested objects: Use
@apexClassType/...when structure exists server-side. - If the prompt explicitly requires true nested object output, prefer an Apex-based CLT (
@apexClassType/...) for deploy-safe nested structures. - For arrays: follow the strict list rules (avoid
items; avoidlightning:typeon nested arrays). - Before deployment, verify exact
lightning:typespellings (for example, uselightning__richTextType, not misspelled variants).
- (Optional) Draft
editor.json(only if custom UI is required)- Supported shape: Top-level
editorobject witheditor.componentOverridesandeditor.layout.- Top-level
editorobject. - Use
editor.componentOverridesfor component overrides. - Use
editor.layoutfor layout. - DEPRECATED: Do NOT use
propertyRenderersorview— these are legacy keys. Always usecomponentOverridesandlayoutinstead.
- Top-level
- Root override pattern (most common for fully custom editing UI):
editor.componentOverrides["$"] = { "definition": "c/<yourEditorComponent>", "attributes": { ... } }- When passing schema data into a custom LWC, use attribute mapping with the
{!$attrs.<name>}syntax: e.g."attributes": { "myField": "{!$attrs.value}" }so the runtime binds schema values to your component's attributes. - CRITICAL: The
<name>in{!$attrs.<name>}must be a property defined in your type schema. For example, if your schema has a property calledtemperature, use{!$attrs.temperature}, not{!$attrs.value}unlessvalueis an actual property.
- Property-level override pattern (for individual fields):
editor.componentOverrides["<propertyName>"] = { "definition": "es_property_editors/<...>" }- Valid editor components (examples):
es_property_editors/inputText,es_property_editors/inputNumber,es_property_editors/inputRichText,es_property_editors/inputImage,es_property_editors/inputTextarea. Do not usees_property_editors/inputList.
- Collection editor (for root-level
lightning__listTypeproperties): Use a collection-level override so the list is edited by a custom component:collection.editor.componentOverrides["$"] = { "definition": "c/<yourCollectionEditorComponent>" }. Alternatively, useeditor.layoutwithlightning/propertyLayoutandattributes.property = "<listPropertyName>"for default list editing. - Layout pattern:
editor.layout.definition = "lightning/verticalLayout"editor.layout.children[*].definition = "lightning/propertyLayout"withattributes.property = "<propertyName>"- CRITICAL:
lightning/propertyLayoutonly accepts thepropertyattribute. Do NOT addlabel,title, or any other attributes — these will fail validation withadditionalProperties: falseerrors.
- Avoid known-invalid patterns:
- Do not use
es_property_editors/inputList. - Do not use
itemSchemaattributes.
- Do not use
- Supported shape: Top-level
- (Optional) Draft
renderer.json(only if custom UI or mosaic rendition is required)- ⚠️ DECIDE FIRST — widget or custom LWC? Before writing any renderer code or planning any steps:
- If the user requested "widget", "mosaic", "fragment", or "cross-platform rendering": you MUST use the Widget renderer pattern below. Do NOT create a custom LWC. Do NOT use the root override pattern with
c/<componentName>. Skip directly to the Widget renderer pattern now. - Otherwise: use the root override pattern or property-level overrides described below.
- If the user requested "widget", "mosaic", "fragment", or "cross-platform rendering": you MUST use the Widget renderer pattern below. Do NOT create a custom LWC. Do NOT use the root override pattern with
- Supported shape: Top-level
rendererobject withrenderer.componentOverridesandrenderer.layout.- Top-level
rendererobject. - Use
renderer.componentOverridesfor component overrides. - Use
renderer.layoutfor layout. - DEPRECATED: Do NOT use
propertyRenderersorview— these are legacy keys. Always usecomponentOverridesandlayoutinstead.
- Top-level
- Widget renderer pattern (for widget rendition — use when user requests "widget", "mosaic", "fragment", or "cross-platform rendering"):
- Structure:
renderer.componentOverrides["$"] = { "type": "mosaic", "definition": "tile/mosaic", "children": [ /* UEM tree of blocks and regions */ ] } - CRITICAL: Do NOT create a custom LWC component (e.g.
c/<componentName>) for widget rendering. Widget rendition uses atile/mosaicUEM block tree — not a custom component. Creating a custom LWC here is always wrong. - REQUIRED workflow:
- STOP: Do NOT attempt to build the UEM tree yourself.
- MANDATORY FIRST STEP: You MUST fetch the reference file
references/widget-rendition.mdlocated in this skill's directory before proceeding. - Follow the complete workflow documented in
widget-rendition.mdusing the generated CLT schema as the grounding schema. - The
widget-rendition.mdreference contains the full widget generation workflow: discovering UEM blocks via discoverUiComponents, calling getUiComponentSchemas, building the UEM tree, and writing renderer.json. - Do not attempt to generate widget rendition without first fetching the
widget-rendition.mdreference file.
- Structure:
- Root override pattern (for custom LWC rendering — only when widget/mosaic was NOT requested):
renderer.componentOverrides["$"] = { "definition": "c/<yourRendererComponent>", "attributes": { ... } }- Use
{!$attrs.<name>}in attribute mappings when binding schema data to custom renderer component attributes. - CRITICAL: Attribute mappings like
{!$attrs.propertyName}must reference properties that actually exist in your type schema. Referencing non-existent properties will fail validation. - Type matching: Attribute values must match the expected type for the component. For example, if a component expects a string attribute, passing an integer will fail validation.
- Property-level override pattern:
renderer.componentOverrides["<propertyName>"] = { "definition": "es_property_editors/outputText" | "es_property_editors/outputNumber" | "es_property_editors/outputImage" | ... }. Valid renderer components (examples):es_property_editors/outputText,es_property_editors/outputNumber,es_property_editors/outputImage. Avoid input-style components in the renderer.
- Layout pattern for renderer:
renderer.layout.definition = "lightning/verticalLayout"renderer.layout.children[*].definition = "lightning/propertyLayout"withattributes.property = "<propertyName>"- CRITICAL: Same as editor layouts,
lightning/propertyLayoutonly accepts thepropertyattribute. Do NOT addlabel,title, or any other attributes.
- Collection renderer (for root-level
lightning__listTypeproperties): Usecollection.renderer.componentOverrides["$"] = { "definition": "c/<yourListRendererComponent>" }ores_property_editors/genericListTypeRendererto render the list.
- ⚠️ DECIDE FIRST — widget or custom LWC? Before writing any renderer code or planning any steps:
- Place files in the correct bundle structure
lightningTypes/<TypeName>/schema.json- (Optional)
lightningTypes/<TypeName>/lightningDesktopGenAi/editor.json - (Optional)
lightningTypes/<TypeName>/lightningDesktopGenAi/renderer.json - For Gen AI / Copilot the standard path is
lightningDesktopGenAi/. Other targets (e.g. Experience Builder, Mobile Copilot, Enhanced Web Chat) use different subfolders when supported:experienceBuilder/,lightningMobileGenAi/,enhancedWebChat/.
- Configure custom LWC components (if using custom components)
- CRITICAL: Custom LWC components referenced in editor/renderer configs MUST have the correct target configuration in their
-meta.xmlfiles:- For editor components (
c/<componentName>used ineditor.json): The LWC's-meta.xmlfile must include<target>lightning__AgentforceInput</target> - For renderer components (
c/<componentName>used inrenderer.json): The LWC's-meta.xmlfile must include<target>lightning__AgentforceOutput</target>
- For editor components (
- Without the correct target, deployment will fail with:
Invalid target configuration. To use 'c/componentName' as a renderer/editor, your js-meta.xml file must include valid target 'lightning__AgentforceOutput/Input'. - Example
-meta.xmlfor a renderer component:<?xml version="1.0" encoding="UTF-8"?> <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> <apiVersion>60.0</apiVersion> <isExposed>true</isExposed> <targets> <target>lightning__AgentforceOutput</target> </targets> </LightningComponentBundle>
- CRITICAL: Custom LWC components referenced in editor/renderer configs MUST have the correct target configuration in their
- Deploy and validate
- Run a final schema sanity check before deploy: valid
lightning:typenames, required fields present, and no disallowed keywords. - Deploy the bundle using your org's standard metadata deployment flow (e.g. Salesforce CLI or IDE). The MCP client or tooling in use should provide or integrate with the appropriate deploy/retrieve commands for Lightning Type bundles.
- Validate incrementally: if deployment fails, remove disallowed keywords first (especially
examples,items, nestedlightning:type).
- Run a final schema sanity check before deploy: valid
Common Deployment Errors
| Error / Symptom | Likely Cause | Fix |
|---|---|---|
| Schema validation fails due to unknown keyword | unevaluatedProperties: false + disallowed keyword (commonly examples, items) |
Remove the offending keyword; keep schema minimal |
| Nested object validation failure | Org/channel validation rejects nested object typing in LightningTypeBundle |
Use CLT reference (c__<CLTName>) or Apex class types |
| Invalid CLT reference | Referenced CLT doesn't exist in org or incorrect syntax | Deploy the referenced CLT first; c__<CLTName> must match the referenced type’s lightning:type value / FQN / registered identifier, not title |
Invalid or misspelled lightning:type (for example, lightning__richtextType instead of lightning__richTextType) |
Incorrect generated type name | Cross-check all lightning:type values against supported type names and correct them before deployment |
| Array property rejected | Use of items (or lightning:type in nested arrays) rejected by validator |
For nested arrays: keep only type: "array". For root arrays: use minimal structure; remove items if rejected |
| Apex-based CLT rejected | Extra fields added (e.g., type, properties) |
Use only title, optional description, and lightning:type |
| Editor config rejected | Use of invalid patterns (es_property_editors/inputList, itemSchema) or unrecognized top-level keys |
Use editor.componentOverrides and editor.layout; keep config minimal |
additionalProperties error on layout attributes |
Adding label or other attributes to lightning/propertyLayout |
Only use property attribute in lightning/propertyLayout. Remove label, title, or any other attributes |
| Invalid target configuration for custom LWC | Custom LWC component's -meta.xml missing required target (lightning__AgentforceInput or lightning__AgentforceOutput) |
Add correct target to LWC's -meta.xml: use lightning__AgentforceInput for editors, lightning__AgentforceOutput for renderers |
| Attribute mapping doesn't exist in type schema | Using {!$attrs.propertyName} where propertyName is not defined in schema |
Ensure all attribute mappings reference actual properties in your type schema's properties section |
additionalProperties error with deprecated keys |
Using propertyRenderers or view in editor/renderer config |
Replace deprecated propertyRenderers with componentOverrides and view with layout |
| Type mismatch in component attributes | Passing wrong type for component attribute (e.g., integer instead of string) | Ensure attribute values match the expected type defined by the component |
Verification Checklist
- Root schema has
type: "object",title,lightning:type: "lightning__objectType", andunevaluatedProperties: false - Root schema does not include
exampleswhen strict validation is enabled - No nested object includes
lightning:type: "lightning__objectType" - Arrays are defined minimally (especially nested arrays)
- Only supported primitive
lightning:typeidentifiers are used for leaf properties - Apex class CLTs contain only
title/descriptionandlightning:type: "@apexClassType/..." - Bundle structure and filenames match Lightning Types requirements
- Editor config uses only allowed patterns (no
es_property_editors/inputList, noitemSchema); use valid components (e.g.es_property_editors/inputText,es_property_editors/inputNumber) or customc/components - Renderer config uses output-style components (e.g.
es_property_editors/outputText,es_property_editors/outputNumber) where applicable, not input editors - Widget renderer uses
tile/mosaicUEM block tree (NOT a customc/<componentName>LWC) - Layout configurations use
lightning/propertyLayoutwith ONLY thepropertyattribute (nolabel,title, or other attributes) - All attribute mappings (
{!$attrs.propertyName}) reference properties that exist in the type schema - Custom LWC components have correct targets in
-meta.xml:lightning__AgentforceInputfor editors,lightning__AgentforceOutputfor renderers