org-shape-and-scratch-definition

Use this skill when authoring, debugging, or optimizing a scratch org definition file (project-scratch-def.json): schema structure, features array, settings hierarchy, Org Shape sourcing, edition selection, orgPreferences-to-settings migration, and release pinning. NOT for scratch org lifecycle management (use scratch-org-management), CI pipeline design, or sandbox configuration.

Best use case

org-shape-and-scratch-definition is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Use this skill when authoring, debugging, or optimizing a scratch org definition file (project-scratch-def.json): schema structure, features array, settings hierarchy, Org Shape sourcing, edition selection, orgPreferences-to-settings migration, and release pinning. NOT for scratch org lifecycle management (use scratch-org-management), CI pipeline design, or sandbox configuration.

Teams using org-shape-and-scratch-definition should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/org-shape-and-scratch-definition/SKILL.md --create-dirs "https://raw.githubusercontent.com/PranavNagrecha/AwesomeSalesforceSkills/main/skills/devops/org-shape-and-scratch-definition/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/org-shape-and-scratch-definition/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How org-shape-and-scratch-definition Compares

Feature / Agentorg-shape-and-scratch-definitionStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Use this skill when authoring, debugging, or optimizing a scratch org definition file (project-scratch-def.json): schema structure, features array, settings hierarchy, Org Shape sourcing, edition selection, orgPreferences-to-settings migration, and release pinning. NOT for scratch org lifecycle management (use scratch-org-management), CI pipeline design, or sandbox configuration.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Org Shape and Scratch Definition

This skill activates when a practitioner needs to author, troubleshoot, or refine the scratch org definition file (`project-scratch-def.json`). It covers the full schema depth of the definition file including edition selection, feature declarations, settings blocks, Org Shape sourcing, and release channel pinning. It does not cover scratch org lifecycle commands, CI pipeline orchestration, or sandbox strategy.

---

## Before Starting

Gather this context before working on anything in this domain:

- What Dev Hub edition is in use? Org Shape requires Enterprise Edition or higher on the Dev Hub.
- Which features does the target org need that go beyond the default Developer edition scratch org (e.g., Communities, MultiCurrency, ServiceCloud, PersonAccounts)?
- Is the team migrating from the deprecated `orgPreferences` block, or starting fresh with `settings`?

---

## Core Concepts

Understanding the scratch org definition file requires clarity on four areas: schema structure, the features array, the settings hierarchy, and Org Shape.

### Definition File Schema

The `project-scratch-def.json` file is the declarative blueprint for a scratch org. It lives at the root of an SFDX project (or a path specified by `--definition-file`). The top-level keys include `orgName`, `edition`, `features`, `settings`, `language`, `country`, `hasSampleData`, `release`, and `sourceOrg`. The `edition` field accepts values like `Developer`, `Enterprise`, `Group`, and `Professional`. If omitted, `Developer` is the default. The edition determines the baseline feature ceiling -- for example, you cannot use Record Types in a `Group` edition scratch org.

### Features Array

The `features` array enables specific platform capabilities that are not part of the base edition. Examples include `Communities`, `ServiceCloud`, `LightningServiceConsole`, `API`, `AuthorApex`, `MultiCurrency`, `PersonAccounts`, `StateAndCountryPicklist`, and `AnalyticsCRMAnalyticsPlusPlatform`. Feature names are case-sensitive strings. An invalid or misspelled feature name causes org creation to fail with an `INVALID_INPUT` error. Some features depend on edition -- for instance, `PersonAccounts` requires `Enterprise` edition or higher.

### Settings Hierarchy

Since Winter '20, the `settings` object replaced the deprecated `orgPreferences` block. Settings are organized by Metadata API type. For example, Translation Workbench is enabled via `languageSettings.enableTranslationWorkbench: true`, and chatter is controlled by `chatterSettings.enableChatter: true`. The structure mirrors the Salesforce Metadata API settings types, so any setting available in `<SettingsType>` metadata can be expressed here using camelCase property paths. Attempting to use the old `orgPreferences` key will produce a deprecation warning and may be silently ignored in newer CLI versions.

### Org Shape

