sf-fflib-operations

Operate fflib Apex Enterprise Patterns across triggers, async jobs, packaging, and deployment pipelines.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Running fflib Apex Enterprise Patterns in a real Salesforce delivery pipeline raises operational questions the framework docs do not answer: how to inventory and consolidate triggers, add admin-controllable bypass switches, run services from Batch or Queueable without breaking Unit of Work semantics, order callouts around commitWork, package and upgrade fflib, and tune Code Analyzer rules that misfire on fflib code. ## Core Features & Use Cases - Trigger inventory and dispatch: Audit orgs for one-trigger-per-object compliance and merge conflicting triggers or legacy handler frameworks into fflib dispatch. - Bypass switches and feature flags: Implement custom metadata and custom permission kill switches with a single cached BypassService, plus feature flags that swap Application factory bindings. - Async and bulk execution: Run fflib services from Queueable with System.Finalizer or Batch with per-chunk Unit of Work commits, idempotency keys, and LDV tuning. - Packaging, analysis, and upgrades: Deploy in the fixed apex-mocks then apex-common then app order, scope Code Analyzer suppressions for fflib false positives, and follow the fflib version-upgrade runbook. - Use Case: Before a bulk data load, assign a session-activated bypass permission set, verify the switch is live with anonymous Apex, run the load, then remove the assignment and execute a reconciliation job. ## Quick Start Ask the assistant to audit the triggers in your fflib org and add a custom-metadata bypass switch for the Opportunity domain.

Frequently Asked Questions about sf-fflib-operations

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

FAQPage Schema
How do I add a bypass switch to fflib triggers in Apex?

Create a custom metadata type with Disabled and CustomPermission fields, then read it through a single BypassService class using getInstance and FeatureManagement.checkPermission with a static transaction cache. Check the switch once at the top of each domain override, never inside a record loop.

How do I run an fflib service from Batch or Queueable?

Keep the async class as a thin shell that calls the service, and commit one Unit of Work per chunk or Queueable execution since each is its own transaction. Never pass a UoW or domain instance into a Queueable, and attach a System.Finalizer for failure handling and retry.

Why does my Apex callout fail after fflib commitWork?

Apex forbids callouts after uncommitted DML, and commitWork is DML, so a callout in the same transaction throws uncommitted work pending. Perform the callout first, then register and commit, or move the callout into a Queueable or Finalizer running in a separate transaction.

What is the deployment order for fflib-apex-mocks and fflib-apex-common?

Deploy fflib-apex-mocks first, then fflib-apex-common, then application code, since the dependency order is fixed. Vendored fflib test classes inflate the org coverage denominator, so exclude them from the package directory or account for them in the coverage gate.

Why does Code Analyzer flag fflib selectors and domains?

Code Analyzer misfires predictably on fflib: ApexCRUDViolation on selectors enforcing access through fflib_SObjectSelector, FLS violations on writes routed through a custom IDML, and sharing violations on inherited sharing domains. Scope suppressions to the framework path only, never the whole workspace.

When should I bypass the fflib framework for a bulk job?

Bypassing fflib is legitimate only when the job is pure data movement with no business rules. Document the decision in the job class header, keep the bypass narrow, and run a reconciliation job afterward for any automation side effects that were skipped.