A Scratch Org is a disposable, source-controlled Salesforce org spun up from a configuration file. Lifespan up to 30 days; intended for short-lived development tasks.
sf org create scratch -f config/project-scratch-def.json -a featurebranch1 -d 7
The config declares features, edition, namespace, language. Each scratch org is fresh — no inherited data, no inherited metadata.
Differences from Sandboxes:
- Scratch: from config file, up to 30 days, no data, used for feature dev.
- Sandbox: from production copy, indefinite, has data (Full) or none (Dev), used for UAT/integration/regression.
Why use scratch orgs: isolation per developer, reproducibility (same config = same org), CI/CD (disposable orgs for tests), feature development.
Limitations: daily creation limits, not for production-realistic data testing, custom domains/SSO not always available.
Modern Apex/LWC dev expects scratch orgs for new code; sandboxes are for testing and staging.
