forcedotcom/sf-skills4 files

Dx Org Devhub Configure

Enable Dev Hub on a Salesforce org and view its scratch org allocation, using the Salesforce CLI (sf). Use when someone wants to turn on or enable Dev Hub, set up an org to create scratch orgs or second-generation (2GP) and unlocked packages, check whether Dev Hub is already enabled, see how many scratch orgs they can create (Active and Daily scratch org limits, remaining allocation), configure Dev Hub preferences such as packaging, org shape export, or scratch org snapshots, or list the active scratch orgs created from a Dev Hub. Enabling deploys the enableScratchOrgManagementPref setting, is irreversible, needs a System Administrator (ModifyAllData or ModifyMetadata), and does not work in sandboxes. DO NOT TRIGGER for creating or deleting individual scratch orgs, for switching the default org (use dx-org-switch), or for trial or org expiration dates (use dx-org-trial-expiration-check).

Specification
Skill ID
forcedotcom/sf-skills/dx-org-devhub-configure
Publisher
forcedotcom
Repository
sf-skills
Installs
0
Files
4
Synced
Sep 23, 2026
How to use it

Open any RiverX project, open the Skills panel in the chat, and search for this identifier. The files are fetched from the source repository at install time.

forcedotcom/sf-skills/dx-org-devhub-configureInstalls these files
  • SKILL.md
  • examples/status-output.md
  • scripts/devhub.sh
  • scripts/test-devhub.sh

What this skill tells the agent

Enable Dev Hub & View Scratch Org Allocation

Enable Dev Hub on a Salesforce org, verify whether it is already on, and see the org's scratch org allocation (Active and Daily limits and how many remain) — for the default org or a named org. The skill can also configure Dev Hub sub-preferences (packaging, org shape export, scratch org snapshots) and list the active scratch orgs created from a Dev Hub.

Dev Hub is the org feature that lets you create and manage scratch orgs and second-generation (2GP) / unlocked packages.

When to use

Trigger on requests like:

  • "Enable Dev Hub" / "Turn on Dev Hub" / "Set up this org for scratch orgs."
  • "Is Dev Hub enabled on my org?" / "Check if Dev Hub is on."
  • "How many scratch orgs can I create?" / "What's my scratch org allocation / limit?" / "How many scratch orgs do I have left?"
  • "Turn on packaging / 2GP / unlocked packages" / "Enable org shape export" / "Enable scratch org snapshots" (Dev Hub sub-preferences).
  • "List the scratch orgs on my Dev Hub."

When NOT to use

Do not trigger this skill for:

  • Creating or deleting an individual scratch org — that is sf org create scratch / sf org delete scratch, a different workflow. This skill enables the Dev Hub feature and reports allocation; it does not create scratch orgs.
  • Switching the default/active org — use dx-org-switch.
  • Trial or org expiration dates ("when does my org expire") — use dx-org-trial-expiration-check.

How Dev Hub enablement is determined

The standard object `ScratchOrgInfo` is provisioned and becomes queryable only when Dev Hub is enabled. So a successful SELECT COUNT() FROM ScratchOrgInfo means Dev Hub is ON; an INVALID_TYPE error means it is OFF. This is the reliable signal.

Do not infer enablement from sf org list limits alone: it reports ActiveScratchOrgs / DailyScratchOrgs rows even on orgs where Dev Hub is off, so limits show allocation but not enablement.

How enabling works (important)

  • The Dev Hub master switch is the deployable Metadata API field `DevHubSettings.enableScratchOrgManagementPref`. There is no enableDevHub field and no dedicated sf command to turn it on — deploying this setting is exactly what the Setup toggle does.
  • Enabling is irreversible — once on, Dev Hub cannot be turned off.
  • Requires a user with ModifyAllData or ModifyMetadata (a System Administrator has these). A user without them gets INSUFFICIENT_ACCESS.
  • Cannot be enabled in a sandbox, or in an org that has a registered namespace.
  • Available in Developer, Enterprise, Performance, Unlimited, and trial editions.

