# Create a Package Version Based on a Scratch Org Snapshot

If the dependent package your base package requires is stable, you can reduce the end-to-end package version creation time by creating a scratch org snapshot.

## Before You Begin

If you haven’t reviewed [When to Use Scratch Org Snapshots in Package Development](/docs/platform/pkg2-dev/guide/dev2gp-so-when-use-snapshot.md), review that topic before continuing.

There’s more than one workflow you can follow when creating a package version based on a scratch org snapshot. You can start by creating a scratch org, you can build your own scratch org definition file, or you can choose to use org shape to create a new scratch org. Whichever path you choose, after the scratch org is created, you install all the dependent packages into it, and then take a snapshot of the scratch org.

Sample Workflow

This workflow uses an org shape to create the initial scratch org where you’ll install the stable dependent packages, and then create a scratch org snapshot to create a package version.

1. Create the org shape.

   ```nolang
   sf org create shape --target-org source-org1
   ```

2. Create a scratch org definition file that indicates the shape’s source org.

   ```nolang
   {
     "orgName": "Salesforce",
     "sourceOrg": "00DB1230400Ifx5"
   }

   ```

3. Create a scratch org using the org shape.

   ```nolang
   sf org create scratch --duration-days 30 --no-namespace --no-ancestors --definition-file config/scratch-def-with-shape-id.json --alias dev1-with-shape
   ```

   If your default Dev Hub org isn’t the one that owns the org shape, indicate it on the command line.

4. Install the dependent packages.

   ```nolang
   sf package install --package 04txx --target-org dev1-with-shape
   ```

5. Create a snapshot of the scratch org.

   ```nolang
   sf org create snapshot --name dhsnapshot --source-org dev1-with-shape --target-dev-hub dev-hub
   ```

6. Create a new scratch org definition file and specify the snapshot name, then save the file.

   ```nolang
   {
     "orgName": "Salesforce",
     "snapshot": "dhsnapshot"
   }

   ```

7. Create a package version using the org snapshot. This command is specifying the scratch org definition file that contains the snapshot information in it.

   ```nolang
   sf package version create --package hc-ext1 --code-coverage --installation-key-bypass --async-validation --definition-file
   scratch-def-with-snapshot-id.json

   ```

**See Also**

- [When to Use Scratch Org Snapshots in Package Development](/docs/platform/pkg2-dev/guide/dev2gp-so-when-use-snapshot.md)
- [*Salesforce DX Developer Guide*: Create Org Shapes](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_create.htm)
