---
url: https://veles.beyondthecloud.dev/docs/setup/connect-scratch-org.md
description: >-
  One command sets up Veles on a scratch org and connects it to the Hub with its
  configuration and workflows.
---

# Connect a scratch org

Scratch orgs connect from the command line with the `sf veles setup` plugin. The command installs Veles in the scratch org, registers it on the Hub, connects it and pulls its configuration. A scratch org that was set up this way also runs its assigned workflows on first connect.

## Once per Hub

1. The Hub must be the **Dev Hub** the scratch orgs are created from.
2. Create an environment group for scratch orgs: **Group Management > New Group**, tick **Scratch Org Group**. New scratch orgs land in it unless you pass `--group`.
3. Assign that group the configuration values and workflows a fresh scratch org needs.
4. The user who runs the command needs **Veles Admin** (or at least **Veles Developer**) on the Hub.

## Once per machine

```bash
sf plugins install @beyondthecloud/sf-veles
```

## For every scratch org

Create the scratch org as usual, then:

```bash
sf veles setup --target-org my-scratch --target-dev-hub my-hub
```

Add `--group <name>` (repeatable, first wins) to pick other groups, `--installation-key <key>` if the package needs one. The command prints one line per step:

```text
✔ Resolving org & Hub (Scratch Org)
✔ Installing Veles package
✔ Deploying connection metadata
✔ Configuring Hub connection
✔ Pre-authorizing integration user (you@example.com)
✔ Connecting to Hub
✔ Setting up environment (RSS)

Veles setup complete.
```

Then open the scratch org: configuration is there, and the Activity Log on the Hub shows the workflows that ran. Every flag and exit code is on [sf veles CLI plugin](/docs/developer/cli-plugin).

## Good to know

* A scratch org counts as a connected org until it expires or is deleted. The **Scratch Org Cleanup** background job removes expired ones from the list.
* Scratch orgs do not reconnect on their own. If one loses its connection, run `sf veles setup` again.
* You can also see your Dev Hub's active scratch orgs under **New Environment > From Scratch Org** on the Hub, but the connection itself is always made by the command.
