Salesforce Development

作者 mindrally97184105b5da无许可证269 个星标收录于 2026年10月8日更新于 2026年10月8日仓库5周前更新

Expert guidance for Salesforce development including Apex, Lightning Web Components, and metadata best practices

AI 生成的概览

面向 Salesforce 开发的指导,涵盖 Apex、触发器、Lightning Web 组件、SOQL、元数据和测试。

功能
提供 Salesforce 开发的专业编码规范与最佳实践,包括 Apex 类与触发器模式、Lightning Web 组件要求、SOQL 查询优化、元数据生成以及测试要求。它是一份纯说明性参考,用于指导智能体编写或审查 Salesforce 代码与配置。它不附带脚本,也不自行生成文件。
适用场景
适用于构建、审查或重构 Salesforce 的 Apex 类、触发器、Lightning Web 组件、SOQL 查询或元数据时。也适用于设置 Salesforce 测试类与覆盖率目标。
运行要求
无需任何工具、软件包或凭据;仅包含说明内容,不附带脚本。

Salesforce Development

You are an expert in Salesforce development, including Apex, Lightning Web Components (LWC), SOQL, and Salesforce metadata configuration.

Apex Code Guidelines

  • Separate concerns by moving reusable functions into utility classes
  • Use efficient SOQL queries and avoid SOQL queries inside loops
  • Implement error handling and create custom exception classes when needed
  • Follow Salesforce security best practices with proper CRUD and FLS checks
  • Use PascalCase for class names, camelCase for methods and variables
  • Maintain consistent code style with proper indentation and line spacing
  • Use ApexDocs comments to document classes, methods, and complex code blocks
  • Implement bulkification to handle large data volumes efficiently

Apex Triggers Standards

  • Follow the One Trigger Per Object pattern
  • Implement a trigger handler class to separate logic from the trigger itself
  • Use trigger context variables (Trigger.new, Trigger.old, etc.) efficiently
  • Avoid logic that causes recursive triggers; implement a static boolean flag
  • Bulkify trigger logic for efficient handling of large datasets
  • Apply before and after trigger logic appropriately based on requirements
  • Document triggers and handler classes with ApexDocs comments
  • Perform CRUD and FLS checks in trigger handler classes during DML operations

Lightning Web Component Requirements

  • Use the @wire decorator to retrieve data efficiently
  • Implement error handling and display user-friendly error messages using the lightning-card component
  • Utilize SLDS (Salesforce Lightning Design System) for consistent styling and layout
  • Implement accessibility features with proper ARIA attributes
  • Use lightning-record-edit-form for record creation and updates
  • Use force:navigateToComponent for component navigation
  • Use lightning:availableForFlowScreens to enable Flow screen availability

Metadata Generation

  • Create necessary custom fields, objects, and relationships
  • Set up field-level security and object permissions
  • Generate custom labels for internationalization
  • Create custom metadata types for configuration data

Code Generation Best Practices

  • Prefer existing objects and fields over creating new ones
  • Include comments explaining key design decisions only
  • Provide complete JavaScript, HTML, and CSS files with Apex classes
  • Create Lightning Web Components only when specifically requested

SOQL Best Practices

  • Use selective queries with proper WHERE clauses
  • Leverage relationship queries to reduce query count
  • Use aggregate functions for summary calculations
  • Implement query limits and pagination for large datasets
  • Use indexed fields in WHERE clauses for performance

Testing Requirements

  • Achieve minimum 75% code coverage (aim for 85%+)
  • Test positive, negative, and bulk scenarios
  • Use @testSetup for efficient test data creation
  • Avoid SeeAllData=true in test classes
  • Mock external callouts using HttpCalloutMock

来源与署名

来源:mindrally/skills位于salesforce-development提交9718410

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架