sf-apex-enterprise-patterns

Implement scalable Salesforce patterns for centralized SOQL, separated logic, and atomic DML transactions.

13|2|Updated Mar 18, 2026
One-click install
npx skills add https://github.com/jiten-singh-shahi/salesforce-claude-code --skill sf-apex-enterprise-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sf-apex-enterprise-patterns
Source: https://github.com/jiten-singh-shahi/salesforce-claude-code/tree/main/.cursor/skills/sf-apex-enterprise-patterns
Command: npx skills add https://github.com/jiten-singh-shahi/salesforce-claude-code --skill sf-apex-enterprise-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Centralizes SOQL, separates business logic, and enforces atomic DML boundaries to reduce duplicated trigger logic, improve testability, and make growing Apex codebases maintainable as teams and class counts increase.

Core Features & Use Cases

  • Selector Layer: Centralize queries for each object to remove ad-hoc SOQL from business logic.
  • Domain Layer: Encapsulate record-level business rules and trigger behavior for easier testing and reuse.
  • Service & Unit of Work: Orchestrate cross-object processes, own transaction boundaries, and commit DML atomically using a Unit of Work pattern; supports either FFLIB or lightweight implementations.
  • Use Case: Migrate complex trigger logic into Domain classes and implement Services that coordinate Create/Update operations across Account and Opportunity records with a single atomic commit.

Quick Start

Use the sf-apex-enterprise-patterns guidance to review your Salesforce codebase and recommend Selector, Domain, Service, and Unit of Work structure for Accounts and Opportunities.

Frequently Asked Questions about sf-apex-enterprise-patterns

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

FAQPage Schema
How do I separate business logic in Apex to manage growing codebases?

You can separate business logic in Apex by implementing enterprise patterns like the Domain layer for record rules and the Service layer for orchestration, ensuring growing codebases remain maintainable and testable.

What is the best way to centralize SOQL queries in Salesforce Apex?

The best way to centralize SOQL queries in Salesforce Apex is by using a Selector layer, which removes ad-hoc queries from business logic and promotes reuse across your application.

How do I manage atomic DML transactions across multiple objects in Apex?

You manage atomic DML transactions across multiple objects in Apex by applying the Unit of Work pattern, which owns transaction boundaries and commits cross-object operations like Account and Opportunity updates together.

When do I need enterprise patterns for Apex trigger logic?

You need enterprise patterns for Apex trigger logic when your Salesforce project grows beyond a handful of developers or classes, encounters complex trigger logic, or requires multi-object orchestration like upgrades and service workflows.

Can I use FFLIB with lightweight Apex enterprise patterns?

Yes, you can use FFLIB with lightweight implementations; the architecture supports both FFLIB and lightweight Unit of Work integration to ensure transaction safety and testability without requiring a strict framework dependency.

Why should I migrate complex trigger logic into Domain classes?

Migrating complex trigger logic into Domain classes encapsulates record-level business rules, making trigger behavior easier to test, reuse, and maintain while reducing duplicated logic across your Apex codebase.