Skip to content

CLI reference

Every apx command with its usage, flags and examples, generated from the oclif command metadata.

sf apx dead

Find Apex classes in an org that nothing references.

Usage

Terminal window
sf apx dead -o <value> [--json] [--flags-dir <value>] [-c] [--dead-only --destructive-manifest] [--include-suppressed] [--ignore <value>...] [-a <value>] [-p <value>] [--dry-run]

Flags

-a, --api-version <value>

Override the API version used for the org connection.

Override the api version used for api requests made by this command

-c, --classes

Find Apex classes that have no inbound metadata dependencies.

-o, --target-org <value> · required

Target org username or alias.

-p, --output-path <value>

Output folder relative to the Salesforce project root.

Default: generated-files

--dead-only

Limit the manifest to unreferenced classes, excluding test-only classes and their tests.

--destructive-manifest

Write a destructive-changes manifest for the classes found. Does not modify the org.

--dry-run

Report the destructive manifest paths without writing files.

--ignore <value>...

Class-name pattern to exclude from results. Supports *. Repeatable.

--include-suppressed

Also report classes suppressed as entry points, test classes, or DI-bound.

Global flags

--flags-dir <value>

Import flag values from a directory.

--json

Format output as json.

Description

Uses the Tooling API Dependency API (MetadataComponentDependency) to find unmanaged Apex classes with no inbound metadata references.

AT4DX dependency-injection bindings are resolved: classes named in ApplicationFactory_ServiceBinding__mdt, ApplicationFactory_SelectorBinding__mdt, ApplicationFactory_DomainBinding__mdt, or DomainProcessBinding__mdt are treated as live, because nothing references an injected implementation directly. Implementations with no binding are still reported, which is usually what you are looking for.

Analysis repeats over the surviving graph until nothing new becomes dead, so an entire abandoned subsystem is found in one run; the round each class was found in is reported.

Classes referenced only by their own tests are paired with those tests so both are removed together. When a test also covers surviving code, the class and its test are both retained and reported, because removing the class without its test would break the deployment.

Test classes and recognized entry points are suppressed by default. Entry points include @RestResource and global classes, webservice methods, and members annotated with @AuraEnabled, @InvocableMethod, @RemoteAction, @NamespaceAccessible, @InvocableVariable, @HttpGet, @HttpPost, @HttpPut, @HttpPatch, or @HttpDelete. Classes implementing Database.Batchable, System.Schedulable, System.Queueable, Messaging.InboundEmailHandler, System.Callable, Process.Plugin, Auth.RegistrationHandler, Database.RaisesPlatformEvents, System.Comparator, System.Iterable, or System.Iterator are also suppressed.

Class names held as strings outside the known binding objects — Type.forName, System.schedule from anonymous Apex, bespoke config tables — remain invisible. Always review results before deploying a destructive change.

Examples

List classes nothing references:

Terminal window
sf apx dead --target-org myOrg --classes

Include suppressed entry points and DI-bound classes in the report:

Terminal window
sf apx dead --target-org myOrg --classes --include-suppressed

Write a destructive manifest for the dead classes and their tests:

Terminal window
sf apx dead --target-org myOrg --classes --destructive-manifest

Write a manifest for unreferenced classes only, excluding test-only groups:

Terminal window
sf apx dead --target-org myOrg --classes --destructive-manifest --dead-only

See code: src/commands/apx/dead.ts

sf apx generate

Generate multiple AEP artifact groups in one command run.

Usage

Terminal window
sf apx generate [--json] [--flags-dir <value>] [-o <value>] [-s <value>] [--at4dx] [--fflib] [-a <value>] [-b <value>] [-p <value>] [--prefix <value>] [-r] [-d] [-u] [--dry-run] [-i]

Flags

-a, --api-version <value>

Override the API version used for the org connection.

Override the api version used for api requests made by this command

-b, --binding-sequence <value>

Binding sequence value for AT4DX unit-of-work metadata.

-d, --domain

Include domain artifacts in aggregate generation.

-i, --interactive

Prompt for generation flag values interactively.

-o, --target-org <value>

Target org username or alias.

-p, --output-path <value>

Output folder relative to the Salesforce project root.

