Andrew Hanna

Andrew Hanna

Salesforce Unlocked Packages: The Right Default, as Artifacts

Salesforce Unlocked Packages: The Right Default, as Artifacts

TL;DR: A Salesforce unlocked package is a second-generation (2GP) package that bundles metadata into a versioned, upgradeable artifact built from source control, with no required namespace and no IP lock. Salesforce positions it as the right package type for most internal apps unless you plan to sell on AppExchange. It works best when you treat every version as an immutable release, not as metadata anyone can edit in production.

What is a Salesforce unlocked package?

An unlocked package is a container for related metadata: objects, Apex, flows, Lightning components. You create it with Salesforce CLI from a source-format project, version it, and install it into any org you own. Version control is the source of truth, and the Dev Hub that created the package owns it.

The word unlocked is literal. Admins can change package metadata directly in a production org, which is handy for an emergency fix and dangerous for everything else. More on that below.

How do unlocked packages compare with managed and unmanaged packages?

  • Unlocked (2GP): versioned and upgradeable, namespace optional, metadata editable after install. Built for internal apps and modular org design.
  • Managed (1GP or 2GP): namespaced, IP-protected and locked after install. Built for ISVs shipping on AppExchange.
  • Unmanaged: a one-time copy of metadata with no upgrade path. Fine for templates and samples, poor for anything you plan to maintain.

Most teams arrive at unlocked packages after years of org-to-org deployments. We argued in why every Salesforce DevOps tool ignores package development that the tooling category grew up around that org model, which is why packaging still feels bolted on.

Are unlocked packages still relevant in Winter '27?

More than before. In its developer guide to Winter '27, Salesforce added 2GP distribution for Multi-Framework apps, recommending unlocked packages for apps you want to keep editable and managed packages for locked, namespaced apps. React and Angular front ends now ship through the same packaging model as your Apex, so the package is becoming the unit of delivery for the whole stack.

How do you build and release an unlocked package?

  1. Create the package against your Dev Hub: sf package create --name Billing --package-type Unlocked --path force-app.
  2. Create a version with tests: sf package version create --package Billing --code-coverage --installation-key-bypass --wait 20. Versions start as beta.
  3. Check coverage with sf package version report. Apex must reach at least 75% coverage before a version can be promoted.
  4. Promote the version to released: sf package version promote --package "[email protected]".
  5. Install into the target org: sf package install --package "[email protected]" --target-org prod --wait 20.

The CLI reference is strict on two points: you cannot promote a version created with --skip-validation, and you cannot combine skip validation with code coverage.

Where do unlocked packages go wrong in production?

This is the part most guides skip. The failure modes are operational, not syntactic:

  • Production drift. A hotfix edited in production gets silently overwritten by the next package upgrade unless someone brings it back to Git and cuts a new version.
  • Org-dependent blind spots. Salesforce does not calculate code coverage for org-dependent unlocked packages, so a green build tells you less than it seems.
  • Open install keys. --installation-key-bypass means anyone with the install link can install the package. Fine for internal pipelines, risky if the link leaks.
  • Dev Hub ownership. The package lives with the Dev Hub that created it. Treat that org as production infrastructure.
  • Dependency order. Split one monolith into five packages and install order becomes a release concern of its own.
  • Empty test orgs. A package that installs cleanly into a blank scratch org can still fail against real data shapes.

None of these show up in a tutorial. All of them show up in the hidden risks in a Salesforce deployment process, and they are a big part of why Salesforce deployments still break.

What should your DevOps tool do about unlocked packages?

Tools differ here, and it is worth checking how. Gearset, for example, has documented warnings when a deployment targets unlocked package components and a Packages affected column in change monitoring, so production edits are caught early.

Serpent treats the package as the release artifact. Its package development support covers 1GP, 2GP and managed packages on every plan, maps dependencies between packages so version conflicts surface before a target org sees them, resolves build and deploy order automatically, and tracks every version against every org it is installed in.

For the empty-org problem, Serpent seeds sample or masked data during environment setup and release pipelines, so scratch orgs and refreshed sandboxes come back populated without a manual script run. PII masking keeps that data production-shaped and usable under GDPR and similar rules. The steps are in the data migration and masking guide.

FAQ

Do unlocked packages need a namespace?

No. A namespace is optional for unlocked packages, which is one reason they suit internal apps.

Can I edit an unlocked package in production?

Yes, but the next upgrade can overwrite that edit. Commit the fix to source control and release a new version.

What code coverage does an unlocked package need?

At least 75% Apex coverage before you can promote a version to released. Org-dependent unlocked packages are not measured.

Should an ISV use unlocked packages?

Not for AppExchange distribution. Use managed packages for IP protection and namespaced upgrades.

If your team is moving from change sets or another tool to package-based releases, see how a migration to Serpent works or compare plans. New to us? Start with our introduction to Serpent or the Serpent homepage.

Related Articles

Curious about faster shipping before you dive in? Let's talk

Commitment free!