Getting started with APX
apx is a Salesforce CLI plugin that generates Apex Enterprise Patterns
(fflib/at4dx) code — Domain, Selector, Service, and Unit of Work artifacts —
from a described SObject. This guide walks through your first generation run.
Install
sf plugins install @syntax-syllogism/apx@x.y.zOr build from source (see Contributing):
git clone git@github.com:jprichter/apxcd apxyarn && yarn buildnode ./bin/dev.js apx generate --helpConcepts
Most org-backed apx generate commands need two things:
- A flavor — exactly one of
--at4dxor--fflib. These are mutually exclusive; you must pick one. The flavor selects which template set is rendered (interface/implementation shape, binding metadata format, base class references) for every artifact the command produces. - A target — org-backed commands describe a live SObject via
--target-org+--sobjectto pull real field names and custom/standard-object status. The AT4DX-onlyaction,criteria,selector method, andselector field-injectioncommands work offline with an SObject API name as a string.servicealso works offline, using--service-basenameinstead of an SObject target.
All commands support --dry-run (render and validate without writing files)
and --output-path (defaults to generated-files, relative to the Salesforce
project root).
Your first generation run
Generate a full selector for Account in AT4DX style:
sf apx generate selector --target-org myOrg --sobject Account --at4dxThis describes Account against myOrg, then writes a selector interface,
implementation, unit test, and (for AT4DX) a SelectorConfig binding custom
metadata record under generated-files/.
Preview first with --dry-run if you want to see what would be written
without touching disk:
sf apx generate selector --target-org myOrg --sobject Account --at4dx --dry-run --jsonIf you prefer a guided flow, add -i/--interactive. APX prompts for values
that were not supplied, shows a summary, and requires confirmation before it
writes anything:
sf apx generate selector -i --target-org myOrg --sobject AccountSee Interactive generation for prompt coverage, confirmation behavior, and the TTY requirement.
Generating multiple layers at once
The bare apx generate command builds several artifact groups from a single
SObject describe, so you only pay for one API round-trip:
sf apx generate --target-org myOrg --sobject Account \ --selector --domain --unit-of-work --at4dxAt least one of --selector, --domain, --unit-of-work is required — the
command errors out if none are set. See
Aggregate generation
for exactly how binding sequence and prefix apply across the combined plan.
Offline scaffolding
Some artifacts don’t need an org at all:
# Action class + AT4DX domain-process binding, entirely offlinesf apx generate action -s Account -c DefaultAccountSloganBasedOnNameAction
# Field-injection fieldset + binding for an existing selectorsf apx generate selector field-injection -s Account --fields Name,IndustrySee Offline domain-process generation
for how --trigger-operation, --order, and --process-name combine to
build the binding’s developer name.
Next steps
- Command details — flavor selection, naming/prefix rules, binding sequence, domain-process metadata, dry-run/overwrite semantics.
- Full CLI reference: see the Commands section of
the README, or run any command with
--help.