Default: generated-files

-r, --selector

Include selector artifacts in aggregate generation.

-s, --sobject <value>

SObject API name used for generated artifacts.

-u, --unit-of-work

Include unit-of-work artifacts in aggregate generation.

--at4dx

Generate AT4DX-flavor artifacts.

--dry-run

Render and validate generation output without writing files.

--fflib

Generate fflib-flavor artifacts.

--prefix <value>

Optional namespace-style class prefix.

Global flags

--flags-dir <value>

Import flag values from a directory.

--json

Format output as json.

Description

Builds selector/domain/unit-of-work plans from one SObject describe and writes all selected outputs in a single manifest.

Examples

Generate selector, domain, and unit-of-work in AT4DX style:

Terminal window
sf apx generate --target-org myOrg --sobject Account --selector --domain --unit-of-work --at4dx

See code: src/commands/apx/generate.ts

sf apx generate action

Generate an AT4DX domain-process action class, test, and binding metadata.

Usage

Terminal window
sf apx generate action [--json] [--flags-dir <value>] [-s <value>] [-c <value>] [--trigger-operation Before_Insert|Before_Update|Before_Delete|After_Insert|After_Update|After_Delete|After_Undelete] [--order <value>] [--process-name <value>] [--description <value>] [-a <value>] [-p <value>] [--dry-run] [-i]

Flags

-a, --api-version <value>

API version to use for generated Apex metadata.

Sets the apiVersion written to the generated metadata files. Without this flag, apx uses the target org’s API version when an org is connected, otherwise its built-in default.

-c, --class-name <value>

Name of the trigger action class to generate.

-i, --interactive

Prompt for generation flag values interactively.

-p, --output-path <value>

Output folder relative to the Salesforce project root.

Default: generated-files

-s, --sobject <value>

SObject API name used for generated artifacts.

--description <value>

Optional description value written into generated metadata.

--dry-run

Render and validate generation output without writing files.

--order <value>

Order-of-execution token used for AT4DX domain-process bindings (for example, 10.1).

--process-name <value>

Optional process token used to build AT4DX binding developer names.

--trigger-operation <option>

Trigger operation enum value for AT4DX domain-process bindings.

Options: Before_Insert · Before_Update · Before_Delete · After_Insert · After_Update · After_Delete · After_Undelete

Global flags

--flags-dir <value>

Import flag values from a directory.

--json

Format output as json.

Description

Creates offline action scaffolding and a DomainProcessBinding record without requiring an org connection.

Examples

Generate action artifacts with defaults:

Terminal window
sf apx generate action -s Account -c DefaultAccountSloganBasedOnNameAction

See code: src/commands/apx/generate/action.ts

sf apx generate criteria

Generate an AT4DX domain-process criteria class, test, and binding metadata.

Usage

Terminal window
sf apx generate criteria [--json] [--flags-dir <value>] [-s <value>] [-c <value>] [--trigger-operation Before_Insert|Before_Update|Before_Delete|After_Insert|After_Update|After_Delete|After_Undelete] [--order <value>] [--process-name <value>] [--description <value>] [-a <value>] [-p <value>] [--dry-run] [-i]

Flags

-a, --api-version <value>

API version to use for generated Apex metadata.

Sets the apiVersion written to the generated metadata files. Without this flag, apx uses the target org’s API version when an org is connected, otherwise its built-in default.

-c, --class-name <value>

Name of the trigger criteria class to generate.

-i, --interactive

Prompt for generation flag values interactively.

-p, --output-path <value>

Output folder relative to the Salesforce project root.

Default: generated-files

-s, --sobject <value>

SObject API name used for generated artifacts.

--description <value>

Optional description value written into generated metadata.

--dry-run

Render and validate generation output without writing files.

--order <value>

Order-of-execution token used for AT4DX domain-process bindings (for example, 10.1).

--process-name <value>

Optional process token used to build AT4DX binding developer names.

--trigger-operation <option>

Trigger operation enum value for AT4DX domain-process bindings.

Options: Before_Insert · Before_Update · Before_Delete · After_Insert · After_Update · After_Delete · After_Undelete

Global flags

--flags-dir <value>

Import flag values from a directory.

