← Back to Platform & Technical
PLAT-004 Platform & Technical 18 min read For: Salesforce Architects

Salesforce DX: What Every Delivery Leader Must Know

Salesforce DX (SFDX) is not just a set of CLI commands — it is a shift in how Salesforce development is structured, tracked, and deployed. Leaders who understand its principles can set the right standards for their teams and ask the right questions during delivery reviews.

VS

Vishal Sharma

Salesforce Architecture Specialist · Updated May 2026

What you will learn...
  • What Salesforce DX is and the philosophy behind it
  • Source-driven development vs org-driven development — why it matters for delivery
  • Scratch orgs: what they are, how they are used, and when they change your team's workflow
  • Second-Generation Packaging (2GP) and its role in enterprise Salesforce delivery
  • What a mature SFDX-based CI/CD pipeline looks like
  • The questions a delivery leader should ask to assess SFDX adoption maturity

What Salesforce DX Is

Salesforce DX (Developer Experience) is a set of tools, practices, and platform capabilities introduced in 2017 to bring modern software development practices to Salesforce delivery. At its core, SFDX is three things: the Salesforce CLI (a command-line tool for all org operations), a source-format for metadata (XML-based files that represent org configuration), and a development model that treats source control as the authoritative state of the org.

Before SFDX, Salesforce development was org-centric: developers made changes directly in a sandbox, then retrieved metadata and deployed it. The org was the system of record. With SFDX, the model inverts: source control is the system of record, and the org is a deployed instance of what is in source control. This sounds like a small philosophical shift — its delivery implications are significant.

SFDX also introduced scratch orgs: short-lived, disposable Salesforce environments that can be created from scratch in minutes based on a configuration definition. A developer can spin up a fresh org, apply their feature's metadata, run tests, and destroy it — all in an automated pipeline without touching any shared sandbox.

💡
The cultural shift: SFDX is not just a tool adoption — it requires a cultural shift from "the org is where we work" to "source control is where we work." Teams that adopt the SFDX toolset without this cultural shift end up with the tools but still make changes directly in production, defeating the purpose.

Source-Driven vs Org-Driven Development

Understanding the difference between these two development models helps leaders assess whether their team is working in a sustainable, auditable way.

Org-driven development (the old model): Developers open a sandbox, make changes, use "Retrieve" to export the metadata to their local machine, commit it to Git, and use "Deploy" to push to other environments. The org is the primary workspace; source control is a secondary backup. Problems: developers forget to retrieve after changes; multiple developers overwrite each other's work; the production org drifts from what's in source control; deployments are manual and error-prone.

Source-driven development (SFDX model): Source control is the primary workspace. Developers pull the latest source, push to a scratch org or sandbox, make and test changes, retrieve the delta back to source, and merge via a pull request. The pipeline deploys from source to environments. The org is a derivative of source control, not the other way around. Problems solved: drift is eliminated, changes are tracked, pipelines are automated, reviews happen before deployment.

A team genuinely practicing source-driven development can answer: "What is the exact set of metadata deployed in production right now?" with confidence — it is the latest commit on the main branch. A team practicing org-driven development usually cannot answer this question accurately.

Scratch Orgs: The Developer Workflow

Scratch orgs are the most visible SFDX feature for development teams. They are temporary Salesforce orgs (default lifetime: 7 days, maximum: 30 days) created from a definition file that specifies the org's shape — which features are enabled, which Salesforce edition it simulates, and which settings are configured.

The workflow: a developer creates a scratch org, pushes the project's source (from Git) to the scratch org, writes their feature, retrieves changes back to source, runs automated tests, and the scratch org is discarded when development is done. No shared sandboxes are polluted with half-finished features; no developers are blocked waiting for a shared environment; no sandbox refresh is required to get a clean state.

Scratch orgs are appropriate for feature development and automated testing. They are not appropriate for UAT (scratch orgs cannot carry data), performance testing, or integration testing with external systems (scratch org URLs change each time, breaking OAuth configurations).

# Creating and using a scratch org
sf org create scratch \
  --definition-file config/project-scratch-def.json \
  --alias myFeatureDev \
  --duration-days 7

# Push local source to the scratch org
sf project deploy start --target-org myFeatureDev

# Run tests
sf apex run test --target-org myFeatureDev --wait 10

# Pull any changes made in the org back to source
sf project retrieve start --target-org myFeatureDev
🔑
Scratch org limits: The number of active scratch orgs is limited by licence type (typically 40-200 active per day depending on the org edition). Large teams need to manage scratch org allocation or use shared developer sandboxes for some workflows. Monitor scratch org consumption if you have a large development team.

