lwc-patterns

Provide guidelines and patterns for building Lightning Web Components in Salesforce.

Updated Jul 2, 2026
One-click install
npx skills add https://github.com/padjei/SF_Agents --skill lwc-patterns-padjei
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: lwc-patterns
Source: https://github.com/padjei/SF_Agents/tree/main/.claude/skills/lwc-patterns
Command: npx skills add https://github.com/padjei/SF_Agents --skill lwc-patterns-padjei

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill unit provides comprehensive guidelines and patterns for building maintainable and efficient Lightning Web Components (LWC), addressing common pitfalls and promoting best practices in Salesforce development.

Core Features & Use Cases

  • Component Architecture: Offers guidelines for separating concerns between container and presentational components.
  • Data Binding: Demonstrates best practices for both one-way and event-driven data binding in LWC.
  • Wire Service: Shows how to leverage the Wire Service for efficient Apex method invocations.
  • Imperative Apex: Provides examples of when and how to use imperative Apex in LWC.
  • Events: Explains how to create and handle custom events within LWC.
  • Security: Advises on security considerations, such as avoiding innerHTML and handling Apex calls securely.
  • Error Handling: Offers a pattern for handling errors gracefully in LWC.
  • Performance: Suggests techniques for optimizing LWC performance.
  • Meta XML Targets: Lists the standard targets for LWC components.

Quick Start

Review the LWC patterns and apply them to your next Salesforce project to enhance the quality and performance of your Lightning Web Components.

Frequently Asked Questions about lwc-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What are the best practices for Lightning Web Components architecture in Salesforce?

Lightning Web Components best practices recommend separating concerns between container components for data fetching and presentational components for UI rendering. This separation creates maintainable and efficient LWC architectures across Salesforce applications.

How do I use the Wire Service versus imperative Apex in LWC?

The Wire Service efficiently invokes Apex methods reactively, caching data for Lightning Web Components automatically. Use imperative Apex for dynamic parameters, conditional execution, or when you need explicit control over error handling and data fetching timing.

How do I handle custom events and data binding in Lightning Web Components?

Lightning Web Components use event-driven data binding by dispatching custom events from child components and handling them in parent containers. This pattern ensures one-way data flow, maintaining predictable state management across your LWC hierarchy.

What security considerations should I follow when developing LWC?

LWC security guidelines advise avoiding innerHTML to prevent cross-site scripting and handling Apex calls securely. Lightning Web Components enforce Lightning Locker or Lightning Web Security, requiring strict input validation and secure data handling patterns.

How do I optimize performance and error handling in Lightning Web Components?

Optimize Lightning Web Components performance by leveraging the Wire Service for cached data and minimizing reactive property updates. Implement graceful error handling patterns to catch Apex failures and display user-friendly messages without breaking the UI.

What are the standard meta XML targets for Salesforce Lightning Web Components?

Standard meta XML targets for Lightning Web Components define where the component appears in Salesforce, such as record pages, app pages, and community pages. Configuring these targets correctly ensures your LWC is available in the intended Salesforce experiences.