From vanguard-frontier-agentic
Generates production-grade Apex classes with Service-Selector-Domain layering, sharing models, and async patterns (Queueable, Batchable, Schedulable). Static code generation without org connection.
How this skill is triggered — by the user, by Claude, or both
Slash command
/vanguard-frontier-agentic:salesforce-apex-generator-skillThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
T0 static code generation for production-grade Apex. This skill is a **forge**, not a
T0 static code generation for production-grade Apex. This skill is a forge, not a flashlight — it authors correct, deployable Apex with the right sharing model, governor-limit safety, and security defaults for each class type. No org connection required.
Use salesforce-apex-generator-skill when the work requires authoring new Apex code:
Delegate elsewhere when:
| Situation | Skill to use |
|---|---|
| User needs test classes specifically | salesforce-apex-test-generator-skill |
| User wants to run tests against a live org | salesforce-apex-test-runner-skill |
| User is debugging a log file or stack trace | salesforce-apex-log-analyzer-skill |
| User needs to deploy and validate | salesforce-deployment-validator-skill |
| Static code review of existing Apex | salesforce-apex-lwc-code-review-skill |
Before generating, confirm:
Account, Opportunity__c)62.0 minimumsalesforce-apex-test-generator-skillIf the user provides a clear, complete request, generate immediately without unnecessary back-and-forth. Apply defaults (see Rules section) for anything not specified.
Map the request to a class type using the type table below. Set defaults:
with sharing unless type-specific exception appliespublic unless global is requiredConsult references/apex-patterns.md for Service-Selector-Domain conventions,
async patterns, and type-specific templates.
Before writing a single line, verify every constraint in the Rules section would be satisfied. If a constraint would be violated by the user's request, explain the problem and propose the correct approach.
Produce {ClassName}.cls with:
with sharing / without sharing / inherited sharing declaration@future methods — use QueueableProduce {ClassName}.cls-meta.xml using the correct apiVersion and status: Active.
Run the 100-point scoring rubric (see below). If the score is below 80, revise before presenting. Document score and notes in the output.
Always end with an explicit recommendation to generate a companion test class using
salesforce-apex-test-generator-skill, noting the class name and key scenarios to cover.
| Class Type | Sharing Model | Access | Key Rules |
|---|---|---|---|
| Service | with sharing | public | No SOQL/DML in loops; inject Selector |
| Selector | with sharing | public | Returns typed lists; no business logic |
| Domain | with sharing | public | Trigger-context aware; delegates to Service |
| Trigger | N/A (handler delegates) | — | One trigger per object; delegates to Domain/handler |
| Batchable | without sharing or with sharing | public | Implements Database.Batchable; Database.Stateful only if required |
| Queueable | with sharing | public | Implements Queueable; use System.Finalizer for chaining; replaces @future |
| Schedulable | with sharing | public | Implements Schedulable; delegates to Queueable or Batch |
| Invocable | with sharing | public | @InvocableMethod; typed inner request/result classes |
| REST Resource | without sharing (framework handles sharing) | global | @RestResource; @HttpGet/@HttpPost etc. |
| DTO / Wrapper | N/A | public | No methods with side effects; serializable |
| Utility | with sharing | public | Static methods only; no instance state |
| Exception | N/A | public | Extends Exception; no override of getMessage |
| Constraint | Rationale |
|---|---|
| Place all SOQL outside loops | Avoid query governor limit (100 queries per transaction) |
| Place all DML outside loops | Avoid DML statement governor limit (150 per transaction) |
| Declare sharing keyword on every class | Prevent unintended without sharing defaults and data leakage |
| Use Custom Metadata / Labels / describe calls instead of hardcoded Ids | Portability across orgs |
| Always handle exceptions (log, rethrow, or recover) | Prevent silent failures |
| Use bind variables for all dynamic SOQL accepting user input | Prevent SOQL injection |
| Use Apex-native collection types | Prevent compile errors from Java-style types |
Never use @future methods | Use Queueable with System.Finalizer; @future cannot chain or accept non-primitive types |
No System.debug in main code paths | Debug statements consume CPU; use a logging framework |
Security: use WITH USER_MODE on SOQL in classes that touch user-controlled data | Enforces FLS/CRUD at query time |
Apply Security.stripInaccessible when constructing SObjects from user input | Strips fields the user cannot access |
| Type | Pattern | Example |
|---|---|---|
| Service | {SObject}Service | AccountService |
| Selector | {SObject}Selector | AccountSelector |
| Domain | {SObject}Domain | AccountDomain |
| Handler | {SObject}TriggerHandler | AccountTriggerHandler |
| Batch | {Purpose}Batch | AccountDeduplicationBatch |
| Queueable | {Purpose}Queueable | OrderEventQueueable |
| Schedulable | {Purpose}Scheduler | NightlyCleanupScheduler |
| DTO | {Purpose}Dto or {Purpose}Wrapper | OrderResponseDto |
Score the generated class before presenting. Threshold: 80+ pass, 60–79 caveat with explanation, below 60 revise before presenting.
| Dimension | Points | What earns full marks |
|---|---|---|
| Sharing model correctness | 25 | Every class has an explicit sharing declaration; with sharing is used wherever FLS/CRUD enforcement is appropriate; without sharing is justified with a comment |
| Governor-limit safety | 25 | No SOQL in loops; no DML in loops; bulkified with List/Map patterns; Collections used correctly |
| Security defaults | 20 | WITH USER_MODE or Security.stripInaccessible applied where appropriate; no hardcoded Ids or credentials; no SOQL injection vectors |
| Naming conventions | 15 | Class and method names follow conventions table; ApexDoc present; XML meta generated |
| Test class recommendation | 15 | Companion test class explicitly recommended with key scenarios listed |
Scoring penalties:
@future used instead of Queueable: -10This skill operates exclusively at T0 — static generation only.
sf CLI calls, no MCP tool calls, no live query or execution.salesforce-apex-test-generator-skill for
test authoring, then salesforce-apex-test-runner-skill (T1) for execution, then
salesforce-deployment-validator-skill (T2) for sandbox dry-run before any deployment.Stop and do not generate if:
without sharing on a user-data class.@future — explain the Queueable alternative and generate Queueable
instead unless the user explicitly overrides with a documented reason.verdict: "pass | caveat | reject"
quality_score: <0-100>
quality_notes: "<scoring rationale>"
generated_files:
- path: "{ClassName}.cls"
content: |
<apex code>
- path: "{ClassName}.cls-meta.xml"
content: |
<meta xml>
sharing_model_used: "with sharing | without sharing | inherited sharing"
sharing_model_rationale: "<why this model was chosen>"
governor_limit_notes: "<any limit-adjacent patterns noted>"
security_notes: "<WITH USER_MODE / stripInaccessible usage>"
test_class_recommendation:
companion_skill: "salesforce-apex-test-generator-skill"
class_to_test: "{ClassName}"
key_scenarios:
- "<positive path>"
- "<negative/exception path>"
- "<bulk path (200+ records)>"
assumptions:
- "<list of assumptions made>"
missing_context:
- "<what the user should provide to improve the output>"
| Output | Hand off to |
|---|---|
| Generated Apex needing test class | salesforce-apex-test-generator-skill |
| Generated Apex ready for test execution | salesforce-apex-test-runner-skill (T1) |
| Ready for sandbox validation | salesforce-deployment-validator-skill (T2) |
| Code review of existing/generated Apex | salesforce-apex-lwc-code-review-skill |
Stop and do not continue if:
with sharing
is the default; without sharing only where explicitly required by class type (REST resource,
certain batch contexts) and documented.WITH USER_MODE, Security.stripInaccessible, and
bind variables are applied by default to all user-data-touching code.| File | When to read |
|---|---|
references/apex-patterns.md | Service-Selector-Domain pattern, sharing models, async patterns, type templates |
references/governor-limits.md | Governor limit values, bulkification strategies, async fallback patterns |
references/security-defaults.md | WITH SHARING default policy, USER_MODE, stripInaccessible, no hardcoded credentials |
npx claudepluginhub raishin/vanguard-frontier-agentic --plugin vanguard-frontier-agenticGenerates, refactors, and reviews Apex classes including service, selector, domain, triggers, batch, queueable, and REST resources. Includes test generation.
Enforces Apex code quality guardrails: bulk-safety, sharing model, CRUD/FLS, SOQL injection prevention, and PNB test coverage. Use when reviewing or generating Apex classes, triggers, batch jobs, or test classes.
Provides patterns for Salesforce development including LWC, Apex, REST APIs, and Salesforce DX with scratch orgs and 2GP.