Skip to content
Back to skills

Sfdx Monorepo Patterns

ASecurity

Structure a single repo with multiple unlocked packages, shared templates, and cross-package test strategies. NOT for multi-repo org strategies.

  • 3 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 8, 2026
devopsgospringgitapidevops

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add BanibrataChatterjee/AwesomeSalesforceSkills --skill sfdx-monorepo-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Sfdx Monorepo Patterns?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Sfdx Monorepo Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/banibratachatterjee-sfdx-monorepo-patterns/badge)](https://www.skillsdirectory.com/skills/banibratachatterjee-sfdx-monorepo-patterns)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: sfdx-monorepo-patterns
description: "Structure a single repo with multiple unlocked packages, shared templates, and cross-package test strategies. NOT for multi-repo org strategies."
category: devops
salesforce-version: "Spring '25+"
well-architected-pillars:
  - Operational Excellence
  - Scalability
triggers:
  - "monorepo salesforce"
  - "multiple unlocked packages one repo"
  - "sfdx project multiple packages"
  - "package dependency order"
tags:
  - monorepo
  - packaging
  - sfdx
inputs:
  - "current repo layout"
  - "list of logical packages"
outputs:
  - "sfdx-project.json package directive list, Turborepo/Nx analog, CI matrix"
dependencies: []
version: 1.0.0
author: Pranav Nagrecha
updated: 2026-04-17
---

# 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.

## When to Use

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

Typical trigger phrases that should route to this skill: `monorepo salesforce`, `multiple unlocked packages one repo`, `sfdx project multiple packages`, `package dependency order`.

## Recommended Workflow

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

- Declarative metadata that spans packages (Custom Object with fields in two packages) requires careful ownership.
- CI must know the dependency graph to build in order.
- Shared templates should not ship to prod — keep them in a `tools` directory outside package dirs.
- Use package aliases in sfdx-project.json for readability.

## Worked Examples (see `references/examples.md`)

- *Three-package layout* — Sales + Service + Agentforce
- *Change-detection CI* — Push touches only sales package

## Common Gotchas (see `references/gotchas.md`)

- **Cross-package field ownership** — Two packages define fields on Account; deploy order breaks.
- **Missing dependency declaration** — Deploy fails in prod; works in scratch.
- **Templates shipped to prod** — Tooling files leak into org.

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

- One giant force-app directory
- No package dependency declaration
- Deploying everything on every push

## Official Sources Used

- Salesforce DX Developer Guide — https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/
- Unlocked Packaging — https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_dev2gp.htm
- SF CLI — https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/
- DevOps Center — https://help.salesforce.com/s/articleView?id=sf.devops_center_overview.htm
- Scratch Org Snapshots — https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_snapshots.htm
- sfdx-hardis — https://sfdx-hardis.cloudity.com/

Files in this skill

  • SKILL.md3.5 KB
  • references/examples.md699 B
  • references/gotchas.md708 B
  • references/llm-anti-patterns.md217 B
  • references/well-architected.md789 B
  • scripts/check_sfdx_monorepo_patterns.py927 B
  • templates/sfdx-monorepo-patterns-template.md546 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in devops →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.