grzmol/vibe-force/sf-fflib-operations
Claude Code and agent skill by grzmol/vibe-force
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Covers running fflib Apex Enterprise Patterns in a real delivery pipeline - trigger inventory and one-trigger-per-object dispatch, bypass and kill-switch design with custom permissions and custom metadata, feature flags that swap Application factory bindings, Queueable with Finalizer and Batch runners that call services with per-chunk Unit of Work commits, platform-event publishing and subscriber domains, callout ordering around commitWork, large-data-volume tuning, structured logging and correlation ids, packaging and deployment ordering for fflib-apex-mocks and fflib-apex-common, Code Analyzer rules that misfire on fflib, PR review checklists and the fflib version-upgrade runbook. Use this skill when auditing triggers in an fflib org, adding a bypass switch, running fflib code from Batch or Queueable, packaging or upgrading fflib, tuning Code Analyzer for fflib, or reviewing an fflib pull request.
Install
npx vskill@latest install grzmol/vibe-force/sf-fflib-operationsSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as majiayu000/claude-skill-registry/sf-fflib-operations.
fflib Operations
Everything around the fflib write path: dispatch inventory, switches, async, bulk, observability, packaging, analysis and upgrades. The layer semantics themselves are in skill sf-fflib-domain-service-uow; the factories in skill sf-fflib-foundations.
Grounded in apex-enterprise-patterns/fflib-apex-common master @ dab59777bac37f6b8a3cc2871fcf5df8d37764b4, fflib-apex-common-samplecode master @ 4657d63, and fflib-apex-mocks master (raw file reads, see References).
When to use
| Situation | Use this skill | |
|---|---|---|
| Auditing which objects have triggers and which are fflib-dispatched | Yes | |
| Adding an admin-visible bypass for a data load or an incident | Yes | |
| Running an fflib service from Batch, Queueable or Schedulable | Yes | |
| Packaging fflib as an unlocked package, or bumping the fflib version | Yes | |
Tuning code-analyzer.yml because PMD flags every selector | Yes | |
| Writing a domain, service or Unit of Work | No - skill sf-fflib-domain-service-uow | |
| Writing selector queries | No - skill sf-fflib-selector-layer | |
| Writing the tests | No - skill sf-fflib-testing |
Quick reference
| Concern | Mechanism | Where it lives | |
|---|---|---|---|
| Trigger dispatch | fflib_SObjectDomain.triggerHandler(X.class) | One trigger per object | |
| Per-user / per-integration bypass | Custom permission read with FeatureManagement.checkPermission | Checked in one BypassService | |
| Admin-tunable, deployable toggle | Custom metadata __mdt read with getInstance / getAll | No SOQL cost | |
| Implementation swap | Application.Service binding chosen from custom metadata | Factory construction | |
| Async service run | Queueable + System.Finalizer, or Batch with a selector QueryLocator | references/async-and-bulk.md | |
| Reliable event emission | uow.registerPublishAfterSuccessTransaction(...) | Service | |
| Deployment ordering | apex-mocks, then apex-common, then app code | references/packaging-and-deployment.md |
Core patterns
1. Trigger inventory and dispatch strategy
An fflib org has exactly one trigger per object, and that trigger does nothing but dispatch. Inventory the org before changing anything:
| Finding | Action | |
|---|---|---|
| Two triggers on one object | Merge into one; a second trigger re-enters the dispatcher with a different record set and breaks stateful domains | |
| Trigger with inline logic | Move the body into a domain override, leave the dispatch line | |
| Legacy handler framework alongside fflib | Migrate object by object; during the transition, the single trigger calls the legacy handler and fflib_SObjectDomain.triggerHandler, in that order, so ordering stays deterministic | |
| Record-triggered Flow doing the same work | Decide one owner per rule; Flows and Apex triggers interleave by order of execution, not by intent (skill sf-flow-automation) |
2. Bypass and kill switches
fflib_SObjectDomain.getTriggerEvent(...) is transaction-scoped Apex state - useful inside a job, useless as an operational switch. Operational switches need a single, testable read point:
__mdt.getInstance(...) and getAll() read from the metadata cache and do not consume SOQL queries; only the first 255 characters of any field are returned (Custom metadata types methods). Full implementations with tests, plus the data-load bypass used with sf data import bulk (skill sf-data-management): references/bypass-and-feature-flags.md.
3. Feature flags that swap factory bindings
fflib makes a feature flag a binding change rather than an if scattered through the code:
Both implementations stay deployed and tested; the switch is metadata. Rollback is a metadata deploy, not a code revert.
4. Async runners
Rules that do not change:
| Rule | Reason | |
|---|---|---|
| The async class is a shell; it calls a service | Business logic stays testable synchronously | |
| One Unit of Work per chunk / per Queueable execution | Each is its own transaction; a UoW cannot cross them | |
| Never pass a UoW or a domain instance into a Queueable | SObject references have no committed context in the next transaction | |
| Idempotency key on every chunk | Batch chunks can be retried by the platform | |
| Finalizer for failure handling and retry | Runs in its own transaction, so it can call out after the job did DML |
System.attachFinalizer accepts one finalizer per Queueable execution; the finalizer runs in a separate Apex and database transaction, and a failing job can be re-enqueued from a finalizer at most five consecutive times (Transaction finalizers). Batch, chunking and idempotency keys: references/async-and-bulk.md and skill sf-async-apex-patterns.
5. Platform events and integration flows
Publish through the Unit of Work so emission is tied to commit outcome, and subscribe with an ordinary fflib domain over the __e records:
Use the two-argument super(records, SObjectType) constructor: an empty __e batch cannot infer its type. Replay, retry and high-volume subscriber concerns: skill sf-integration-patterns.
6. Callouts and commitWork()
Apex forbids a callout after uncommitted DML in the same transaction. commitWork() is DML, so:
| Order | Verdict | |
|---|---|---|
Callout, then register, then commitWork() | Correct | |
commitWork(), then callout in the same transaction | Throws You have uncommitted work pending | |
commitWork(), then callout from a Queueable or a Finalizer | Correct - separate transaction | |
Callout inside an IDoWork registered with registerWork | Wrong - doWork() runs inside the commit, after DML |
Mocking the gateway: skill sf-fflib-testing; named credentials and retry: skill sf-integration-patterns.
7. Large data volumes
| Cost | Measurement | Mitigation | |
|---|---|---|---|
| Domain instantiation per chunk | fflib_SObjectDomain copies the record list and describes the SObject once per construction | One domain instance per chunk, never per record | |
| Selector field list breadth | Heap grows with fields x rows | Narrow selector methods for bulk jobs (skill sf-fflib-selector-layer) | |
| UoW DML statements | 1 savepoint + 1 per non-empty type per operation | One commitWork() per chunk | |
| Relationship resolution | Iterates registered relationships per type | Register parents and children in one pass | |
| Trigger re-entry during commit | Each UoW insert fires the target object's trigger | Bypass the sub-object's domain for the job when the job already owns that logic |
Batch scope for fflib work starts at 200 and comes down only with evidence; profile with a debug log before changing it (skill sf-debugging-logs). Limit arithmetic: skill sf-governor-limits; query shape: skill sf-soql-sosl-optimization.
Bypassing the framework for a bulk job is legitimate when the job is a pure data movement with no business rules - document the decision in the job class header and keep the bypass narrow.
8. Observability
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/sf-fflib-operations/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/grzmol/vibe-force/sf-fflib-operations)