grzmol/vibe-force/sf-lwc-development

Claude Code and agent skill by grzmol/vibe-force

Trust tier 3
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"},{"type":"config","description":"Configuration overrides"}]
Source check pending

Checking that the SKILL.md file is still in the repository.

Covers building Lightning Web Components on the Salesforce platform - bundle anatomy and js-meta.xml targets/targetConfigs, the reactivity model, @api/@wire/@track decorators, Lightning Data Service and imperative Apex, CustomEvent and Lightning Message Service communication, lifecycle hooks, template directives (lwc:if, for:each, iterator, lwc:ref, lwc:dom="manual", slots), SLDS styling hooks, shadow vs light DOM, NavigationMixin, toasts, labels and i18n, static resources and third-party JS, Lightning Web Security constraints, and performance/accessibility rules. Use this skill whenever work touches force-app/**/lwc/**, a *.js-meta.xml file, a wire adapter such as getRecord or graphql, an @AuraEnabled(cacheable=true) method consumed from JavaScript, refreshApex, a LightningMessageChannel, or when a component must be exposed to a Lightning App Page, Record Page, Flow screen, quick action, or Experience Cloud site.

Install

npx vskill@latest install grzmol/vibe-force/sf-lwc-development

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

The same SKILL.md was published earlier as grzmol/vibe-force/sf-lwc-development.

Lightning Web Components Development

When to use

SituationUse this skill
Creating or editing anything under force-app/main/default/lwc/Yes
Choosing between @wire, imperative Apex, and Lightning Data ServiceYes
Component must appear in Lightning App Builder, Flow Builder, or Experience BuilderYes
Writing the Apex controller behind the componentSkill sf-apex-development (this skill covers only the JS side of the contract)
Writing Jest tests for the componentSkill sf-lwc-jest-testing
Previewing the component without deployingSkill sf-local-development
ESLint/PMD/Code Analyzer findings on LWC JSSkill sf-code-analyzer-quality
Generating a component, spec or migration with Salesforce DX MCP tools or Agentforce Vibes LWC skillsYes - `references/mcp-and-skills.md`, then the same gates apply

LWC is the owner slice of sf-lwc-engineer in wave 1: lwc/ and aura/ only. Apex signatures the component consumes are fixed in wave 0 and recorded in .vibeforce/state/contract.md.

Decision table

NeedMechanismCacheableRefresh path
Read one record, fields known at build time@wire(getRecord, {recordId, fields})Yes (LDS)Automatic; notifyRecordUpdateAvailable() after out-of-band writes
Read several related objects in one round trip@wire(graphql, {query, variables})Yes (LDS)refreshGraphQL / re-evaluate variables
Read object metadata or picklistsgetObjectInfo, getPicklistValuesYes (LDS)Automatic
Read a query/aggregate LDS cannot express@wire(apexMethod) with @AuraEnabled(cacheable=true)Yes (client cache)refreshApex(this.wiredResult)
Write one record, standard fieldscreateRecord / updateRecord / deleteRecord (lightning/uiRecordApi)n/aLDS updates wires automatically
Write with server-side business logicimperative Apex (@AuraEnabled, never cacheable=true)Noawait notifyRecordUpdateAvailable([{recordId}])
Form UI with zero JSlightning-record-form / lightning-record-edit-formn/aonsuccess event
Fire-and-forget action on user clickimperative Apex in an async handlerNon/a

Rule: a method annotated @AuraEnabled(cacheable=true) cannot perform DML; it is the only shape @wire accepts. Any DML path must be a separate non-cacheable @AuraEnabled method.

Core patterns

1. Bundle anatomy and configuration
force-app/main/default/lwc/accountCard/
accountCard.js default-exported class extending LightningElement
accountCard.html template (optional only for service components)
accountCard.css scoped styles (optional)
accountCard.js-meta.xml required; controls exposure and builder configuration
__tests__/accountCard.test.js Jest suite (gate: vf-check jest)
xml
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>67.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>Account Card</masterLabel>
<description>Shows key account fields with an escalate action.</description>
<targets>
<target>lightning__RecordPage</target>
<target>lightning__AppPage</target>
<target>lightningCommunity__Default</target>
</targets>
<targetConfigs>
<targetConfig targets="lightning__RecordPage">
<property name="showEscalate" type="Boolean" label="Show Escalate Button" default="true"/>
<objects>
<object>Account</object>
</objects>
</targetConfig>
<targetConfig targets="lightningCommunity__Default">
<property name="recordId" type="String" label="Record Id"/>
</targetConfig>
</targetConfigs>
</LightningComponentBundle>

apiVersion comes from config/vibe-force.defaults.json (67.0). Beginning in Spring '25 every component must carry an apiVersion tag to be saved back to Salesforce. isExposed=false hides the component from all builders; exposure additionally requires at least one <target>. Full target list: references/component-reference.md.

2. Reactivity: fields, not state objects
javascript
import { LightningElement, track } from 'lwc';
export default class ReactivityExample extends LightningElement {
// Reactive by default: reassignment of a field re-renders if the field is used in the template
count = 0;
filters = { status: 'Open' };
@track rows = []; // @track only for mutation-in-place of objects/arrays
get label() { // getters are the supported way to compute template values
return `${this.count} open`;
}
mutate() {
this.count = 1; // rerender
this.filters.status = 'Closed'; // NO rerender: field not reassigned
this.filters = { ...this.filters, status: 'Closed' }; // rerender
this.rows.push({ id: '1' }); // rerenders only because of @track
}
}

Reassigning a field to an ===-equal primitive is not a mutation and does not rerender. Prefer immutable replacement ({...obj}, [...arr]) over @track; reserve @track for deep mutation you genuinely cannot avoid. @track and @api on the same property is a compile error (LWC1093).

3. Public API: @api properties and methods
javascript
import { LightningElement, api } from 'lwc';
export default class Badge extends LightningElement {
@api recordId; // set by the record page container
@api variant = 'neutral';
_rows = [];
@api
get rows() { return this._rows; }
set rows(value) { this._rows = Array.isArray(value) ? [...value] : []; } // normalize on the way in
@api focusFirst() { // public method, called by parent via querySelector
this.refs.firstInput?.focus();
}
}

Never mutate an @api property from inside the component; the owner owns the value. Public property setters run before connectedCallback() on initial render and again on every reassignment by the owner.

4. Wire service and refresh
javascript
import { LightningElement, api, wire } from 'lwc';
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import NAME_FIELD from '@salesforce/schema/Account.Name';
import RATING_FIELD from '@salesforce/schema/Account.Rating';
import getOpenCases from '@salesforce/apex/AccountCaseController.getOpenCases';
import { refreshApex } from '@salesforce/apex';
export default class AccountCard extends LightningElement {
@api recordId;
wiredCases;
error;
@wire(getRecord, { recordId: '$recordId', fields: [NAME_FIELD, RATING_FIELD] })
account;
@wire(getOpenCases, { accountId: '$recordId' })
handleCases(result) {
this.wiredCases = result; // keep the whole result for refreshApex
const { data, error } = result;
this.error = error ? this.reduce(error) : undefined;
}
get accountName() {
return getFieldValue(this.account.data, NAME_FIELD);
}
async refresh() {
await refreshApex(this.wiredCases);
}
reduce(error) {
return error?.body?.message ?? error?.body?.pageErrors?.[0]?.message ?? 'Unknown error';
}
}

$recordId makes the configuration dynamic: when recordId changes, the adapter re-provisions. refreshApex takes the value provisioned by an Apex @wire (the whole result object, not result.data). Never mutate a wire configuration property inside renderedCallback(); that is an infinite-loop generator.

5. Imperative Apex and error shape
javascript
import escalate from '@salesforce/apex/CaseEscalationService.escalate';
import { notifyRecordUpdateAvailable } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
async handleEscalate() {
this.busy = true;
try {
await escalate({ caseId: this.recordId, reason: this.reason });
await notifyRecordUpdateAvailable([{ recordId: this.recordId }]);
this.dispatchEvent(new ShowToastEvent({
title: 'Escalated', message: 'Case escalated to tier 2.', variant: 'success'
}));
} catch (error) {
this.dispatchEvent(new ShowToastEvent({
title: 'Escalation failed', message: this.reduce(error), variant: 'error', mode: 'sticky'
}));
} finally {
this.busy = false;
}
}

Apex errors reach JavaScript as { body: { message } } for AuraHandledException, and as { body: { pageErrors: [], fieldErrors: {}, output: {...} } } for DML/record errors from LDS. Always reduce defensively - see references/data-access-patterns.md for a complete reduceErrors helper.

6. Events: child to parent, and cross-tree
javascript
// child: selector.js
handleSelect(event) {
this.dispatchEvent(new CustomEvent('rowselect', {
detail: { recordId: event.currentTarget.dataset.id } // primitives only
}));
}
html
<!-- parent -->
<c-selector onrowselect={handleRowSelect}></c-selector>

Defaults are bubbles: false, composed: false: the event stops at the component boundary, which is what you want for parent/child. Use { bubbles: true, composed: true } only for genuinely application-level events, and never put mutable objects in detail. For sibling or cross-DOM communication use Lightning Message Service, not a home-grown pubsub module:

javascript
import { LightningElement, wire } from 'lwc';
import { publish, subscribe, unsubscribe, MessageContext, APPLICATION_SCOPE } from 'lightning/messageService';
import RECORD_SELECTED from '@salesforce/messageChannel/Record_Selected__c';
export default class ListPanel extends LightningElement {
@wire(MessageContext) messageContext;
subscription;
connectedCallback() {
this.subscription = subscribe(this.messageContext, RECORD_SELECTED,
(message) => { this.selectedId = message.recordId; },
{ scope: APPLICATION_SCOPE });
}
disconnectedCallback() { unsubscribe(this.subscription); this.subscription = null; }
select(id) { publish(this.messageContext, RECORD_SELECTED, { recordId: id }); }
}
7. Lifecycle hooks
HookFiresSafe to doNever do
constructor()Once, before insertionCall super() first, set non-DOM defaultsTouch this.template, read @api values
connectedCallback()On DOM insertion, parent to childSubscribe (LMS, message bus), read @api props, kick off imperative callsAssume children rendered
render()Before each renderReturn an imported template for multi-template componentsSide effects
renderedCallback()After every render, child to parentOne-time third-party init guarded by a boolean, imperative DOM readsMutate @api/wire-config props (infinite loop)
disconnectedCallback()On DOM removalunsubscribe, clearInterval, abort fetchesAssume it runs on tab close
errorCallback(error, stack)Child throws in lifecycle/renderRender a fallback, logSwallow silently
8. Templates
html
<template>
<template lwc:if={hasRows}>
<ul>
<template for:each={rows} for:item="row" for:index="i">
<li key={row.id} data-id={row.id} onclick={handleSelect}>{row.name}</li>
</template>
</ul>
</template>
<template lwc:elseif={loading}><lightning-spinner alternative-text="Loading"></lightning-spinner></template>
<template lwc:else><p>No results.</p></template>
<ul>
<template iterator:it={rows}>
<li key={it.value.id} class={it.first}>{it.value.name}</li>
</template>
</ul>

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Extension points

  • hookPre/post lifecycle hooks
  • configConfiguration overrides

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/grzmol/vibe-force/sf-lwc-development/badge)](https://verified-skill.com/skills/grzmol/vibe-force/sf-lwc-development)

Something wrong with this skill or its page? Tell us.