SfSkills Domains Docs GitHub

Home / devops / packaging-dependency-graph

packaging-dependency-graph

Model and verify unlocked package dependencies, version pinning, and promotion. NOT for 1GP managed packages — use devops/multi-package-development.

Open the skill folder on GitHub


Packaging Dependency Graph

Unlocked package dependencies bind a package version to versions of other packages. Without an explicit graph you can ship an extension version built against a base version that was never released, or install packages in an order the platform rejects. This skill covers declaring dependencies in sfdx-project.json, choosing between the LATEST and RELEASED keywords, deriving install and promotion order from the graph, and proving the order in an org that has never seen the source.


Before Starting


Questions to Ask Before Configuring

AskWhy it mattersWhat a good answer adds
Are any base and extension packages developed in parallel?LATEST binds the extension to the newest created base version, which may never be promoted (gotcha 1).A rule to switch the dependency to RELEASED before the extension version you will promote is created.
Does anyone create versions with skip validation?Skip-validated versions aren't checked for dependencies, ancestors, or metadata; extensions must be tested against a promoted or validated base (gotcha 2).A list of which versions are safe to build against.
Is calculateTransitiveDependencies on?Without it you must list indirect dependencies yourself, in install order (gotcha 3).One unambiguous dependency list per package.
What order would a subscriber install these packages in?Dependencies are listed in installation order, and SubscriberPackageVersion.Dependencies returns the 04t IDs in that order (gotcha 4).A generated install order rather than a remembered one.
Who promotes, and in what order?Promotion is permission-gated and cannot be reverted with package version update (gotcha 5).A named promoter and a base-first promotion runbook.
Will any package reference a package that references it back?A cycle makes the graph impossible to order; the fix is a third package (gotcha 6).A dependency direction rule per package layer.
Do you ever expect to delete a version?Released unlocked versions can be deleted, released 2GP managed versions can't, and deleting a version that is still a dependency breaks installs (gotcha 7).A retention rule that checks dependents before any delete.

A properly configured graph adds a single source for install and promotion order and a RELEASED-based dependency at promotion time, where "just adding the dependency" ships an extension pinned to a base build nobody released.


Core Concepts

Dependency declaration

Each packageDirectories entry may carry a dependencies array. A dependency is either {"package": "<alias>@<version>"} (the alias resolves to a version) or {"package": "<name>", "versionNumber": "<M.m.p.build>"}; packages outside the Dev Hub use the alias form. IDs work too: the 0Ho package ID with a version number, or the 04t subscriber package version ID alone. With more than one dependency, list them in installation order, including indirect ones, unless calculateTransitiveDependencies is true — then list direct dependencies only and the CLI computes the rest.

{
  "packageDirectories": [
    { "path": "util", "package": "Expense Manager - Util", "versionNumber": "4.7.0.NEXT", "default": true },
    {
      "path": "exp-core",
      "package": "Expense Manager",
      "versionNumber": "3.2.0.NEXT",
      "default": false,
      "calculateTransitiveDependencies": true,
      "dependencies": [
        { "package": "Expense Manager - Util", "versionNumber": "4.7.0.RELEASED" }
      ]
    }
  ],
  "packageAliases": {
    "Expense Manager - Util": "0Ho000000000001AAA",
    "Expense Manager": "0Ho000000000002AAA"
  }
}

Version keywords (package version pinning)

A dependency's versionNumber is how you pin a package version: an explicit build number pins to exactly that version, while the keywords below pin to a moving target. Package version pinning is a choice between these three forms, not a separate setting.

KeywordWhereResolves to
NEXTyour own versionNumberthe next available build number
LATESTa dependency's versionNumberthe most recently created version, promoted or not
RELEASEDa dependency's versionNumberthe promoted and released version
HIGHEST / NONEancestorVersion / ancestorIdhighest promoted version / no ancestor (existing customers can't upgrade)

Example from the guide: with versions 1.0.0.1, 1.0.0.2, 1.0.0.3 created and 1.0.0.2 promoted, 1.0.0.RELEASED = 1.0.0.2 but 1.0.0.LATEST = 1.0.0.3.

Reading the graph back

For an installed (or installable) version, query the Tooling API: SELECT Dependencies FROM SubscriberPackageVersion WHERE Id = '04t...' returns the dependency 04t IDs in install order. sf package version displaydependencies draws the hierarchy when calculateTransitiveDependencies is enabled.

Metadata XML: not applicable — the graph lives entirely in sfdx-project.json and the package version records.


  1. Inventory sfdx-project.json: every package directory, alias, versionNumber, and dependencies entry; answer the Questions table.
  2. Run python3 skills/devops/packaging-dependency-graph/scripts/check_packaging_dependency_graph.py --manifest-dir . — it ERRORs on unresolved aliases, cycles, NEXT on a dependency, and LATEST/RELEASED on your own versionNumber, and prints the base-first order.
  3. During parallel development use LATEST; before creating the extension version you intend to promote, promote the base, switch the dependency to RELEASED, then create and test the extension version.
  4. Install the 04t versions into a fresh org in the printed order (references/worked-example.md has the CI job) and run tests against the installed metadata.
  5. Promote base-first with sf package version promote, recording each 04t with its commit.
  6. Before any sf package version delete, query dependents and confirm nothing installs against that version.

Decision Guidance

SituationUseWhy
Base and extension change in the same sprintLATEST while developing, RELEASED for the promoted buildLATEST can bind to an unpromoted base
Extension depends on a third-party or other-Dev Hub packageAlias form "Name@1.2.0" / the 04t IDPackages outside the Dev Hub use the alias form
Deep chains (C → B → A)calculateTransitiveDependencies: trueList direct dependencies only; the CLI computes the rest
Two packages need each other's codeExtract a third package both depend onA cycle has no install order
A released version is badShip a new versionRelease status can't be changed with package version update

Review Checklist


Salesforce-Specific Gotchas

Full list in references/gotchas.md. The two that block releases most often:

  1. LATEST is not "latest released" — it maps to the newest created version.
  2. List order is install order — dependencies are listed in installation order unless transitive calculation is on.

Output Artifacts

ArtifactDescription
Dependency diagramPackages, edges, and the keyword on each edge
Install / promotion orderThe checker's base-first order, used by CI and the release runbook
Pinning strategyWhen each edge moves from LATEST to RELEASED
Promotion runbookBase-first promotion with recorded 04t IDs

Reference Files

FileUse it for
references/examples.mdA three-package graph declared correctly, and a clean-org install proof
references/gotchas.mdSeven dependency and promotion behaviours with avoidance steps
references/llm-anti-patterns.mdDependency syntax and promotion mistakes AI assistants make
references/well-architected.mdPillar framing and the guide lines behind each claim
references/worked-example.mdParallel base/extension release from LATEST to RELEASED, with the CI install job

Package files