Create an Unlocked Package

Learning Objectives

After completing this project, you’ll be able to: 

  • Create an unlocked package using the Salesforce CLI.
  • Create a permission set for the unlocked package.
  • Deploy a permission set using the Salesforce CLI.

Before You Begin

This project assumes that you are familiar with package development. If you haven’t worked on package development, or would like a refresher, see the Package Development Model and Unlocked Packages for Customers modules here on Trailhead. In those modules, you learn the basics of package development, enable Dev Hub in your Trailhead Playground, and install the Salesforce command line interface (CLI), all of which you need to complete this project.

If you’re new to Salesforce DX or want a refresher, work through the Quick Start: Salesforce DX project.

A New Source of Truth

If you completed the Application Lifecycle and Development Models module, you learned that the source of truth for your org is now a package (or multiple packages). With package development, teams are working off of the same metadata package. This becomes especially important when packages include profiles and permission sets. If you don’t include permission sets in your packages, users may not get the right level of application access, potentially delaying deployment as changes get out of sync with other projects.  

In this project, you create a Sales unlocked package and include the permission set in the package. To get started, let’s get you the right tools to work through this project. 

Install and Update Visual Studio Code

Before you write any code, you’ll need a code editing tool. Visual Studio Code (VS Code) is a powerful and highly customizable cross-platform editor. The Salesforce Extension Pack for Visual Studio Code replaces the IDE plug-in for Salesforce development on the desktop. Let’s install Visual Studio Code and set up the extension pack.

Install Visual Studio

  1. Install Visual Studio Code from
  2. Open the Visual Studio Code application.

Install the Salesforce Extension Pack for Visual Studio Code

The Salesforce extensions provide features such as code completion, syntax highlighting, Apex debugging, and more for the Lightning Platform.

  1. In VS Code, click the View menu, and then choose Extensions.
  2. In the search box, enter salesforce extension pack.
  3. Click Install (or Update, if you already have an earlier version of the extension pack installed and it needs to be updated).
    The Salesforce Extension Pack header information includes the number of downloads, star rating, and a short description: Extensions for developing on the Salesforce Platform.
  4. When the extension pack is installed, relaunch Visual Studio Code.

You now have a powerful tool that enables you to do some pretty cool development projects. In this project, you use VS Code for all terminal commands and code editing. 

Install and Update Salesforce CLI

Time to get another new tool to complement your new code editor. Next, you install the Salesforce CLI (or upgrade it, if you already have it installed). You use CLI commands to create scratch orgs and to synchronize source code between orgs and source repositories.  

  1. Install Salesforce CLI from
  2. In VS Code, click Terminal > New Terminal.
  3. Verify that the sfdx-cli version is up to date.
    sfdx update

If the Salesforce CLI needs updating, the terminal window displays “Updating CLI from <old version> to <new version>”.
Message in terminal when Salesforce CLI is updated: “Updating CLI… done”.

If your Salesforce CLI is already up to date, the terminal window displays the message “...already on latest version”.
Terminal window displaying the message “...already on latest version”.

Launch Your Trailhead Playground

You'll be completing this hands-on project in your own personal Salesforce environment, called a Trailhead Playground. Get your Trailhead Playground now by first logging in to Trailhead, and then clicking Launch at the bottom of this page. Your playground opens in a new browser tab or window. Keep the playground window open while you do this project. After you complete the project steps in your playground, come back to this window and click Verify step at the bottom of this page.

Authorize Your Dev Hub

Now is a good time to verify that Dev Hub is enabled in your Trailhead playground. You make org configuration changes through your org setup.

  1. In your playground, click Setupand then select Setup.
  2. In the Quick Find box, enter Dev Hub, and then select Dev Hub.
  3. Click Enable Dev Hub.
  4. Select Enable Unlocked Packages and Enable Second-Generation Managed Packages.

To authorize your playground, you need your username and password.

  1. In the Quick Find box, enter Users, and then select Users.
  2. Take note of your username. You’ll need your username and password to authorize the Salesforce CLI to connect to your Trailhead Playground. If you know your username and password, you can skip the next step and authorize your playground.
  3. If you don’t already know your password, check the box next to your name.
  4. Click Reset Password(s) and then OK. This step sends an email to the address associated with your username. If you don’t see the email, check your spam folder.
  5. Click the link in the email, and enter a new password.

Now you’re ready to authorize your playground. 

  1. In the VS Code Terminal window, log in to your playground to authorize the Salesforce CLI.  
    sfdx auth:web:login -d -a DevHub
  2. When the Salesforce login page opens in your browser, enter the username and password, and then click Log In.
  3. If prompted, click Allow to authorize the Salesforce CLI.

Download the Project 

We’ve created some sample metadata for you to use in this project. You’re going to download the project from GitHub, create an unlocked package, make some changes in a scratch org, and then release the package to your Trailhead Playground. If you don’t have a GitHub account, go to, enter a username, email, and password, and click Sign up for GitHub.

Clone the project from GitHub into your Documents folder.

  1. Log in to your GitHub account, if you haven’t already.
    1. In a web browser, navigate to
    2. Click Sign In.
    3. Enter your GitHub credentials, and then click Sign In.
  2. In VS Code, open the Documents folder.
    MacOS: File > Open > Documents
    Windows: File > Open Folder > Documents
  3. Open a new Terminal window by clicking Terminal > New Terminal.
  4. Clone the GitHub project by running this command:
git clone

The PermSetUnlockedPackage directory that you just created is your project directory. It already contains a list of items you need to build your unlocked package.
The PermSetUnlockedPackage project contains three folders: config, force-appp, and scripts, and five files: .forceignore, .gitignore, package.xml,, and sfdx-project.json.

    5. Navigate to your project directory by running this command:

cd PermSetUnlockedPackage

Great job! Now that you have the tools, let’s create a permission set.


Keep learning for
Sign up for an account to continue.
What’s in it for you?
  • Get personalized recommendations for your career goals
  • Practice your skills with hands-on challenges and quizzes
  • Track and share your progress with employers
  • Connect to mentorship and career opportunities