forcedotcom/sf-skills / plugins/builder/salesforce-development/skills/platform-apex-generate
platform-apex-generate
VerifiedPrimary Apex authoring skill for class generation, refactoring, and review. ALWAYS ACTIVATE when the user mentions Apex, .cls, triggers, or asks to create/refactor a class (service, selector, domain, batch, queueable, schedulable, invocable, DTO, utility, interface, abstract, exception, REST resource). Use this skill for requests involving SObject CRUD, mapping collections, fetching related records, scheduled jobs, batch jobs, trigger design, @AuraEnabled controllers, @RestResource endpoints, custom REST APIs, or code review of existing Apex.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 22.0 KB |
| assets/abstract.cls | other | 5.1 KB |
| assets/batch.cls | other | 4.8 KB |
| assets/domain.cls | other | 4.1 KB |
| assets/dto.cls | other | 3.5 KB |
| assets/exception.cls | other | 1.8 KB |
| assets/interface.cls | other | 747 B |
| assets/invocable.cls | other | 4.0 KB |
| assets/queueable.cls | other | 3.5 KB |
| assets/rest-resource.cls | other | 11.4 KB |
| assets/schedulable.cls | other | 2.5 KB |
| assets/selector.cls | other | 3.4 KB |
| assets/service.cls | other | 2.8 KB |
| assets/trigger.cls | other | 1.7 KB |
| assets/utility.cls | other | 3.4 KB |
| references/AccountDeduplicationBatch.cls | other | 5.8 KB |
| references/AccountSelector.cls | other | 6.3 KB |
| references/AccountService.cls | other | 7.8 KB |
assets/utility.cls
View on GitHub/**
* Utility class for {describe the category of utilities: String, Date, Collection, etc.}.
* All methods are static and side-effect-free (no SOQL, no DML).
* Private constructor prevents instantiation.
*/
public with sharing class {ClassName} {
// ─── Private Constructor ─────────────────────────────────────────────
/**
* Prevents instantiation — use static methods only
*/
@TestVisible
private {ClassName}() {
// Utility class — do not instantiate
}
// ─── Public Methods ──────────────────────────────────────────────────
// TODO: Add utility methods below. Examples:
/**
* Safely converts a String to an Integer, returning a default if parsing fails
* @param value The String to parse
* @param defaultValue The fallback value if parsing fails
* @return The parsed Integer or the default value
* @example
* Integer result = {ClassName}.safeParseInteger('42', 0); // returns 42
* Integer result = {ClassName}.safeParseInteger('abc', 0); // returns 0
*/
public static Integer safeParseInteger(String value, Integer defaultValue) {
if (String.isBlank(value)) {
return defaultValue;
}
try {
return Integer.valueOf(value.trim());
} catch (TypeException e) {
return defaultValue;
}
}
/**
* Chunks a list into smaller sublists of the specified size.
* Useful for processing records in governor-limit-safe batches.
* @param items The list to chunk
* @param chunkSize The maximum size of each chunk
* @return A list of sublists, each containing up to chunkSize elements
* @example
* List<List<String>> chunks = {ClassName}.chunkList(myList, 200);
*/
public static List<List<Object>> chunkList(List<Object> items, Integer chunkSize) {
List<List<Object>> chunks = new List<List<Object>>();
if (items == null || items.isEmpty() || chunkSize <= 0) {
return chunks;
}
List<Object> currentChunk = new List<Object>();
for (Object item : items) {
currentChunk.add(item);
if (currentChunk.size() == chunkSize) {
chunks.add(currentChunk);
currentChunk = new List<Object>();
}
}
if (!currentChunk.isEmpty()) {
chunks.add(currentChunk);
}
return chunks;
}
/**
* Extracts a Set of non-null field values from a list of SObjects
* @param records The SObject records to extract from
* @param fieldName The API name of the field to extract
* @return A Set of non-null String values
* @example
* Set<String> emails = {ClassName}.pluckStrings(contacts, 'Email');
*/
public static Set<String> pluckStrings(List<SObject> records, String fieldName) {
Set<String> values = new Set<String>();
if (records == null || String.isBlank(fieldName)) {
return values;
}
for (SObject record : records) {
Object val = record.get(fieldName);
if (val != null) {
values.add(String.valueOf(val));
}
}
return values;
}
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |