Skip to Content
Adaptation Lifecycle

The full adapt, boost, restore, clean lifecycle, with safe rollback.

LATdx ships several commands that mutate Apex source or org state. They map to two distinct workflows (“rapid execution” and “test acceleration”) plus the cleanup path. This page ties them together.

Two Adaptation Modes

LATdx supports two ways to run tests faster. They share the same transformation engine but differ in what gets deployed and how the tests execute.

ModeEntry pointDeploys to org?Package required?Best for
Rapid executionlatdx test runNo (or minimal)No (file mode)Inner-loop dev: edit, run, see results in seconds.
Test accelerationlatdx boost then sf apex test runYesYesCI / orgs that must execute via the standard runner.

Rapid execution accepts one of -f, -d, -n, or -t to select files, directories, class names, or tests.

Rapid execution wraps test bodies in anonymous Apex and runs them through the SOAP API. Nothing persists in the org. Test acceleration transforms the entire codebase, deploys the adapted classes alongside the LATdx managed package, and lets the standard Salesforce test runner pick them up. The transformation in both cases reroutes SOQL/DML/System.* calls through LATdx proxies that simulate the database in-memory.

If you only need fast local feedback, you never have to leave latdx test run. The rest of this page covers test acceleration and the lifecycle of the artifacts it creates.

Commands at a Glance

CommandWhat it doesMutates source?Mutates org?
latdx adaptSingle-file transformation entry point (placeholder today; no-op).No (yet)No
latdx boostTransforms every .cls in a source dir into deployable adapted classes.New output dirNo (deploy is your step)
latdx restoreReverses boost adaptations (in a directory or in an org).YesYes (org mode)
latdx cleanRemoves deployed LATdx helper classes (latdx_*) from an org.NoYes
latdx uninstallFull removal: restore then clean then managed-package uninstall.NoYes (deeply)
NOTE

The transformation injects LATDX_ORIG markers that record the pre-transform body, so latdx restore can reverse the change deterministically. Adapted source carries its own undo information; it does not depend on a separate snapshot or backup.

latdx adapt

Currently a placeholder. The command accepts -f/--file <path> (required) and an optional -o/--output <path>, reads the file, and either writes the contents back unchanged or prints them. It exists as the entry point for upcoming single-file transformation modes (rapid execution, deploy-dbsim, deploy-passthrough); use latdx boost for the working directory-level flow today.

latdx boost

latdx boost -d ./force-app/main/default/classes -o ./build/adapted

Boost walks the source directory recursively, transforms every .cls file, and writes the adapted versions to the output directory.

The transformation:

  • Reroutes Database.*, System.*, and SOQL/DML statements through LATdx managed-package proxies. The proxies activate inside Test.isRunningTest() and run against the in-memory simulator.
  • Preserves @isTest, @TestSetup, @TestVisible, class modifiers, and visibility, the standard test runner has to execute the adapted classes unchanged.
  • Injects LATDX_ORIG markers that record the pre-transform body, so latdx restore can reverse the change deterministically.

The summary line reports transformed / unchanged / errors. Per-file errors are logged at warn level; the overall command still succeeds with a non-zero error count, so check the summary in CI.

The output directory is a transient artifact. Do not commit it to source control; deploy it to the org and discard it after restore (or after merging the branch).

Typical Test-Acceleration Loop

Transform the code

latdx boost -d force-app/main/default/classes -o build/adapted

Run per branch or per CI job. Boost is idempotent: re-running over an already-adapted directory leaves the markers intact.

Deploy the adapted classes

sf project deploy start -d build/adapted -o my-org

The LATdx managed package must already be installed in the org. The package install is a one-time step per org; see Authentication & Org Targeting for the readiness check.

Run the tests through the standard runner

sf apex test run -o my-org -w 10

The Salesforce-native runner picks up the adapted classes; the LATdx proxies activate inside Test.isRunningTest() and route SOQL/DML through the simulator.

Tear down the adaptation

latdx restore -o my-org

Optional, but recommended on long-lived sandboxes when the branch is done.

