lwc-lightning-record-forms

Lightning Data Service form components for LWC — when to use lightning-record-form vs lightning-record-edit-form vs lightning-record-view-form, output-field vs input-field, density modes, layout types (Compact/Full), and the platform-managed validation/save/error UI. NOT for fully custom form layouts (use lwc/lwc-custom-form-with-uiRecordApi) or aura:recordEditForm (Aura is deprecated for new work).

Best use case

lwc-lightning-record-forms is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Lightning Data Service form components for LWC — when to use lightning-record-form vs lightning-record-edit-form vs lightning-record-view-form, output-field vs input-field, density modes, layout types (Compact/Full), and the platform-managed validation/save/error UI. NOT for fully custom form layouts (use lwc/lwc-custom-form-with-uiRecordApi) or aura:recordEditForm (Aura is deprecated for new work).

Teams using lwc-lightning-record-forms should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/lwc-lightning-record-forms/SKILL.md --create-dirs "https://raw.githubusercontent.com/PranavNagrecha/AwesomeSalesforceSkills/main/skills/lwc/lwc-lightning-record-forms/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/lwc-lightning-record-forms/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How lwc-lightning-record-forms Compares

Feature / Agentlwc-lightning-record-formsStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Lightning Data Service form components for LWC — when to use lightning-record-form vs lightning-record-edit-form vs lightning-record-view-form, output-field vs input-field, density modes, layout types (Compact/Full), and the platform-managed validation/save/error UI. NOT for fully custom form layouts (use lwc/lwc-custom-form-with-uiRecordApi) or aura:recordEditForm (Aura is deprecated for new work).

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# LWC Lightning Record Forms

Lightning Data Service ships three form base components that
remove the most common reasons developers hand-write forms:
field-level security enforcement, page-layout awareness, automatic
validation, and managed save/error UI. They are
`lightning-record-form` (the all-in-one), `lightning-record-edit-form`
(create/edit with custom layout), and `lightning-record-view-form`
(read-only with custom layout).

The decision is mostly about how much layout control you need.
`lightning-record-form` is one tag, takes an object + optional
record Id + a layout-type, and renders the entire form including
mode toggle, save/cancel buttons, spinner, and inline errors. The
two `-edit-form` and `-view-form` variants give you back the
template — you place `lightning-input-field` / `lightning-output-field`
yourself and own the buttons. Both still leverage LDS for caching,
FLS, and validation.

The mistakes follow a predictable pattern. Engineers reach for a
hand-rolled form with `@wire(getRecord)` and manual DML the moment
they need a single CSS tweak, abandoning every benefit of LDS. Or
they try to mix `lightning-record-edit-form` with custom Apex
`@AuraEnabled` saves, fighting the framework. Or they forget that
`lightning-input-field` requires `field-name` to be a value imported
via `@salesforce/schema/Object.Field`, not a string literal — and
the form silently renders nothing.

## Recommended Workflow

1. **Choose the smallest component that works.** Start with
   `lightning-record-form`. Move to `-edit-form` or `-view-form`
   only when you need a custom layout, custom buttons, or
   conditional fields. Never start with hand-rolled.
2. **Import field references via `@salesforce/schema`.** This
   is what enables compile-time validation, FLS enforcement, and
   safe refactoring. String-literal field names in `field-name`
   are accepted but lose all of the above.
3. **Pick the layout-type deliberately.** `Compact` mirrors the
   compact layout (Salesforce-managed, admin-editable). `Full`
   mirrors the page layout. A `fields=[...]` array is fully
   programmatic — use this when the form's contents must not
   shift when an admin edits the layout.
4. **Wire `onsuccess`, `onsubmit`, and `onerror`.** `onsubmit`
   fires before save, lets you mutate `event.detail.fields` for
   conditional defaults; `onsuccess` fires after, lets you fire a
   toast or navigate. Without `onerror`, validation errors still
   show inline (LDS handles it) but you cannot react
   programmatically.
5. **Set `density="comfy" | "compact" | "auto"` to match the host
   surface.** Default `auto` adapts to the SLDS density flag set
   on the user record — overriding only makes sense when the form
   is on a tightly-scoped page (a modal) where you know which
   layout you want.
6. **Test by simulating LDS in jest.** Use
   `@salesforce/sfdx-lwc-jest` mocks for `getRecord` /
   `createRecord` / `updateRecord`. Do not unit-test the form's
   internal save logic — that is platform code.

## When To Reach For Custom (Skip This Skill)

If you need a wizard with multiple steps, a custom save endpoint
that does cross-object orchestration, or a UI tightly coupled to
non-Salesforce data, do not start with `lightning-record-edit-form`.
Build the form with `lightning-input` components and call your
Apex method directly. The LDS form components are for the case
where Salesforce is the source of truth for one record at a time.

## What This Skill Does Not Cover

| Topic | See instead |
|---|---|
| Fully custom forms with `uiRecordApi` | `lwc/lwc-custom-form-with-uiRecordApi` |
| Custom lookup fields inside a form | `lwc/lwc-custom-lookup` |
| Datatable inline edit | `lwc/lwc-datatable-advanced` |
| Aura `lightning:recordEditForm` | Aura is deprecated for new work |

