home / skills / davila7 / claude-code-templates / salesforce-development

This skill helps you develop Salesforce apps by applying bulkified Apex, LWC wiring, and async patterns with best practices.

This is most likely a fork of the salesforce-development skill from xfstudio
npx playbooks add skill davila7/claude-code-templates --skill salesforce-development

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.5 KB
---
name: salesforce-development
description: "Expert patterns for Salesforce platform development including Lightning Web Components (LWC), Apex triggers and classes, REST/Bulk APIs, Connected Apps, and Salesforce DX with scratch orgs and 2nd generation packages (2GP). Use when: salesforce, sfdc, apex, lwc, lightning web components."
source: vibeship-spawner-skills (Apache 2.0)
---

# Salesforce Development

## Patterns

### Lightning Web Component with Wire Service

Use @wire decorator for reactive data binding with Lightning Data Service
or Apex methods. @wire fits LWC's reactive architecture and enables
Salesforce performance optimizations.


### Bulkified Apex Trigger with Handler Pattern

Apex triggers must be bulkified to handle 200+ records per transaction.
Use handler pattern for separation of concerns, testability, and
recursion prevention.


### Queueable Apex for Async Processing

Use Queueable Apex for async processing with support for non-primitive
types, monitoring via AsyncApexJob, and job chaining. Limit: 50 jobs
per transaction, 1 child job when chaining.


## Anti-Patterns

### ❌ SOQL Inside Loops

### ❌ DML Inside Loops

### ❌ Hardcoding IDs

## ⚠️ Sharp Edges

| Issue | Severity | Solution |
|-------|----------|----------|
| Issue | critical | See docs |
| Issue | high | See docs |
| Issue | medium | See docs |
| Issue | high | See docs |
| Issue | critical | See docs |
| Issue | high | See docs |
| Issue | high | See docs |
| Issue | critical | See docs |

Overview

This skill provides expert patterns and practical guidance for Salesforce platform development, covering Lightning Web Components (LWC), Apex triggers and classes, REST/Bulk APIs, Connected Apps, and Salesforce DX with scratch orgs and 2nd generation packages (2GP). It focuses on reliable, scalable patterns and common anti-patterns to avoid. Use it to standardize implementations, improve testability, and reduce runtime errors in production orgs.

How this skill works

The skill codifies proven patterns: reactive LWC wiring, bulkified Apex triggers with a handler layer, and Queueable Apex for asynchronous processing. It also highlights anti-patterns—SOQL/DML inside loops and hardcoded IDs—and provides pragmatic mitigations. Guidance includes DX workflows with scratch orgs and 2GP packaging for repeatable development and CI/CD.

When to use it

  • Building LWC components that consume Salesforce data or Apex services
  • Implementing or refactoring Apex triggers to handle bulk operations
  • Designing async jobs, integrations, or long-running processes using Queueable Apex or Bulk API
  • Setting up CI/CD with Salesforce DX, scratch orgs, and 2GP packages
  • Creating Connected Apps or REST integrations with OAuth and secure token flows

Best practices

  • Use @wire for LWC reactive data binding; prefer Lightning Data Service when possible
  • Always bulkify triggers and delegate logic to handler classes to improve testability
  • Avoid SOQL and DML inside loops; batch operations and use collections
  • Use Queueable Apex for non-primitive async processing and monitor jobs via AsyncApexJob
  • Parameterize configuration and avoid hardcoding IDs or credentials; use Custom Metadata or Named Credentials
  • Adopt Salesforce DX workflows with scratch orgs and 2GP for repeatable package-based delivery

Example use cases

  • LWC that displays related records using @wire to an Apex method for server-side filtering
  • Apex trigger that collects incoming records, validates and delegates to a handler class for bulk processing
  • Chained Queueable jobs that transform data, call an external API, and update records asynchronously
  • Automated CI pipeline that creates a scratch org, runs tests, and deploys a 2GP package to a hub org
  • Integration using a Connected App and Named Credentials to securely call external REST services

FAQ

How do I prevent trigger recursion?

Use a static boolean or a trigger framework that tracks processed record IDs in the transaction and short-circuits repeated execution.

When should I use Queueable vs Batch Apex?

Use Queueable for shorter, non-batch async work that needs complex types or chaining. Use Batch Apex for very large datasets that must be processed in batches with governor limits in mind.

How do I avoid hardcoded IDs across environments?

Store environment-specific values in Custom Metadata, Custom Settings, or Named Credentials, and reference them in code and configuration rather than embedding IDs.