Steps

  1. CRITICAL: Run the bundled helper script, which handles Dev Hub detection, the enablement deploy (with a safe dry-run default), allocation math, and structured output, and works on macOS and Linux. Always invoke it by absolute path from the skill directory — never ./scripts/, which resolves against the user's current directory and will either run the wrong script or fail. The script self-checks this: if $0 is not absolute it exits with a usage error, so pass the full path to <skill_dir> (the directory containing this SKILL.md).
   bash "<skill_dir>/scripts/devhub.sh" <alias-or-username>            # status: on? + allocation
   bash "<skill_dir>/scripts/devhub.sh"                               # default org (target-org)
   bash "<skill_dir>/scripts/devhub.sh" <org> --allocation           # allocation only
   bash "<skill_dir>/scripts/devhub.sh" <org> --enable               # validate enabling (dry run)
   bash "<skill_dir>/scripts/devhub.sh" <org> --enable --apply       # actually enable (irreversible)
   bash "<skill_dir>/scripts/devhub.sh" <org> --list-scratch         # list active scratch orgs
   bash "<skill_dir>/scripts/devhub.sh" <alias> --instance-url <url> --enable --apply  # log in first, then enable
   bash "<skill_dir>/scripts/devhub.sh" <url>                        # bare instance URL: log in to it

When the user supplies an instance URL (their My Domain, sandbox, or pre-release/scratch login URL — e.g. https://my-domain.my.salesforce.com), pass that exact URL with --instance-url <url> — the script accepts Salesforce-owned hostnames and logs in with sf org login web --instance-url <url> and then continues. A bare URL positional is accepted as shorthand for the same thing.

<skill_dir> is the absolute path to the directory containing this SKILL.md.

  1. For enablement, default to a dry run first. Run --enable (no --apply) to validate the deploy, then relay the result. Because enabling is irreversible, only run --enable --apply when the user has clearly asked to actually enable Dev Hub. Applied operations require an explicit org alias or username; the script refuses to mutate an implicit default org. If the deploy is rejected for permissions, surface the Setup-UI fallback it prints.
  1. Relay the script output. When an org can't be queried, surface the sf org login web command the script prints so the user can authenticate. Pick optional flags based on the request (see below): --allocation for limits only, --list-scratch to enumerate scratch orgs, --packaging / --snapshots / --shape to turn on sub-preferences, --json for automation.

Before you finish

Verify these before returning your answer:

  • [ ] CRITICAL: Invoked the helper via its absolute path (bash "<skill_dir>/scripts/devhub.sh" …), never ./scripts/ (the script rejects a non-absolute $0).
  • [ ] Did not run --apply unless the user clearly asked to actually enable Dev Hub or deploy a preference — enabling is irreversible.
  • [ ] Relayed the script's own output (status/allocation or the login/Setup-UI guidance it printed), rather than substituting a hand-written answer.

Options

FlagPurpose
--allocation, -AShow only the scratch org allocation (Active/Daily).
--list-scratch, -lList active scratch orgs created from this Dev Hub.
--enable, -eEnable Dev Hub (deploys enableScratchOrgManagementPref=true). Dry run unless --apply.
--configure, -cConfigure sub-preferences without (re)enabling the master switch. Pair with a pref flag.
--packagingenablePackaging2=true (Unlocked + 2GP packages).
--snapshotsenableScratchOrgSnapshotPref=true.
--shapeenableShapeExportPref=true.
--scratch-managementenableScratchOrgManagementPref=true (the Dev Hub switch).
--pref KEY=VALUEAny DevHubSettings sub-pref (KEY starts with enable, VALUE true/false). Repeatable.
--applyActually deploy to the explicit org argument. Default for --enable/--configure is a validate-only dry run.
--loginAuthenticate an org first via sf org login web (opens a browser), then run the action.
--instance-url <url>Log in to a specific instance (My Domain, sandbox, or pre-release/scratch instance) with sf org login web --instance-url <url>. Implies --login.
--jsonEmit machine-readable JSON.
--fail-if-disabledExit 3 if Dev Hub is not enabled (CI/cron gate).
--help, -hShow usage.

--enable may be combined with sub-pref flags to enable and configure at once (e.g. --enable --packaging --apply). If omitted, the org defaults to target-org, then target-dev-hub.

Output examples

The script prints the authoritative output at runtime. If you need to calibrate what an enabled-vs-disabled status transcript looks like (including the allocation table and the enable/Setup-UI guidance), read `examples/status-output.md` — otherwise skip it to keep this workflow lean.

Structured output for automation (--json)

More from forcedotcom

Use this skill in a project

Open any RiverX project, search the Skills panel for forcedotcom/sf-skills/dx-org-devhub-configure, and install it in one click.

Use this skill