forcedotcom/sf-skills / skills/platform-widget-generate
platform-widget-generate
VerifiedUse this skill to author a complete HXL WidgetBundle (UEM body + schema.json + -meta.xml). TRIGGER when: user asks for a widget, mosaic, fragment, card, or rich UI surface for any subject, domain, feature, or entity noun; the prompt names only an entity or data shape without invoking Lightning Types, CLTs, or Apex-backed types. DO NOT TRIGGER when: the prompt explicitly says 'Lightning Type', 'CLT', 'Custom Lightning Type', 'Apex-backed type', or references '@apexClassType/...' (use platform-lightning-type-widget-coordinate); authoring a custom-LWC renderer for a Custom Lightning Type (use platform-custom-lightning-type-generate); or editing only an LWC component.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 19.1 KB |
| examples/conditional.json | config | 2.5 KB |
| examples/formulas.json | config | 13.5 KB |
| examples/list-with-foreach.json | config | 2.4 KB |
| examples/localized-labels.json | config | 1.8 KB |
| examples/single-object.json | config | 2.2 KB |
| references/schema-from-lightning-type.md | markdown | 7.5 KB |
| references/widget-actions.md | markdown | 711 B |
| references/widget-bundle-layout.md | markdown | 5.2 KB |
| references/widget-bundle-validation.md | markdown | 2.8 KB |
| references/widget-formulas.md | markdown | 10.6 KB |
| references/widget-gotchas.md | markdown | 2.5 KB |
| references/widget-labels.md | markdown | 3.0 KB |
| references/widget-meta-directives.md | markdown | 4.7 KB |
| references/widget-styling.md | markdown | 1.3 KB |
references/widget-bundle-layout.md
View on GitHub# WidgetBundle Layout
The widget skill writes three files into one directory under the project's package directory.
---
## Folder layout
```text
<pkgDir>/uiWidgets/<widgetName>/
<widgetName>.json # widget envelope + UEM body
schema.json # JSON Schema
<widgetName>.uiwidget-meta.xml # UiWidgetBundle registration
```
`<widgetName>` is `camelCase` and matches the directory name and both `<widgetName>.json` / `<widgetName>.uiwidget-meta.xml` filenames exactly.
---
## Resolving `<pkgDir>`
`<pkgDir>` resolves to `<packageDirectories[].path>/main/default` — the SFDX source-format default, where `<packageDirectories[].path>` is the `default: true` entry in `sfdx-project.json` (or the first entry if none is marked default).
---
## `<widgetName>.json` — Widget envelope + UEM body
The envelope has exactly two top-level keys — `type` and `contentBody`. The UEM tree lives at `contentBody.widgetBody`. Display metadata (label / description) lives in `<widgetName>.uiwidget-meta.xml`, not in the envelope.
```json
{
"type": "lightning__agentforceWidget",
"contentBody": {
"widgetBody": {
"definition": "tile/widget",
"children": [
/* every block — root and non-root — carries "definition", optional "attributes", optional "meta", optional "children". No "type" key on any node. */
]
}
}
}
```
Envelope keys:
- `type` — always `"lightning__agentforceWidget"`.
- `contentBody.widgetBody` — the root UEM node; this is `tile/widget`. It carries `definition` and `children` only — no `type` key on the root, no `type` key on any child.
Tree composition (everything inside `widgetBody.children`) is owned by `SKILL.md` *Composition*. No node — root or non-root — carries a `type` key.
---
## `schema.json` — Input contract
JSON Schema describing what data the widget accepts at runtime. Fields are wrapped one level deep under `properties.attributes`.
**Required root keys:**
- `title` (string) — display name
- `type` (string) — must equal `"object"`
- `properties.attributes` (object) — must carry `lightning:type: "lightning__objectType"` and a nested `properties` map whose leaves each carry `lightning:type`
**Optional root keys:**
- `description` (string)
**Each leaf under `properties.attributes.properties` MUST have `lightning:type`.** Optional per-leaf: `title`, `description`. **A `lightning__listType` leaf MUST also carry `items.lightning:type`** — set to the matching primitive `lightning:type` for a list of primitives, or to an `@apexClassType/...` reference for a list of Apex objects (see `references/schema-from-lightning-type.md`). **For a list of plain objects with no Apex-backed type**, `items.lightning:type` is `lightning__objectType` and `items` MUST also carry a nested `properties` map inlining every field the list items expose (same shape as the outer `attributes.properties` map).
Example:
```json
{
"title": "Order Summary Widget",
"description": "Displays an order's id, customer, total, and tags.",
"type": "object",
"properties": {
"attributes": {
"lightning:type": "lightning__objectType",
"properties": {
"orderId": { "title": "Order ID", "description": "Stable identifier shown in the header.", "lightning:type": "lightning__textType" },
"customer": { "title": "Customer", "description": "Display name of the customer on the order.", "lightning:type": "lightning__textType" },
"total": { "title": "Total", "description": "Order total in the order's currency.", "lightning:type": "lightning__numberType" },
"tags": { "title": "Tags", "description": "Labels attached to the order.", "lightning:type": "lightning__listType", "items": { "lightning:type": "lightning__textType" } }
}
}
}
}
```
`{!$attrs.X}` in the body resolves to `properties.attributes.properties.X` in the schema.
---
## `<widgetName>.uiwidget-meta.xml` — Registration
```xml
<?xml version="1.0" encoding="UTF-8"?>
<UiWidgetBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<masterLabel><Human display label></masterLabel>
<description><One-line description of what the widget renders></description>
<widgetType>JSON</widgetType>
</UiWidgetBundle>
```
Elements:
- `<masterLabel>` — required. Human-readable label shown in the runtime UI. Prefer title-case (e.g. `Account Summary Card`) — not the `camelCase` `<widgetName>`.
- `<description>` — required. One-line description of what the widget renders. Populates the display metadata previously carried in the envelope.
- `<widgetType>` — required. Only the `JSON` variant is supported. The `FUNCTION` variant is out of scope.
---
## Validation reminders
- Every `{!$attrs.X}` in `<widgetName>.json` MUST resolve to a property under `schema.json` `properties.attributes.properties` (or to a `forItem` loop variable defined upstream).
- `<widgetName>.uiwidget-meta.xml` MUST parse as well-formed XML, have root element `<UiWidgetBundle>`, and carry non-empty `<masterLabel>`, `<description>`, and `<widgetType>JSON</widgetType>` elements.
- The three files MUST be co-located in the same `<widgetName>/` directory under `uiWidgets/`.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |