Enable Agentforce and Data Cloud in a Scratch Org — Complete Setup Guide


 Stop hacking workarounds. Here's the exact definition file and CLI commands to spin up an Agentforce-ready scratch org in minutes.

If you've been building Agentforce solutions, you already know the pain of needing an AI-enabled org to test in. Trailhead orgs expire, sandboxes take time to spin up, and production is off-limits. Scratch orgs with Agentforce enabled are the right developer tool for the job — and once you know the exact definition file structure, it takes about two minutes to have a fresh Agentforce org ready to go.

What You're Getting

According to the official Agentforce Developer Guide, 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. It is configured entirely from a definition file.

Once your Agentforce-enabled scratch org is open, you have access to:

  • Agentforce — build and test agents from scratch
  • Prompt Builder — create and test prompt templates
  • Model Builder — configure model connections
  • Models API — programmatic model access

Prerequisites

Before you create the scratch org, you need three things in place according to the official Agentforce Developer Guide:

  1. Salesforce CLI installed and up to date — run sf update to confirm you're on the latest version
  2. A Dev Hub org enabled — your Dev Hub must have the required Data 360 licenses. Go to Setup → Dev Hub and enable it
  3. Authorized to your Dev Hub — run sf org login web --set-default-dev-hub and sign in
⚠️ Data Cloud requires a special request for ISV/Partner orgsAccording to the official Second-Generation Managed Packaging Developer Guide, if you need both Agentforce and Data Cloud in a scratch org, your PBO (Partner Business Org) Dev Hub must first be granted permission by opening a case in the Salesforce Partner Community. This permission is only granted to PBO orgs. Do not include Data Cloud unless it is required — it significantly increases scratch org creation time.

The Scratch Org Definition File

According to the official Agentforce Developer Guide, to use an Einstein Generative AI scratch org, add the Einstein1AIPlatform feature — supported in Developer and Enterprise editions. To automatically enable Einstein and Agentforce, turn on agentPlatformSettings.enableAgentPlatform and einsteinGptSettings.enableEinsteinGptPlatform in the settings block.

Agentforce Only (recommended for most use cases)

config/afdx-scratch-def.json
{
  "orgName": "SalesforceBolt Agentforce Dev",
  "edition": "Developer",
  "features": ["Einstein1AIPlatform"],
  "settings": {
    "agentPlatformSettings": {
      "enableAgentPlatform": true
    },
    "einsteinGptSettings": {
      "enableEinsteinGptPlatform": true
    },
    "lightningExperienceSettings": {
      "enableS1DesktopEnabled": true
    }
  }
}

Agentforce + Data Cloud (ISV/Partner orgs only)

Only add Data Cloud if your use case requires it — for example, prompt templates that use RAG, Retrievers, or BYO LLM. According to the official Second-Generation Managed Packaging Developer Guide, including Data Cloud significantly increases scratch org creation time.

config/afdx-scratch-def-dc.json
{
  "orgName": "SalesforceBolt Agentforce + Data Cloud Dev",
  "edition": "Developer",
  "features": [
    "Einstein1AIPlatform",
    "DataCloud"
  ],
  "settings": {
    "agentPlatformSettings": {
      "enableAgentPlatform": true
    },
    "einsteinGptSettings": {
      "enableEinsteinGptPlatform": true
    },
    "lightningExperienceSettings": {
      "enableS1DesktopEnabled": true
    }
  }
}

Step-by-Step: Create and Open the Scratch Org

1
Update the CLI
Bash — SF CLI
sf update
2
Log in to your Dev Hub
Bash — SF CLI
sf org login web --set-default-dev-hub --alias MyDevHub
3
Create the scratch org from your definition file
Bash — SF CLI
sf org create scratch \
  --definition-file config/afdx-scratch-def.json \
  --alias AgentforceDev \
  --set-default \
  --duration-days 30
4
Open the org in your browser
Bash — SF CLI
sf org open --target-org AgentforceDev

That's it. According to the official guide, after you open the org you can immediately use Agentforce, Prompt Builder, Model Builder, and the Models API.

Sandbox vs. Scratch Org — Which Should You Use?

According to the official Agentforce Developer Guide, you can use either a sandbox or a scratch org to develop and test your agents. The recommendation is clear:

Use caseRecommended environment
General Agentforce development and testingScratch org — faster to spin up, clean slate
Agents that need Agentforce Data Library (ADL) or Data 360 featuresSandbox — recommended by official docs
RAG, Retrievers, BYO LLM (without a sandbox)Scratch org with Data Cloud (ISV/Partner only)
Testing with production data or metadataSandbox only

Key Takeaways

🚀 Agentforce Scratch Org — Quick Reference
  • Feature required: Einstein1AIPlatform — Developer and Enterprise editions only
  • Settings required: agentPlatformSettings.enableAgentPlatform: true and einsteinGptSettings.enableEinsteinGptPlatform: true
  • Create command: sf org create scratch --definition-file config/afdx-scratch-def.json --alias AgentforceDev --duration-days 30
  • After opening: Agentforce, Prompt Builder, Model Builder, and Models API are all available
  • Need ADL or Data 360 features? Use a sandbox instead
  • Need Data Cloud in a scratch org? ISV/Partner PBO orgs only — open a Partner Community case first
  • Max scratch org lifetime: 30 days — store all config in version control

Once you have this definition file saved in your project, spinning up a fresh Agentforce dev environment is a single CLI command. No more waiting for Trailhead org access, no more expired AI orgs mid-project.

📄 Sources: Create an Agentforce-Ready Scratch Org With Salesforce CLI — Agentforce Developer Guide  |  Get Access to Scratch Orgs That Have Agentforce — Second-Generation Managed Packaging Developer Guide

 If you have any question please leave a comment below.

If you would like to add something to this post please leave a comment below.
Share this blog with your friends if you find it helpful somehow !

Post a Comment

0 Comments