Read the screenplay: FANNIEGATE — $7 trillion. 17 years. The biggest fraud in American capital markets.
🚀 DeploymentBeginner2026-03-04

Scratch Org Setup: From Zero to a Working Dev Environment in 10 Minutes

Scratch orgs changed how Salesforce development works, but the initial setup is a wall for most developers. You need Salesforce CLI, a Dev Hub org, a project configuration, and a working scratch org definition file. Skip any step and you get cryptic errors. Here is the exact sequence that works every time.

First, install Salesforce CLI (sf) and authenticate your Dev Hub org with sf org login web --set-default-dev-hub --alias devhub. This is a one-time setup. Next, create your project with sf project generate --name my-project or use an existing repo. The critical file is config/project-scratch-def.json — this defines what features your scratch org has. Include the features your org uses (Communities, ServiceCloud, etc.) or your code will not deploy.

Create the scratch org with sf org create scratch --definition-file config/project-scratch-def.json --alias mydev --duration-days 30 --set-default. Push your source with sf project deploy start. Open it with sf org open. The whole process takes about 5 minutes once your Dev Hub is connected. I create a fresh scratch org for every feature branch at Cloud Nimbus so each developer has an isolated environment that matches production.

Code Example

// 1. Install SF CLI (one-time)
// npm install -g @salesforce/cli

// 2. Auth Dev Hub (one-time)
sf org login web --set-default-dev-hub --alias devhub

// 3. Project scratch definition:
// config/project-scratch-def.json
{
  "orgName": "My Scratch Org",
  "edition": "Developer",
  "features": [
    "EnableSetPasswordInApi",
    "Communities"
  ],
  "settings": {
    "lightningExperienceSettings": {
      "enableS1DesktopEnabled": true
    },
    "securitySettings": {
      "passwordPolicies": {
        "enableSetPasswordInApi": true
      }
    }
  }
}

// 4. Create scratch org
sf org create scratch \
  --definition-file config/project-scratch-def.json \
  --alias mydev \
  --duration-days 30 \
  --set-default

// 5. Push source
sf project deploy start

// 6. Assign permission set
sf org assign permset --name My_Permission_Set

// 7. Load sample data
sf data import tree --plan data/sample-data-plan.json

// 8. Open the org
sf org open

// Tear down when done:
sf org delete scratch --target-org mydev --no-prompt

Need this implemented in your org?

I've shipped these patterns in production for 10+ years.

View Consulting →

Enjoyed this? Get more like it.

Glen's Musings — AI, investing, and building things. Occasional. Free.

More Deployment Tips