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:
- Salesforce CLI installed and up to date — run
sf updateto confirm you're on the latest version - A Dev Hub org enabled — your Dev Hub must have the required Data 360 licenses. Go to Setup → Dev Hub and enable it
- Authorized to your Dev Hub — run
sf org login web --set-default-dev-huband sign in
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)
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.
Step-by-Step: Create and Open the Scratch Org
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 case | Recommended environment |
|---|---|
| General Agentforce development and testing | Scratch org — faster to spin up, clean slate |
| Agents that need Agentforce Data Library (ADL) or Data 360 features | Sandbox — recommended by official docs |
| RAG, Retrievers, BYO LLM (without a sandbox) | Scratch org with Data Cloud (ISV/Partner only) |
| Testing with production data or metadata | Sandbox only |
Key Takeaways
- Feature required:
Einstein1AIPlatform— Developer and Enterprise editions only - Settings required:
agentPlatformSettings.enableAgentPlatform: trueandeinsteinGptSettings.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


0 Comments