generating-apex

Generates, refactors, and reviews production-grade Apex classes, triggers, and async jobs.

1|Updated May 7, 2026
One-click install
npx skills add https://github.com/amanpraaj/sf-skill-hub --skill generating-apex-amanpraaj
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: generating-apex
Source: https://github.com/amanpraaj/sf-skill-hub/tree/main/skills/salesforce/generating-apex
Command: npx skills add https://github.com/amanpraaj/sf-skill-hub --skill generating-apex-amanpraaj

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes assets (resource) and references (resource) components.

What problem does it solve? Writing Salesforce Apex that survives governor limits, security reviews, and deployment pipelines is error-prone. This Skill produces bulkified, secure, well-structured Apex classes and triggers with enforced conventions, then validates them with a code analyzer and real test execution before reporting. ## Core Features & Use Cases - Type-Specific Generation: Authors services, selectors, domains, batch, queueable, schedulable, invocable methods, DTOs, utilities, interfaces, exceptions, REST resources, and triggers using matching templates and naming conventions. - Guardrail Enforcement: Applies hard-stop rules such as SOQL/DML outside loops, explicit sharing keywords, bind variables, no @future methods, and CRUD/FLS enforcement via WITH USER_MODE. - Mandatory Validation Loop: Runs a code analyzer on generated .cls files, remediates sev0-sev2 violations, and executes Apex tests before producing a structured report. - Use Case: Ask for an AccountService class that deduplicates accounts; the Skill generates the class, its meta XML, delegates test creation to the generating-apex-test skill, runs the analyzer and tests, and reports results. ## Quick Start Ask the agent to create an Apex service class for your target object, for example: generate an AccountSelector class with a method to query accounts by a set of Ids.

Frequently Asked Questions about generating-apex

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate a bulkified Apex class for Salesforce?▼

Request the class by type and target object, such as an AccountService or AccountSelector. The Skill authors the .cls and .cls-meta.xml files with SOQL and DML outside loops, explicit sharing keywords, and ApexDoc, then generates tests via the generating-apex-test skill.

What Apex class types can this skill create?▼

It supports services, selectors, domains, batch, queueable, schedulable, invocable methods, DTOs, wrappers, utilities, interfaces, abstract classes, custom exceptions, REST resources, triggers, and Trigger Actions Framework classes, each with its own template and naming convention.

Should I use Batch, Queueable, or Schedulable Apex for async work?▼

Use Queueable for standard async work with chaining and non-primitive types, Batch for very large datasets with QueryLocator, and Schedulable only when chaining to Batch or needing complex logic. The Skill's async decision matrix forbids @future in new code.

Does the skill enforce Salesforce security and governor limit rules?▼

Yes. It enforces hard-stop constraints including SOQL/DML outside loops, explicit sharing on every class, bind variables for dynamic SOQL, WITH USER_MODE for CRUD/FLS, no hardcoded IDs, and no System.debug in main code paths.

Why does the skill require running a code analyzer and tests?▼

Writing files is treated as the midpoint, not the finish. The Skill invokes run_code_analyzer to remediate sev0-sev2 violations and executes Apex tests, capturing actual tool output in the final report so unverified code is never reported as complete.

When should I not use this Apex generation skill?▼

Do not use it for test authoring, assertion fixes, or coverage work; those are delegated to the generating-apex-test skill. It also does not handle deployments, metadata describe operations, or Flow and LWC work, which belong to their own skills.