Related Skills

record-access-troubleshooting

8
from PranavNagrecha/AwesomeSalesforceSkills

Diagnose why a user can or cannot see/edit a record: UserRecordAccess SOQL, Why Can a User Access This Record debug log, OWD, role hierarchy, sharing rules, manual/team/apex shares, implicit parent share. NOT for field-level security (use field-level-security-audit). NOT for designing sharing (use sharing-selection decision tree).

tableau-embedding-in-lightning

8
from PranavNagrecha/AwesomeSalesforceSkills

Embedding Tableau dashboards (and Tableau Pulse insights) inside Lightning App / Record / Home pages — Tableau Embedding API v3 in an LWC, the connected-app + JWT trust pattern for SSO from Salesforce to Tableau, row-level security so a Salesforce user only sees their data in Tableau, CSP / Trusted Sites configuration for the Tableau host, and the Tableau Viz Lightning Web Component (drag-and-drop alternative to a custom LWC). NOT for building Tableau dashboards / data sources (that's Tableau-side work), NOT for CRM Analytics (Tableau is the separate product; see data/crm-analytics-patterns).

lwc-record-picker

8
from PranavNagrecha/AwesomeSalesforceSkills

lightning-record-picker base component (Winter '24 GA): object/record filter, displayInfo/matchingInfo, graph-ql filters, accessibility. Replaces ad-hoc lookup inputs. NOT for multi-select custom pickers (use lwc-multi-select-lookup). NOT for external-object lookup (use lwc-external-lookup).

lwc-lightning-modal

8
from PranavNagrecha/AwesomeSalesforceSkills

LightningModal base class (Winter '23+): extending LightningModal, open() static method, modal headers/bodies/footers, close() with result, size variants, accessibility. NOT for lightning-dialog legacy patterns (deprecated). NOT for in-page overlays (use SLDS popover).

lwc-forms-and-validation

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when building or reviewing Lightning Web Component form UX, especially the choice between `lightning-record-edit-form` and custom inputs, client-side validation with `reportValidity()`, server-side validation feedback, and file upload flows. Triggers: 'record edit form in lwc', 'reportValidity not working', 'custom validation message', 'fieldErrors in onerror'. NOT for Flow screen design or Apex-only validation logic.

lightning-navigation-dead-link-handling

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when an LWC navigates via NavigationMixin to records or pages that may no longer exist, lack the user's access, or be permanently moved. Triggers: 'lightning navigation 404', 'navigate to deleted record', 'NavigationMixin error toast', 'graceful fallback when target page missing', 'permission denied on navigation'. NOT for general routing within an SPA or for Experience Cloud public-facing routing.

record-triggered-flow-patterns

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when designing or reviewing Salesforce record-triggered Flows, especially before-save vs after-save behavior, entry criteria, recursion avoidance, and when to escalate to Apex. Triggers: 'before save vs after save', '$Record__Prior', 'record-triggered flow', 'order of execution', 'flow recursion'. NOT for screen-flow UX or pure bulkification work when the trigger model is already correct.

flow-record-save-order-interaction

8
from PranavNagrecha/AwesomeSalesforceSkills

Reason about how record-triggered flows interleave with the Salesforce Save Order (validation, before-save flows, before triggers, duplicate rules, after-save flows, workflow, after triggers, assignment, auto-response, escalation). Trigger keywords: save order, before-save flow, after-save flow, dml order, trigger vs flow order. Does NOT cover writing trigger handlers, approval process setup, or workflow rule migration.

flow-record-locking-and-contention

8
from PranavNagrecha/AwesomeSalesforceSkills

Diagnose and prevent UNABLE_TO_LOCK_ROW + parent-record contention in record-triggered, scheduled, and screen flows by mapping the implicit lock chain and applying decouple patterns (Platform Events, Queueable handoff, Scheduled Paths). NOT for general flow bulkification — see flow-bulkification. NOT for fault-path catch logic — see flow-rollback-patterns.

flow-get-records-optimization

8
from PranavNagrecha/AwesomeSalesforceSkills

Optimize Get Records elements in Flow: filter sharpness, field selection, sort-and-limit placement, caching via formula resources, and avoiding repeated queries in loops. Trigger keywords: get records, flow soql, flow query limit, flow performance, record lookup. Does NOT cover Apex SOQL, Data Cloud queries, or external object lookups.

record-merge-implications

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when merging Account, Contact, or Lead records in Salesforce and needing to understand what data is kept, what is deleted, and what side effects occur on related records. Triggers: 'which fields win in a merge', 'child records after merge', 'merge duplicate accounts', 'what happens to opportunities after contact merge', 'Lead merge field resolution'. NOT for deduplication strategy design (use data-quality-and-deduplication), NOT for Apex Merge DML beyond its direct implications.

architecture-decision-records

8
from PranavNagrecha/AwesomeSalesforceSkills

Author and maintain Architecture Decision Records (ADRs) for Salesforce implementations: capture chosen approach, rejected alternatives, constraints, and consequences. Trigger keywords: adr, architecture decision record, design decision log, technical decision. Does NOT cover project roadmap planning, release notes, or RFC workflow for features.