Second-Generation Packaging (2GP)

Second-Generation Packaging (2GP) is the SFDX-based approach to defining explicit, versioned packages of Salesforce metadata. Unlike an org's flat metadata pool (where everything exists together in one space), 2GP packages define clear boundaries: "this package contains these specific objects, classes, and flows."

For enterprise delivery teams (as opposed to ISVs building AppExchange products), 2GP provides modularity benefits: different teams own different packages, dependencies between packages are explicit and enforced, and each package can be versioned and deployed independently. A shared core package (company data model standards) can be a dependency of multiple team packages without each team duplicating it.

2GP is the recommended model for complex enterprise implementations with multiple teams — but it is not appropriate for every situation. Smaller implementations, single-team projects, and orgs with highly intertwined metadata may have more overhead from package management than benefit. The decision to adopt 2GP should be made at programme initiation, not retrofitted mid-project.

What a Mature SFDX CI/CD Pipeline Looks Like

A mature Salesforce CI/CD pipeline built on SFDX typically includes these stages, automated end-to-end.

Developer push → Pull request: Developer pushes source changes to a feature branch and creates a pull request. The pipeline automatically creates a scratch org, deploys the feature branch source, runs unit tests, and runs a static code analysis (PMD/Code Analyser). PR cannot be merged if tests fail or code analysis detects critical issues.

Merge to develop → Integration sandbox deploy: Merged code is automatically deployed to the integration sandbox where integration tests run. This catches conflicts between features merged from multiple developers.

Release branch → UAT sandbox deploy: A release branch cut from develop is deployed to the UAT sandbox. Manual UAT testing happens here against the full data set.

Production deploy: After UAT sign-off, the release branch is deployed to production via the pipeline. No manual metadata deployments from a developer's machine — the pipeline is the only deployment mechanism.

💡
Questions to ask your team: "Can you show me the last 10 production deployments in your CI/CD pipeline?" A healthy answer includes a list of automated pipeline runs with test results and deployer identity. If the answer is "we do manual deployments from sandbox," the team is not practicing SFDX-based delivery regardless of what tools they have installed.

Key Takeaways

  • Salesforce DX inverts the development model: source control is the system of record, and the org is a deployed instance. This eliminates drift, enables automation, and makes deployments auditable.
  • Source-driven development means every change flows source → org, never org → source as the primary direction. Teams that skip this cultural shift defeat the purpose of SFDX tooling.
  • Scratch orgs are short-lived disposable environments created from source in minutes — appropriate for feature development and automated testing, not for UAT or integration testing.
  • Second-Generation Packaging (2GP) provides modular, versioned metadata boundaries with explicit dependencies — recommended for complex enterprise multi-team implementations, not mandatory for every project.
  • A mature SFDX CI/CD pipeline automates the full path from developer commit to production deploy, with automated tests, code analysis, and no manual deployments from developer machines.
  • The delivery leader's litmus test: "Can you show me the last production deployment in your pipeline?" — the answer reveals whether SFDX practices are genuinely in use.

Test Your Understanding

1. A team has Salesforce CLI installed and uses SFDX commands, but developers still make changes directly in the integration sandbox and "retrieve" them to Git afterward. Are they practicing source-driven development?

A. Yes — they are using SFDX tools and committing to Git, which satisfies the source-driven development requirement
B. No — source-driven development requires source control to be the primary workspace. Making changes in the org first and retrieving afterward is org-driven development, which still allows drift and untracked changes.
C. Partially — they meet the tooling requirement but need to add automated testing to complete the SFDX adoption

2. A 15-person development team uses scratch orgs for feature development. After 3 months they find they frequently hit "maximum active scratch orgs" errors. What is the cause and fix?

A. Scratch orgs cannot be used by teams larger than 10 — upgrade to full sandboxes for teams above this size
B. The daily scratch org creation limit is exceeded. Solutions: developers delete scratch orgs promptly when done (not let them expire), reduce scratch org default duration, or request a limit increase via Salesforce support.
C. The SFDX CLI version is outdated — upgrading the CLI resolves scratch org creation errors

3. At what project stage should the decision to use Second-Generation Packaging (2GP) be made for a large enterprise implementation?

A. After the first sprint, once the team understands the complexity of the metadata involved
B. After go-live, as a technical debt reduction initiative once the initial delivery is complete
C. At programme initiation — 2GP package boundaries need to be defined before development starts, as retrofitting package structure into existing org metadata is extremely difficult and disruptive

Discussion & Feedback