sf-trigger-frameworks

Centralize Salesforce Apex trigger logic with recursion control and bypass mechanisms.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Centralizes trigger logic and prevents common failure modes in Salesforce Apex triggers such as recursion, uncontrolled side-effects, and scattered business logic across multiple triggers, making triggers predictable and maintainable during development, refactoring, and data migrations.

Core Features & Use Cases

  • Pragmatic TriggerHandler Pattern: A dependency-free base class with context-aware routing, bypass registry, and execution depth control to avoid recursion.
  • FFLIB Domain Layer Support: Guidance for adopting fflib_SObjectDomain patterns where the org uses Apex Commons.
  • TDTM / CMDT Dispatcher: Table-driven registration of handlers using Custom Metadata for runtime enable/disable and ordered execution.
  • Bypass & Migration Strategies: Static, framework-level, and declarative bypass options for migrations and bulk data loads plus a migration checklist for converting bare triggers to handler-based frameworks.
  • Recursion Prevention & Testing: Static processed-id sets and depth counters, with testing notes on static variable lifetime and example test patterns.

Quick Start

Analyze the Account trigger and provide a migration plan to a handler-based framework including bypass and recursion controls.

Frequently Asked Questions about sf-trigger-frameworks

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

FAQPage Schema
How do I prevent recursion in Salesforce Apex triggers?

Prevent Apex trigger recursion by using static processed-id sets and execution depth counters within a centralized trigger handler base class. This routes context-aware logic safely and stops uncontrolled side effects during bulk operations.

How do I consolidate multiple triggers on one Salesforce object into a single handler?

Consolidate multiple triggers by migrating bare triggers to a centralized handler-based framework. Use a migration checklist to enforce one-trigger-per-object routing, applying bypass mechanisms for safe data loads during the transition.

Does this Apex trigger framework support FFLIB and TDTM dispatchers?

Yes, the framework supports FFLIB Domain Layer patterns for Apex Commons organizations and TDTM CMDT-based dispatchers. Table-driven custom metadata registration enables runtime enable/disable and ordered handler execution.

What is the best way to bypass Apex triggers during data migrations?

The best way to bypass Apex triggers during migrations is using framework-level and declarative bypass mechanisms. Static, framework-level, and declarative options disable handlers safely for bulk data loads without altering core code.

Why do static variables fail to prevent Apex trigger recursion in some test scenarios?

Static variable lifetime between test executions can cause recursion prevention to fail if not properly reset. Test patterns must account for static processed-id sets clearing between DML operations to ensure depth counters function correctly.