--json

Format output as json.

Description

Creates offline criteria scaffolding and a DomainProcessBinding record without requiring an org connection.

Examples

Generate criteria artifacts with defaults:

Terminal window
sf apx generate criteria -s Account -c AccountNameContainsFishCriteria

See code: src/commands/apx/generate/criteria.ts

sf apx generate domain

Generate domain classes, tests, triggers, and metadata for an SObject.

Usage

Terminal window
sf apx generate domain [--json] [--flags-dir <value>] [-o <value>] [-s <value>] [--at4dx] [--fflib] [-a <value>] [-p <value>] [--prefix <value>] [--dry-run] [-i]

Flags

-a, --api-version <value>

Override the API version used for the org connection.

Override the api version used for api requests made by this command

-i, --interactive

Prompt for generation flag values interactively.

-o, --target-org <value>

Target org username or alias.

-p, --output-path <value>

Output folder relative to the Salesforce project root.

Default: generated-files

-s, --sobject <value>

SObject API name used for generated artifacts.

--at4dx

Generate AT4DX-flavor artifacts.

--dry-run

Render and validate generation output without writing files.

--fflib

Generate fflib-flavor artifacts.

--prefix <value>

Optional namespace-style class prefix.

Global flags

--flags-dir <value>

Import flag values from a directory.

--json

Format output as json.

Description

Describes the target SObject and scaffolds domain artifacts in either AT4DX or fflib flavor.

Examples

Generate AT4DX domain files:

Terminal window
sf apx generate domain --target-org myOrg --sobject Account --at4dx

See code: src/commands/apx/generate/domain.ts

sf apx generate selector

Generate selector classes, tests, and metadata for an SObject.

Usage

Terminal window
sf apx generate selector [--json] [--flags-dir <value>] [-o <value>] [-s <value>] [--at4dx] [--fflib] [-a <value>] [-p <value>] [--prefix <value>] [--dry-run] [-i]

Flags

-a, --api-version <value>

Override the API version used for the org connection.

Override the api version used for api requests made by this command

-i, --interactive

Prompt for generation flag values interactively.

-o, --target-org <value>

Target org username or alias.

-p, --output-path <value>

Output folder relative to the Salesforce project root.

Default: generated-files

-s, --sobject <value>

SObject API name used for generated artifacts.

--at4dx

Generate AT4DX-flavor artifacts.

--dry-run

Render and validate generation output without writing files.

--fflib

Generate fflib-flavor artifacts.

--prefix <value>

Optional namespace-style class prefix.

Global flags

--flags-dir <value>

Import flag values from a directory.

--json

Format output as json.

Description

Describes the target SObject and scaffolds selector artifacts in either AT4DX or fflib flavor.

Examples

Generate AT4DX selector files:

Terminal window
sf apx generate selector --target-org myOrg --sobject Account --at4dx

Generate fflib selector files with a prefix:

Terminal window
sf apx generate selector --target-org myOrg --sobject Property__c --fflib --prefix foobar

See code: src/commands/apx/generate/selector.ts

sf apx generate selector field-injection

Generate AT4DX selector field-injection metadata (fieldset + binding).

Usage

Terminal window
sf apx generate selector field-injection [--json] [--flags-dir <value>] [-s <value>] [--fields <value>] [--fieldset-name <value>] [--label <value>] [--description <value>] [-p <value>] [--dry-run] [-i]

Flags

-i, --interactive

Prompt for generation flag values interactively.

-p, --output-path <value>

Output folder relative to the Salesforce project root.

Default: generated-files

-s, --sobject <value>

SObject API name used for generated artifacts.

--description <value>

Optional description value written into generated metadata.

--dry-run

Render and validate generation output without writing files.

--fields <value>

Comma-separated API names for field-set displayed fields.

--fieldset-name <value>

Optional field-set API name for selector field injection.

--label <value>

Optional label value for generated metadata artifacts.

Global flags

--flags-dir <value>

Import flag values from a directory.

--json

Format output as json.

Description

Creates a FieldSet and SelectorConfig_FieldSetInclusion binding offline from a comma-separated field list.

Examples

Generate field-injection metadata:

Terminal window
sf apx generate selector field-injection -s Account --fields Name,Industry

