apex-patterns

Design enterprise patterns for Salesforce Apex codebases.

2|Updated Mar 18, 2026
One-click install
npx skills add https://github.com/bhanu91221/claude-sfdx-iq --skill apex-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: apex-patterns
Source: https://github.com/bhanu91221/claude-sfdx-iq/tree/main/skills/apex-patterns
Command: npx skills add https://github.com/bhanu91221/claude-sfdx-iq --skill apex-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Designing scalable and testable Salesforce Apex applications by applying established enterprise patterns to separate concerns and manage governor limits.

Core Features & Use Cases

  • Service, Selector, Domain, Factory, and Strategy layers to structure business logic and data access.
  • Guidance and templates for implementing fflib-inspired patterns across triggers, schedulers, and batch jobs.
  • Real-world scenarios: modularizing complex business rules, improving testability, and enforcing consistent architecture.

Quick Start

Describe your Apex design goal and I will outline the corresponding Service, Selector, Domain, Factory, and Strategy patterns to apply.

Frequently Asked Questions about apex-patterns

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

FAQPage Schema
How do I design Apex code to separate business logic and data access?

To design Apex code with separated business logic and data access, apply layered architecture using Service, Selector, and Domain patterns to modularize rules and ensure scalable, testable code.

What are the fflib design patterns for Salesforce Apex?

fflib design patterns for Apex provide a framework for Service, Selector, Domain, Factory, and Strategy layers, enabling modular, testable architectures across triggers, schedulers, and batch jobs.

How do I structure an Apex trigger to handle complex business rules?

Structure Apex triggers by delegating complex business rules to a Service layer, using a Domain pattern for validation and defaulting, which keeps triggers thin, modular, and testable.

Does layered architecture work for Apex batch jobs and schedulers?

Layered architecture works for Apex batch jobs and schedulers by applying Service and Selector layers to batch execution, ensuring consistent data access, modular logic, and governor limit management.

Why does my Apex application hit governor limits in complex triggers?

Apex applications hit governor limits in complex triggers when data access is unstructured; applying a Selector layer centralizes SOQL queries, while a Service layer manages transactional logic efficiently.

What is the best way to improve Apex unit test coverage and maintainability?

The best way to improve Apex unit test coverage and maintainability is adopting enterprise design patterns like Service and Domain layers, which isolate business logic for predictable, testable outcomes.