sf-apex-development

Writes and reviews production Salesforce Apex classes, triggers, and services with API 67.0 security defaults.

2|Updated Sep 12, 2026
One-click install
npx skills add https://github.com/grzmol/vibe-force --skill sf-apex-development-grzmol
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sf-apex-development
Source: https://github.com/grzmol/vibe-force/tree/main/skills/sf-apex-development
Command: npx skills add https://github.com/grzmol/vibe-force --skill sf-apex-development-grzmol

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing Salesforce Apex that survives deployment requires juggling sharing keywords, user-mode versus system-mode access, bulkification, trigger frameworks, and partial-success DML handling — and API 67.0 changed the defaults, invalidating older patterns like WITH SECURITY_ENFORCED. This Skill encodes those rules so generated or reviewed Apex is secure, bulkified, and gate-compliant from the start. ## Core Features & Use Cases - Security-correct Apex by default: Enforces explicit sharing declarations (with/without/inherited sharing) and explicit access modes (WITH USER_MODE, insert as user, AccessLevel) aligned with API 67.0 behavior changes. - Trigger framework and bulkification patterns: Provides a runnable one-trigger-per-object handler framework with recursion guards, bypass registry, and map-driven bulkified idioms that eliminate SOQL/DML in loops. - Enterprise layering and integration surfaces: Includes dependency-free Selector, Domain, Service, and Unit of Work implementations plus @AuraEnabled(cacheable=true) contracts for LWC and @RestResource services. - Use Case: When asked to add a second trigger to an object or refactor a class flagged by vf-check analyzer for ApexSharingViolations, the Skill restructures the code into a single trigger with a declared handler class and user-mode queries. ## Quick Start Ask the assistant to create or review an Apex class or trigger under force-app, for example to build a bulkified Case escalation service with a trigger handler and explicit sharing.

Frequently Asked Questions about sf-apex-development

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

FAQPage Schema
How do I write a bulkified Apex trigger in Salesforce?

Use exactly one trigger per object containing only a handler call, and put all logic in a handler class. Query related records once into a Map keyed by Id, accumulate changes in lists, and perform a single DML statement per object — never SOQL or DML inside loops.

What is the difference between with sharing, without sharing, and inherited sharing in Apex?

with sharing enforces record-level sharing rules, without sharing bypasses them, and inherited sharing resolves at runtime based on the caller. From API 67.0 a class with no declaration runs with sharing; triggers always run without sharing and cannot carry a declaration.

Does WITH SECURITY_ENFORCED still work in API 67.0 Apex?

No. From API 67.0, WITH SECURITY_ENFORCED is rejected at compile time in Apex SOQL. Replace it with WITH USER_MODE, AccessLevel.USER_MODE on Database methods, or insert as user / update as user for DML.

How do I handle partial success with Database.insert in Apex?

Call Database.insert(list, false, AccessLevel.USER_MODE) and iterate the returned SaveResult array, reading getErrors() for each failed row. Note the platform retries up to three times on the shrinking subset and static variables are not reset between retries.

Why does my Apex trigger run twice for a single record update?

A workflow field update causes before-update and after-update triggers to re-fire exactly once more, and Trigger.old in the second pass holds the pre-update value. Make handlers idempotent using an Id-set recursion guard keyed by operation.

When should I use @AuraEnabled(cacheable=true) for LWC?

Use cacheable=true on read-only methods called via @wire from Lightning web components; the method must not perform DML. For mutations, drop cacheable and wrap DmlException errors in AuraHandledException so no stack trace leaks to the client.