latdx restore

Reverses what boost deployed, either in a local directory or in a Salesforce org.

latdx restore -d ./build/adapted # restore on disk latdx restore -o my-org # restore deployed classes in the org latdx restore -o my-org --dry-run # list what would change without changing it latdx restore -o my-org --json # structured result

In dir mode, restore reads the LATDX_ORIG markers in adapted files and writes back the original method bodies in place. In org mode, it queries the org for adapted classes, materializes the originals from markers, and redeployes them via the Tooling API.

WARNING

latdx restore -o <alias> rewrites Apex classes in the target org through the Tooling API. There is no implicit production guard at the CLI level; target the right org alias intentionally and prefer --dry-run first on production-shaped orgs.

If any class fails to restore, the command exits with code 1 and reports the offenders. Use --dry-run to preview before touching the org.

latdx clean

Removes LATdx-deployed helper classes from an org. This is distinct from restore: restore reverses adapted user classes, while clean removes the infrastructure LATdx put there (mocks, trigger handlers, generated initializers).

latdx clean -o my-org latdx clean -o my-org --dry-run latdx clean -o my-org --json

The query targets classes named latdx* with a null NamespacePrefix, excluding sidecar latdx_<Name>_ORIG classes that restore may still need. The output lists deleted classes and triggers.

WARNING

latdx clean deletes Apex classes and triggers from the target org. Run --dry-run first to confirm the deletion list. The command does not back up the deleted metadata; recovery requires re-deploying from source.

You usually do not need to run clean directly; latdx uninstall calls it for you. Reach for it standalone if you accidentally deployed adapted classes and want to wipe the helpers without touching the rest of the org.

latdx uninstall

The full-removal entry point. It runs in this order:

  1. restore, revert adapted user classes to their originals.
  2. clean, delete LATdx helper classes.
  3. Managed-package uninstall, remove the latdx-sf managed package.
latdx uninstall -o my-org latdx uninstall -o my-org --dry-run latdx uninstall -o my-org --json

--dry-run prints what each step would do without performing it. --json returns a structured envelope with per-step results, including the package’s blockers array if removal is blocked by external references.

WARNING

latdx uninstall is irreversible: it removes adapted source, helper classes, and the latdx-sf managed package itself. Re-installing later requires the package install workflow from scratch. The CLI does not retry on failure; re-run --dry-run to inspect what’s left after a partial run.

Exit codes:

  • 0, all three steps succeeded.
  • 1, restoration failed, package uninstall blocked, or an internal error occurred.

The CLI does not retry. Re-run latdx uninstall --dry-run to see what’s left if a step failed midway.

When to Run Which

SituationCommand(s)
Local dev: edit a test, run it, get fast feedback.latdx test run -f path/to/Test.cls
CI: run the whole test suite via the standard runner with simulator-backed speedups.latdx boost -d ... -o ... then deploy then sf apex test run then latdx restore
Branch is dead, want to remove its adapted classes from a long-lived sandbox.latdx restore -o my-org
Cleaning helper classes left behind after a misconfigured run.latdx clean -o my-org
Removing LATdx entirely from an org (e.g., decommissioning).latdx uninstall -o my-org

What Survives Across Runs

NOTE

Across boost runs, the cached transformations under ~/.latdx/workspaces/<id>/cache/ and the runner-access permset grants under ~/.latdx/runner-access/ survive: subsequent runs reuse them. restore and clean mutate org state but leave local caches alone. latdx uninstall does not touch ~/.latdx; if you want a full local reset, use latdx cache clear --all separately.

Safety Notes

  • Run --dry-run on production-shaped orgs before invoking the real command. The CLI does not require an explicit --prod-ok flag; target the right org alias intentionally.
  • latdx uninstall is the only command that removes the managed package; restore and clean leave the package in place so re-installation is not required.
  • All five commands respect the auto-grant FLS/OLS opt-out (LATDX_SKIP_TEST_RUNNER_ACCESS); see Authentication & Org Targeting.

See also

Last updated on