Create an Agentforce-Ready Scratch Org With Salesforce CLI
This guide describes the basic steps for using Salesforce CLI to create a generative AI scratch org for a Developer or Enterprise edition org. You can use either a sandbox or a scratch org to develop and test your agents. If your agent needs Agentforce Data Library (ADL) or other Data 360 features, we recommend using a sandbox. For more information on the Agentforce developer lifecycle, see Build Agents with Agentforce DX
A scratch org is a configurable, short-term Salesforce environment that you can quickly spin up when starting a new project, a new feature branch, or a feature test. Unlike a sandbox, a scratch org doesn't contain data or metadata from your production org. Scratch orgs are configured using a scratch org definition file, which lists the features and settings that mirror the customer's production org.
-
Install Salesforce CLI on your computer.
-
Open a terminal (macos, Linux) or command prompt (Windows) and make sure that Salesforce CLI is up to date by running this command.
-
(Optional) Create a Salesforce DX project on your computer and change to the directory.
If you only want to create a scratch org, then this step isn't necessary. But we recommend creating a DX project if you plan to store your org’s metadata (code and configuration), org templates, sample data, and tests in a version control system. See Project Setup.
-
Select and enable your Dev Hub org, which must have your Data 360 licenses. See Select and Enable a Dev Hub Org in the Salesforce DX Developer Guide for more information.
-
Log in to your Dev Hub org and allow access. In the browser window that opens, sign in to your org with your Salesforce login credentials. Click Allow, which allows Salesforce CLI to access to your org.
-
Create a definition file, such as
afdx-scratch-def.json. If you're using a Salesforce DX project, create the file in theconfigdirectory alongside the existingconfig/project-scratch-def.jsonfile.To use an Einstein Generative AI scratch org, add the
Einstein1AIPlatformfeature, which is supported in Developer and Enterprise editions. To automatically enable Einstein and Agentforce, turn on theagentPlatformSettings.enableAgentPlatformandeinsteinGptSettings.enableEinsteinGptPlatformsettings. -
Using the scratch org definition file, create the scratch org.
-
Open the org.
After you open the org, you can use Salesforce generative AI features such as Agentforce, Prompt Builder, Model Builder, and the Models API. To learn more, see Agentforce and Einstein Generative AI in Salesforce Help.