Org Shape lets you create scratch orgs that replicate the shape (features, settings, limits) of an existing source org. You enable it by setting `"sourceOrg": "<orgId>"` in the definition file and omitting `edition`, `features`, and `settings` that conflict. The source org must be connected to the Dev Hub. However, Org Shape does not capture every feature -- notably, `MultiCurrency`, `PersonAccounts`, and certain ISV features are excluded and must still be declared explicitly in the `features` array alongside the `sourceOrg` reference. Org Shape is only available when the Dev Hub is Enterprise Edition or above.

---

## Common Patterns

### Pattern: Hybrid Org Shape with Explicit Feature Overrides

**When to use:** Your team wants scratch orgs that closely mirror production but production uses features Org Shape does not capture (MultiCurrency, PersonAccounts).

**How it works:**
1. Set `sourceOrg` to the 15- or 18-character Org ID of the source org.
2. Add the uncaptured features to the `features` array explicitly.
3. Add any settings that Org Shape does not carry over to the `settings` block.
4. Omit `edition` -- Org Shape infers it from the source.

```json
{
  "sourceOrg": "00D000000000001",
  "features": ["MultiCurrency", "PersonAccounts"],
  "settings": {
    "languageSettings": {
      "enableTranslationWorkbench": true
    }
  }
}
```

**Why not the alternative:** Using Org Shape alone silently omits these features, leading to deployment failures or missing functionality during development that only surfaces during UAT.

### Pattern: Edition-Pinned Minimal Definition for Package Development

**When to use:** You are building an unlocked or managed package and need a lightweight, fast-provisioning scratch org with only the features the package requires.

**How it works:**
1. Set `edition` explicitly (usually `Developer`).
2. Declare only the features your package metadata requires.
3. Pin `release` to `"Previous"` if you need stability against preview-release breakage.

```json
{
  "orgName": "Package Dev Scratch",
  "edition": "Developer",
  "features": ["LightningComponentBundle", "API"],
  "settings": {
    "lightningExperienceSettings": {
      "enableS1DesktopEnabled": true
    }
  },
  "release": "Previous"
}
```

**Why not the alternative:** Including unnecessary features slows provisioning and introduces surface area for flaky CI failures.

---

## Decision Guidance

| Situation | Recommended Approach | Reason |
|---|---|---|
| Scratch orgs must closely mirror production | Org Shape + explicit feature overrides | Captures most settings automatically; fill gaps with features array |
| Building a package with minimal dependencies | Edition-pinned definition with targeted features | Faster provisioning, fewer moving parts, reproducible across Dev Hubs |
| Team needs stability during Salesforce preview windows | Set `"release": "Previous"` | Avoids preview-release regressions breaking CI pipelines |
| Migrating from legacy orgPreferences | Replace with equivalent settings blocks | orgPreferences deprecated since Winter '20; settings is the only supported path |
| Definition file works locally but fails in CI | Audit Dev Hub edition and feature entitlements | CI Dev Hub may have different edition or missing feature licenses |

---

## Recommended Workflow

Step-by-step instructions for authoring or debugging a scratch org definition file:

1. **Identify target capabilities** -- List every Salesforce feature, setting, and edition requirement the development work needs. Cross-reference with the source production org if available.
2. **Choose sourcing strategy** -- Decide between Org Shape (`sourceOrg`) and manual feature/settings declaration. Use Org Shape when the source org is Enterprise+ and the Dev Hub supports it; otherwise, declare manually.
3. **Draft the definition file** -- Write `project-scratch-def.json` with the chosen edition (or sourceOrg), features array, and settings blocks. Use the Metadata API settings type names for the settings hierarchy.
4. **Validate feature names** -- Confirm each feature string against the official Salesforce feature list. Misspelled or unsupported feature names cause creation failure with no partial-match hint.
5. **Test org creation** -- Run `sf org create scratch --definition-file config/project-scratch-def.json --target-dev-hub <hub>` and inspect the output for warnings or errors. Fix any `INVALID_INPUT` messages.
6. **Verify feature availability** -- After creation, open the scratch org and confirm the expected features are enabled (e.g., check Setup > Company Information for MultiCurrency, check Communities setup page).
7. **Commit and document** -- Store the validated definition file in the project repo under `config/`. Document any Org Shape gaps that required explicit overrides.

---

## Review Checklist

Run through these before marking work in this area complete:

