SfSkills Domains Docs GitHub

Home / devops / sfdx-monorepo-patterns

sfdx-monorepo-patterns

Structure a single repo with multiple unlocked packages, shared templates, and cross-package test strategies. NOT for multi-repo org strategies — use apex/sf-cli-and-sfdx-essentials.

Open the skill folder on GitHub


SFDX Monorepo Patterns

A monorepo lets multiple unlocked packages share a single git history, shared templates (test factory, TriggerHandler), and a coordinated CI pipeline. This skill formalizes the sfdx-project.json layout, the dependency graph ("dependencies" per package), and a change-detection strategy so CI only validates what changed.

Adoption Signals

Orgs with 3+ logical domains (sales, service, custom agentforce actions). Not for single-package projects.

  1. Define package directories in sfdx-project.json with "default": true on the top-level, "package": "<pkg>" on each.
  2. Declare cross-package dependencies in "dependencies"; package version bumps cascade.
  3. Move shared templates to packaged 'utils' with narrow public API; dependent packages depend on utils.
  4. CI: compute changed files per push; run sf project deploy validate only on affected packages using --manifest.
  5. Weekly: bump package version + create a new version ID for changed packages; promote to released after validation.

Key Considerations

Worked Examples (see references/examples.md)

Common Gotchas (see references/gotchas.md)

Top LLM Anti-Patterns (full list in references/llm-anti-patterns.md)

Official Sources Used

Package files