npx skills add ...
npx skills add forcedotcom/sf-skills --skill experience-lds-best-practices-apply
Use when reviewing or implementing Lightning Data Service best practices in an LWC (.js, .html, .js-meta.xml) — UIAPI vs Apex, refreshApex / notifyRecordUpdateAvailable, @salesforce/schema imports, LDS record-form data patterns. TRIGGER on \"apply LDS best practices to this LWC\", \"review this LWC for LDS best-practice issues\", \"review this component for Lightning Data Service issues\", \"UIAPI or Apex for this data?\", \"fix stale data after record save\", \"sync LDS cache\", \"use @salesforce/schema for field names\", \"choose between getRecord and Apex\". DO NOT TRIGGER when building a new LWC (use experience-lwc-generate), applying SLDS design tokens (use design-systems-slds-apply), picking or wiring a `lightning-*` base component's props/events/slots generically (use experience-lwc-base-components-integrate — this skill covers only the LDS data-layer rationale, even when the fix involves a base record form), or for security / RTL / accessibility reviews (separate passes).
npx skills add forcedotcom/sf-skills --skill experience-lds-best-practices-apply
Apply the Lightning Data Service guidelines to a Lightning Web Component. Three pillars: data consistency, referential integrity, and UIAPI vs Apex. Focused on the UI API path — GraphQL and upstream data-requirements analysis are handled out-of-band.
getRecord, getRecords, createRecord, updateRecord, deleteRecord, base record form components, or Apex.@salesforce/schema/...) to replace hard-coded field/object names.Do NOT use this skill for:
design-systems-slds-apply).@salesforce/schema imports (Setup → Object Manager → <Object> → Details → API Name; or, when GraphQL serves the read, an SDL pulled from the target org).refreshApex, notifyRecordUpdateAvailable, wire result propagation.@salesforce/schema imports, field constants, object-name resolution, and their propagation through refactors.Per-adapter API reference — references/adapter-apis.md holds Syntax / Parameters / Returns / Usage for every UI API adapter, grouped by family (uiRecordApis, uiListsApis, uiRelatedListApis, uiObjectInfoApis). Each adapter is a # `<name>` block; grep for the backticked name (e.g. # `getRecord`) to jump to its entry. Read this before wiring an adapter; do not paraphrase from memory.
Type catalog — references/wire-adapter-types.md holds every type the adapters return (Record, ObjectInfo, FieldValue, etc.), grouped by category and rendered with the same formatter the legacy MCP tool used. Grep for ## <TypeName> to jump to a specific entry.
Read the applicable reference before editing code.
refreshApex(wiredResult) or notifyRecordUpdateAvailable([{ recordId }]) after any mutation.@salesforce/schema — not string literals. This protects the component against metadata renames.lightning-record-form, lightning-record-edit-form, lightning-record-view-form) for single-record UIs. They ship with validation, SLDS styling, accessibility, and field-level security.Answer Yes / No to each. Any Yes triggers a refactor.
lightning-record-form, lightning-record-edit-form, or lightning-record-view-form would suffice?record.data.fields.Name.value without schema imports?@salesforce/schema import even though it interacts with Salesforce fields?getRecord, updateRecord, or a base record form could handle?List every data operation in the component:
@wire(getRecord, …), @wire(getRecords, …), @wire(someApexMethod, …)).updateRecord, createRecord, deleteRecord, Apex imperative).Walk sections §1–§4 in order. For each section, decide whether it applies to the component under review and record the result in the report. Use the shape below — every section must appear exactly once, either as an issue (violation) under ## LDS Best Practices, or as a compliant entry under ## Sections checked (no issue). Finish with a ## Summary line listing counts and a one-paragraph narrative.
Report shape:
Rules for producing this report:
## Sections checked (no issue).## LDS Best Practices, only list actual violations. If there are no violations, write "No best-practice issues found." as the first line, then move every section to the compliant block.For every hard-coded API name:
Use these constants everywhere the object or field is referenced — wire configs, @wire field arrays, getFieldValue(record, NAME_FIELD) calls, and base-component object-api-name / fields attributes.
Full rules: references/lds-referential-integrity.md.
updateRecord, createRecord, deleteRecord), dispatch a refresh:
this.wiredRecord = result; return result.data;) so refreshApex can target them.Full rules: references/lds-data-consistency.md.
getRecord (with fields + schema imports).updateRecord or lightning-record-edit-form.createRecord or lightning-record-form with mode="edit".getRelatedListRecords.getPicklistValues.getObjectInfo / getObjectInfos.When in doubt about adapter shape, grep references/adapter-apis.md for the backticked adapter name (e.g. # `getRecord`) — it has the authoritative parameters, returns, and usage. For @salesforce/schema/<Object>.<Field> paths, confirm the exact API name in Setup → Object Manager → <Object> → Details → API Name. For unfamiliar return types, grep references/wire-adapter-types.md for the type name.
refreshApex called exactly once per mutation).experience-lwc-generate — when the review surfaces the need to regenerate rather than patch the component.design-systems-slds-apply — for SLDS class / design-token cleanup surfaced by the LDS review.Base-component first (preferred)
Imperative update with refresh
@salesforce/schema/ imports — they should cover every field/object the component references.'Account', 'Name') — none should appear in wire configs or field arrays.refreshApex, notifyRecordUpdateAvailable, or a base form handling it internally).