- [ ] Definition file has valid JSON syntax and all required top-level keys
- [ ] Edition is appropriate for the features declared (no Group edition with Record Types)
- [ ] No use of deprecated `orgPreferences` -- all preferences expressed via `settings`
- [ ] Org Shape source org is connected to the Dev Hub (if using sourceOrg)
- [ ] Features excluded from Org Shape (MultiCurrency, PersonAccounts) are declared explicitly
- [ ] Feature names are spelled exactly as documented (case-sensitive)
- [ ] `release` is set intentionally (`Previous`, `Current`, or omitted for default)
- [ ] Scratch org creation succeeds and target features are verified in the running org

---

## Salesforce-Specific Gotchas

Non-obvious platform behaviors that cause real production problems:

1. **Org Shape silently omits features** -- MultiCurrency, PersonAccounts, and certain ISV-specific features are not captured by Org Shape. The scratch org creates successfully but is missing capabilities, which only surfaces when deploying metadata that depends on them.
2. **orgPreferences deprecation is silent** -- Since Winter '20, `orgPreferences` is deprecated. Some CLI versions silently ignore it rather than erroring, so your definition file appears to work but the preferences are not applied.
3. **Feature names are case-sensitive** -- Declaring `"multicurrency"` instead of `"MultiCurrency"` produces an `INVALID_INPUT` error. There is no fuzzy matching or helpful suggestion in the error message.

---

## Output Artifacts

| Artifact | Description |
|---|---|
| `project-scratch-def.json` | The validated scratch org definition file ready for use with `sf org create scratch` |
| Definition file audit report | List of issues found in an existing definition file (deprecated keys, missing features, edition mismatches) |

---

## Related Skills

- scratch-org-management -- Use for scratch org lifecycle operations (creation, deletion, allocation management, CI automation)
- unlocked-package-development -- Use when the definition file is part of a package development workflow
- environment-strategy -- Use for broader environment planning across sandboxes, scratch orgs, and production

---

## Official Sources Used

- Scratch Org Definition File -- https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_def_file.htm
- Scratch Org Definition Configuration Values -- https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_def_file_config_values.htm
- Salesforce DX Developer Guide -- https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_intro.htm

Related Skills

scratch-org-snapshots

8
from PranavNagrecha/AwesomeSalesforceSkills

Use Scratch Org Snapshots to reduce CI bring-up time from 10–20 minutes to under 2. NOT for persistent sandbox provisioning.

scratch-org-pools

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when configuring pre-created scratch org pools for parallel CI testing, reducing pipeline wait times by claiming pre-warmed orgs instead of provisioning on demand. Covers CumulusCI pool commands, Dev Hub allocation planning for pools, pool sizing strategies, and CI matrix integration. NOT for basic scratch org lifecycle (use scratch-org-management), scratch org definition files (use org-shape-and-scratch-definition), or test data seeding (use data-seeding-for-testing).

scratch-org-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when designing, configuring, or troubleshooting scratch orgs: definition file structure, edition selection, allocation limits, Org Shape, CI automation via ScratchOrgInfo, and lifecycle management from the Dev Hub. NOT for SFDX CLI basics (use sf-cli-and-sfdx-essentials), sandbox management, or production org administration.

nfr-definition-for-salesforce

8
from PranavNagrecha/AwesomeSalesforceSkills

Defining measurable non-functional requirements for Salesforce implementations: performance SLIs, scalability targets, availability SLAs, security and compliance requirements, usability benchmarks. Use when starting architecture design or preparing for go-live sign-off. NOT for technical implementation of those requirements. NOT for HA/DR planning (use ha-dr-architecture). NOT for individual governor limit investigation (use limits-and-scalability-planning). NOT for security controls implementation (use security-architecture-review).

mcp-tool-definition-apex

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill to implement custom Apex MCP tool classes by extending McpToolDefinition from the salesforce-mcp-lib package. Covers inputSchema(), validate(), and execute() override patterns, JSON schema construction, SOQL and DML inside tools, error handling, and tool registration in the Apex REST endpoint. Trigger keywords: McpToolDefinition, extend McpToolDefinition, Apex MCP tool, mcp-tool Apex, JSON-RPC tool, salesforce-mcp-lib tool class. NOT for the initial server installation and proxy setup (see salesforce-mcp-server-setup), NOT for MCP Resources or Prompts, NOT for OmniStudio or Flow-based tool definitions.

