Scratch orgs are source-driven, disposable and fully configurable environments.
I’ve been using scratch org for about a year now, I want to highlight some of the useful commands and informations related to it
Configure a default devhub ⚙️
Enable devhub in Setup → Devhub
Authorize the devhub
sfdx force:auth:web:login -d -a DevHub
Configure a scratch org 📄
The definition file is structured in 3 main parts
1️⃣ Edition of the scratch org
Supported features are listed in Scratch Org Definition Configuration Values → Supported Editions
2️⃣ Features to activate
Supported features are listed in Scratch Org Definition Configuration Values → Supported Features
3️⃣ ️Settings to apply
All supported settings in the Metadata API listed in Settings are supported in scratch org
Scratch org definition example file
Creating a scratch org ☁️
Scratch org can be created using the Salesforce CLI
sfdx force:org:create -f project-scratch-def.json -a MyScratchOrgAlias
Scratch orgs can last from 1 to 30 days
Pushing & pulling metadatas 🔄
you can push & pull metadatas to/from a scratch using following commands
⬆️ source:push
⬇️ source:pull
List the diffs using source:status
Note : source:retrieve & source:deploy can also be used to deploy & retrieve from a scratch org
Creating sample datas 💾
Create some sample data in your first scratch org then use
⤵️ data:tree:export
⤴️ data:tree:import
import the exported data when creating the next scratch orgs
Configure users & permission sets 👥
User User 👤 is the default admin user created in a new scratch org
Create more users using user:create
Generate a password to the User User using user:password:generate
Display your user informations using user:display
Assign a permission set to your user using user:permset:assign
Managing Shapes & Snapshots (Pilot) 🧰
Still waiting for a beta of the Shape & Snapshot commands 🤩 that will allow us to create scratch orgs from the configuration of any org