See code: src/commands/apx/generate/selector/field-injection.ts

sf apx generate selector method

Generate an AT4DX selector method-injection class and test.

Usage

Terminal window
sf apx generate selector method [--json] [--flags-dir <value>] [-s <value>] [-c <value>] [--sobject-selector-class-name <value>] [-a <value>] [-p <value>] [--dry-run] [-i]

Flags

-a, --api-version <value>

API version to use for generated Apex metadata.

Sets the apiVersion written to the generated metadata files. Without this flag, apx uses the target org’s API version when an org is connected, otherwise its built-in default.

-c, --class-name <value>

Selector method-injection class name.

-i, --interactive

Prompt for generation flag values interactively.

-p, --output-path <value>

Output folder relative to the Salesforce project root.

Default: generated-files

-s, --sobject <value>

SObject API name used for generated artifacts.

--dry-run

Render and validate generation output without writing files.

--sobject-selector-class-name <value>

Selector implementation class name used by method injection.

Global flags

--flags-dir <value>

Import flag values from a directory.

--json

Format output as json.

Description

Creates method-injection scaffolding for an existing selector without requiring an org describe.

Examples

Generate selector method scaffolding:

Terminal window
sf apx generate selector method -c SelectBySloganMethod --sobject-selector-class-name AccountsSelector -s Account

See code: src/commands/apx/generate/selector/method.ts

sf apx generate service

Generate service facade/interface/implementation classes and metadata.

Usage

Terminal window
sf apx generate service [--json] [--flags-dir <value>] [-o <value>] [--service-basename <value>] [--at4dx] [--fflib] [-a <value>] [-p <value>] [--prefix <value>] [--dry-run] [-i]

Flags

-a, --api-version <value>

API version to use for generated Apex metadata.

Sets the apiVersion written to the generated metadata files. Without this flag, apx uses the target org’s API version when an org is connected, otherwise its built-in default.

-i, --interactive

Prompt for generation flag values interactively.

-o, --target-org <value>

Target org username or alias.

-p, --output-path <value>

Output folder relative to the Salesforce project root.

Default: generated-files

--at4dx

Generate AT4DX-flavor artifacts.

--dry-run

Render and validate generation output without writing files.

--fflib

Generate fflib-flavor artifacts.

--prefix <value>

Optional namespace-style class prefix.

--service-basename <value>

Base name used for generated service classes.

Global flags

--flags-dir <value>

Import flag values from a directory.

--json

Format output as json.

Description

Builds service-layer Apex artifacts for the provided basename and flavor.

Examples

Generate an AT4DX service set:

Terminal window
sf apx generate service --target-org myOrg --service-basename LimitMonitors --at4dx

See code: src/commands/apx/generate/service.ts

sf apx generate unitofwork

Generate unit-of-work binding metadata for an SObject.

Usage

Terminal window
sf apx generate unitofwork [--json] [--flags-dir <value>] [-o <value>] [-s <value>] [--at4dx] [--fflib] [-a <value>] [-b <value>] [-p <value>] [--prefix <value>] [--dry-run] [-i]

Flags

-a, --api-version <value>

Override the API version used for the org connection.

Override the api version used for api requests made by this command

-b, --binding-sequence <value>

Binding sequence value for AT4DX unit-of-work metadata.

-i, --interactive

Prompt for generation flag values interactively.

-o, --target-org <value>

Target org username or alias.

-p, --output-path <value>

Output folder relative to the Salesforce project root.

Default: generated-files

-s, --sobject <value>

SObject API name used for generated artifacts.

--at4dx

Generate AT4DX-flavor artifacts.

--dry-run

Render and validate generation output without writing files.

--fflib

Generate fflib-flavor artifacts.

--prefix <value>

Optional namespace-style class prefix.

Global flags

--flags-dir <value>

Import flag values from a directory.

--json

Format output as json.

Description

Creates AT4DX unit-of-work binding metadata or prints the fflib Application snippet.

Examples

Generate AT4DX unit-of-work binding:

Terminal window
sf apx generate unitofwork --target-org myOrg --sobject Account --at4dx

See code: src/commands/apx/generate/unitofwork.ts