analytics-kpi-definition

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill to define, document, and validate KPI metrics for CRM Analytics — covering metric formula design, dimension selection, target-dataset modeling, benchmark setting, and the KPI register that must exist before any dashboard or lens is built. Trigger keywords: KPI definition CRM Analytics, analytics metric design, analytics target attainment, CRM Analytics measures vs dimensions, analytics benchmark. NOT for building CRM Analytics dashboards or lenses (use analytics/dashboard-design), SOQL report KPI design, or Marketing Cloud analytics KPI work.

xss-and-injection-prevention

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when writing or reviewing Visualforce pages, Apex controllers, or LWC components that output user-supplied data, build dynamic queries, or construct HTTP responses. Triggers: 'XSS in Visualforce', 'SOQL injection vulnerability', 'how to encode output in Apex', 'JSENCODE Visualforce', 'open redirect prevention'. NOT for Apex CRUD/FLS enforcement (use soql-security or apex-crud-and-fls), NOT for Shield encryption (use shield-encryption-key-management), NOT for AppExchange security review process (use secure-coding-review-checklist).

visualforce-security-and-modernization

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when hardening or modernizing legacy Visualforce pages — covers the platform CSRF token model and when disabling it is a security regression, view state encryption guarantees and the 170 KB ceiling, FLS/CRUD enforcement gaps on `<apex:outputField>` and on getters that return sObjects, `<apex:includeScript>` interaction with the org Content Security Policy, hosting LWC inside a VF page via `lightning:container` / `lightning-out`, and the retire-vs-harden-vs-leave-alone decision for an inventory of legacy pages. Triggers: 'should I rewrite this Visualforce page in LWC', 'CSRF protection disabled on Visualforce page is that safe', 'community user sees a field they should not on a Visualforce page', 'view state encryption is that enough for sensitive data', 'how do I host an LWC inside a Visualforce page', 'apex:dynamicComponent and apex:actionFunction safe to keep'. NOT for greenfield Visualforce architecture (use apex/visualforce-fundamentals — controller types, view state pattern selection, PDF rendering); NOT for Visualforce email template authoring (use apex/visualforce-email-templates if/when that skill is authored); NOT for general Apex security review across triggers and async (use apex/soql-security and security/secure-coding-review-checklist).

transaction-security-policies

8
from PranavNagrecha/AwesomeSalesforceSkills

Transaction Security policy creation and configuration: condition builder, enhanced policies, enforcement actions (block, MFA, notification, end session), real-time monitoring mode, and policy troubleshooting. NOT for Event Monitoring log analysis or Shield Event Monitoring setup (use event-monitoring). NOT for Apex testing or debug-log analysis.

sso-saml-troubleshooting

8
from PranavNagrecha/AwesomeSalesforceSkills

Diagnosing broken SAML SSO into Salesforce — IdP-initiated vs SP-initiated flows, signing-certificate validity / expiry, NameID format mismatches, RelayState handling, audience / entityId / issuer mismatches, clock skew, the SAML Assertion Validator in Setup, the Login History debug log, and the My Domain prerequisite for SSO. Covers the standard diagnostic loop: read the SAML response, identify which check failed, fix at the IdP or SP. NOT for OAuth / OpenID Connect SSO (see security/oauth-openid-troubleshooting), NOT for setting up SSO from scratch (see security/sso-saml-setup).

shield-kms-byok-setup

8
from PranavNagrecha/AwesomeSalesforceSkills

Configure Shield Platform Encryption with customer-supplied (BYOK) or customer-held (Cache-Only Key Service) tenant secrets, rotate them, and recover. NOT for Classic Encryption or field masking.

shield-event-log-retention-strategy

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when designing Salesforce Shield Event Monitoring retention, SIEM routing, and storage-tier strategy — which event types to keep, for how long, where, and how to answer audit queries across hot/warm/cold tiers. Triggers: 'shield event log retention', 'route event monitoring to splunk', 'how long to keep login history', 'siem salesforce integration', 'event monitoring storage tier'. NOT for enabling Shield (see salesforce-shield-deployment).