Skip to content

forcedotcom/sf-skills / plugins/builder/salesforce-development/skills/platform-apex-generate

platform-apex-generate

Verified

Primary 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.

assets/exception.cls

View on GitHub
/**
 * Custom exception for {describe when this exception is thrown}.
 *              Use this exception to signal domain-specific errors that callers
 *              can catch and handle distinctly from system exceptions.
 *
 * @example
 * throw new {ClassName}('Account merge failed: duplicate detected.');
 *
 * // Wrap a caught exception
 * try {
 *     // ... risky operation
 * } catch (DmlException e) {
 *     throw new {ClassName}('DML failed during account merge: ' + e.getMessage());
 * }
 */
public with sharing class {ClassName} extends Exception {
    // Apex custom exceptions automatically inherit:
    //   - getMessage()
    //   - getCause()
    //   - getStackTraceString()
    //   - setMessage(String)
    //   - initCause(Exception)
    //
    // And support these constructor patterns:
    //   - new {ClassName}()
    //   - new {ClassName}('message')
    //   - new {ClassName}(causeException)
    //   - new {ClassName}('message', causeException)
    //
    // Note: Apex does NOT support custom constructors on Exception subclasses.
    // To add context, use the message string or create a wrapper pattern:
    //
    // Example wrapper pattern (if you need structured error data):
    //
    // public class {ClassName}Detail {
    //     public String errorCode;
    //     public List<Id> failedRecordIds;
    //     public String detail;
    //
    //     public {ClassName}Detail(String errorCode, List<Id> failedRecordIds, String detail) {
    //         this.errorCode = errorCode;
    //         this.failedRecordIds = failedRecordIds;
    //         this.detail = detail;
    //     }
    //
    //     public override String toString() {
    //         return '[' + errorCode + '] ' + detail + ' (Records: ' + failedRecordIds + ')';
    //     }
    // }
}
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: 322kUpdated Claude CodeCodexVerifiedInstall
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: 198kUpdated Claude CodeCodexVerifiedInstall
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: 198kUpdated Claude CodeCodexVerifiedInstall
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: 198kUpdated Claude CodeCodexVerifiedInstall