Skip to content

How to Use Salesforce Developer in Claude Code - Setup and Examples

Purpose

This post demonstrates how to use the Salesforce Developer skill in Claude Code for platform development tasks.

Environment

  • Claude Code CLI (latest)
  • claude-skills plugin installed
  • Salesforce Developer skill activated

What is Salesforce Developer?

The Salesforce Developer skill is a specialized agent within the claude-skills ecosystem that helps with Salesforce platform development tasks. It provides guidance on Apex code, Visualforce, Lightning components, and Salesforce configuration.

When I first encountered this skill, I wanted to understand:

  • When should I invoke it?
  • What types of tasks can it handle?
  • How do I get the most value from it?

The skill exists because Salesforce development has unique patterns and best practices that differ from general web development. Having a specialized agent helps avoid common pitfalls and follow platform conventions.

Installation and Setup

First, ensure you have the claude-skills plugin installed:

Terminal window
# Install claude-skills
npm install -g claude-skills
# Or using the Claude Code skills system
# The skill should already be available in your skills directory

To verify the Salesforce Developer skill is available, I check the skills list:

Terminal window
# In Claude Code
/skills

This shows all available skills including salesforce-developer. The skill activates automatically when I mention Salesforce-related tasks.

Core Usage Patterns

When I work with Salesforce development, I use specific trigger phrases to invoke the skill:

Direct invocation:

"Use salesforce-developer to create an Apex trigger"
"Activate salesforce-developer for this Lightning component"

Contextual activation:

"I need to write a Salesforce Apex class for..."
"How do I implement a Visualforce page for..."
"Create a Lightning Web Component that..."

The skill recognizes these patterns and activates automatically.

Practical Examples

Example 1: Creating an Apex Trigger

When I need to create a trigger, I simply describe the requirement:

"Use salesforce-developer to create an Apex trigger that updates a custom field when an Opportunity is closed."

The skill then provides:

  • Proper trigger handler pattern
  • Best practices for bulkification
  • Governor limit considerations
  • Test class structure

Here’s what the output typically includes:

OpportunityTrigger.trigger
trigger OpportunityTrigger on Opportunity (after update) {
// Handler pattern for best practices
new OpportunityTriggerHandler().onAfterUpdate(Trigger.new, Trigger.oldMap);
}
OpportunityTriggerHandler.cls
public with sharing class OpportunityTriggerHandler {
public void onAfterUpdate(List<Opportunity> newOpps, Map<Id, Opportunity> oldOppsMap) {
// Bulkified processing
List<Opportunity> oppsToUpdate = new List<Opportunity>();
for (Opportunity opp : newOpps) {
Opportunity oldOpp = oldOppsMap.get(opp.Id);
// Check if stage changed to Closed Won
if (opp.StageName != oldOpp.StageName && opp.StageName == 'Closed Won') {
opp.Custom_Field__c = true;
oppsToUpdate.add(opp);
}
}
if (!oppsToUpdate.isEmpty()) {
update oppsToUpdate;
}
}
}

Example 2: Lightning Web Component

When I create LWC components, I use:

"Use salesforce-developer to create a Lightning Web Component that displays account data with wire service."

The skill guides me through:

  • Component structure
  • Wire service usage
  • LDS adapters
  • Metadata configuration

Example output:

accountList.js
import { LightningElement, wire } from 'lwc';
import getAccounts from '@salesforce/apex/AccountController.getAccounts';
export default class AccountList extends LightningElement {
@wire(getAccounts)
accounts;
get hasAccounts() {
return this.accounts && this.accounts.data && this.accounts.data.length > 0;
}
}
accountList.html
<template>
<template if:true={hasAccounts}>
<template for:each={accounts.data} for:item="account">
<div key={account.Id} class="account-item">
<p>{account.Name}</p>
</div>
</template>
</template>
</template>

Example 3: Common Pattern - Bulkification

A key pattern the skill enforces is bulkification. When I write non-bulkified code:

// WRONG - Not bulkified
for (Opportunity opp : Trigger.new) {
Account acc = [SELECT Id FROM Account WHERE Id = :opp.AccountId];
acc.Field__c = opp.Amount;
update acc;
}

The skill immediately corrects this:

// CORRECT - Bulkified
Set<Id> accountIds = new Set<Id>();
for (Opportunity opp : Trigger.new) {
accountIds.add(opp.AccountId);
}
List<Account> accounts = [SELECT Id, Field__c FROM Account WHERE Id IN :accountIds];
Map<Id, Account> accountMap = new Map<Id, Account>(accounts);
for (Opportunity opp : Trigger.new) {
Account acc = accountMap.get(opp.AccountId);
if (acc != null) {
acc.Field__c = opp.Amount;
}
}
update accountMap.values();

Best Practices

DO

  • Use trigger handler pattern: Always separate trigger logic into a handler class
  • Bulkify all operations: Design for batches, not single records
  • Check governor limits: Monitor SOQL queries, DML operations, and heap size
  • Write test classes: Aim for 75%+ code coverage
  • Use proper naming conventions: Follow Salesforce naming standards
  • Handle null checks: Always validate data before processing
  • Use error handling: Implement try-catch blocks with proper logging

DON’T

  • Don’t put logic in triggers: Triggers should only call handler methods
  • Don’t query inside loops: Always bulkify SOQL queries
  • Don’t ignore governor limits: Respect platform constraints
  • Don’t hardcode IDs: Use Custom Settings or Custom Metadata Types
  • Don’t skip testing: Write comprehensive test classes
  • Don’t use without sharing: Explicitly declare sharing model
  • Don’t forget error handling: Always implement proper exception handling

Tips for Maximum Effectiveness

When I work with the Salesforce Developer skill, I follow these practices:

  1. Be specific about requirements: Instead of “create a trigger,” use “create a trigger that updates field X when condition Y occurs”

  2. Provide context: Share your data model and business rules for better solutions

  3. Ask for explanations: Request “why” behind best practices to understand patterns

  4. Request test classes: Always ask for accompanying test code

  5. Iterate on solutions: Refine the output through conversation

Common Scenarios

The skill handles these scenarios effectively:

  • Apex development: Triggers, classes, controllers, batch jobs
  • Visualforce pages: Standard controllers, custom controllers, extensions
  • Lightning components: Aura components, Lightning Web Components
  • Configuration: Flows, validation rules, process builder
  • Integration: REST APIs, SOAP APIs, external services
  • Testing: Unit tests, integration tests, mock data generation

The Salesforce Developer skill works well with complementary skills:

  • security-review: For validating security patterns in Apex code
  • code-review: For reviewing Salesforce code quality
  • test-coverage: For ensuring proper test coverage

For official documentation:

Summary

In this post, I showed how to use the Salesforce Developer skill in Claude Code. The key point is knowing when to invoke it and how to interact with it effectively for platform development tasks. The skill enforces Salesforce best practices like bulkification, proper handler patterns, and governor limit awareness.

Final Words + More Resources

My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments