跳到主内容
智客 ZICQ

技能库 智客分类:运维与云 dx-org-devhub-configure

Dx Org Devhub Configure

启用 Salesforce org 上的 Dev Hub 并使用 Salesforce CLI (sf) 查看其抓取 org 分配 。 当有人想打开或启用 Dev Hub 时使用,设置一个org来创建抓取或第二代(2GP)并解锁包,检查 Dev Hub 是否已经启用,查看他们可以创建多少个抓取(Active和 Daily craw org 限制,剩余分配),配置 Dev Hub 的偏好,如包装, org 形状导出, 或抓取或快照, 或列出 Dev Hub 创建的活性抓取 Org 。 启用部署可启用的剪贴板 行政管理 Pref 设置, 是不可逆的, 需要系统管理员( Modify AllData 或 Mend Metadata) , 而不能在沙盒中工作 。 创建或删除单个抓取角, 切换默认角( 使用 dx- org- switch) , 或用于试验或org 过期日期( 使用 dx- org- trial- expriation- check) , 不使用 TRIGGER .

1973 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

使用 Salesforce CLI (sf) 在 Salesforce org 上启用 Dev Hub 并查看其抓取 org 分配

何时用

触发请求, 如:

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:Enable Dev Hub & View Scratch Org Allocation、When to use、When NOT to use、How Dev Hub enablement is determined、How enabling works (important)、Steps。 其中含规范建议的小节:分步指令、输入输出示例。

文件分析

文件分析:除 SKILL.md 外,正文引用了 scripts/devhub.sh,属于带资源的技能包,这些文件按需再读。

官方 description(原文)

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).

Enable Dev Hub & View Scratch Org AllocationWhen to useWhen NOT to useHow Dev Hub enablement is determinedHow enabling works (important)StepsBefore you finishOptionsOutput examplesStructured output for automation (`--json`){"org":"my-devhub","devHubEnabled":true,"status":"enabled", ... }Exit codes

· allowed-tools:Read, Bash(bash), Bash(sf api request rest), Bash(sf data query), Bash(sf org list), Bash(sf org login web), Bash(sf org login device), Bash(sf project deploy), Bash(sf config get), Bash(sf org display), Bash(sf org open), Bash(jq)

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
dx-org-devhub-configure
description
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).
allowed-tools
Read, Bash(bash), Bash(sf api request rest), Bash(sf data query), Bash(sf org list), Bash(sf org login web), Bash(sf org login device), Bash(sf project deploy), Bash(sf config get), Bash(sf org display), Bash(sf org open), Bash(jq)实验字段,支持情况取决于客户端;字段声明本身不会授予工具权限。
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。
指令中引用的文件 · 1
  • scripts/devhub.sh

以下路径提取自原文;文件是否齐全请以来源仓库中的完整目录为准。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

该技能引用了附属文件,请从来源获取完整目录;仅复制 SKILL.md 可能缺少依赖。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「dx-org-devhub-configure」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-92ffa24a1af5123c-Dx-Org-Devhub-%E9%85%8D%E7%BD%AE.html
请存为 .cursor/skills/dx-org-devhub-configure/SKILL.md 或 .claude/skills/dx-org-devhub-configure/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。
该技能还带 scripts/、references/、assets/ 等文件,请从 https://github.com/forcedotcom/sf-skills 取完整目录,不要只建一个 SKILL.md。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/forcedotcom/sf-skills' --list

npx skills add 'https://github.com/forcedotcom/sf-skills' --skill 'dx-org-devhub-configure'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: dx-org-devhub-configure description: "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)." allowed-tools: Read, Bash(bash), Bash(sf api request rest), Bash(sf data query), Bash(sf org list), Bash(sf org login web), Bash(sf org login device), Bash(sf project deploy), Bash(sf config get), Bash(sf org display), Bash(sf org open), Bash(jq) metadata: version: "1.0" domains: ["Developer Experience"] # DevHubSettings metadata + the Tooling API DevHubSettings endpoint require # API 47.0 or later (see scripts/devhub.sh SETTINGS_API_VERSION). minApiVersion: "47.0" relatedSkills: - "dx-org-switch" - "dx-org-trial-expiration-check" # Enabling needs ModifyAllData OR ModifyMetadata (either suffices). accessCheck # is a flat array with no OR operator, so declaring both would read as AND and # could falsely gate an admin holding only one. Declare the canonical # System-Administrator perm; the OR alternative stays documented in the # description and body. accessCheck: - type: "userPerm" value: "ModifyAllData" cliTools: - tool: ["jq"] semver: ">=1.6.0" - tool: ["sf"] semver: ">=2.0.0" --- # 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 `` (the directory containing this SKILL.md). ```bash bash "/scripts/devhub.sh" # status: on? + allocation bash "/scripts/devhub.sh" # default org (target-org) bash "/scripts/devhub.sh" --allocation # allocation only bash "/scripts/devhub.sh" --enable # validate enabling (dry run) bash "/scripts/devhub.sh" --enable --apply # actually enable (irreversible) bash "/scripts/devhub.sh" --list-scratch # list active scratch orgs bash "/scripts/devhub.sh" --instance-url --enable --apply # log in first, then enable bash "/scripts/devhub.sh" # 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 ` — the script accepts Salesforce-owned hostnames and logs in with `sf org login web --instance-url ` and then continues. A bare URL positional is accepted as shorthand for the same thing. `` is the absolute path to the directory containing this SKILL.md. 2. **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. 3. 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 "/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 | Flag | Purpose | |------|---------| | `--allocation`, `-A` | Show only the scratch org allocation (Active/Daily). | | `--list-scratch`, `-l` | List active scratch orgs created from this Dev Hub. | | `--enable`, `-e` | Enable Dev Hub (deploys `enableScratchOrgManagementPref=true`). Dry run unless `--apply`. | | `--configure`, `-c` | Configure sub-preferences without (re)enabling the master switch. Pair with a pref flag. | | `--packaging` | `enablePackaging2=true` (Unlocked + 2GP packages). | | `--snapshots` | `enableScratchOrgSnapshotPref=true`. | | `--shape` | `enableShapeExportPref=true`. | | `--scratch-management` | `enableScratchOrgManagementPref=true` (the Dev Hub switch). | | `--pref KEY=VALUE` | Any `DevHubSettings` sub-pref (KEY starts with `enable`, VALUE `true`/`false`). Repeatable. | | `--apply` | Actually deploy to the explicit org argument. Default for `--enable`/`--configure` is a validate-only dry run. | | `--login` | Authenticate an org first via `sf org login web` (opens a browser), then run the action. | | `--instance-url ` | Log in to a specific instance (My Domain, sandbox, or pre-release/scratch instance) with `sf org login web --instance-url `. Implies `--login`. | | `--json` | Emit machine-readable JSON. | | `--fail-if-disabled` | Exit `3` if Dev Hub is not enabled (CI/cron gate). | | `--help`, `-h` | Show 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`](examples/status-output.md) — otherwise skip it to keep this workflow lean. ## Structured output for automation (`--json`) Use `--json` in any mode for machine-readable output (no prose). Status returns `devHubEnabled`, `status`, and an `allocation` object; enablement returns `success`, `applied`, and `devHubVerifiedState`. Deterministic, no LLM needed. ```bash bash "/scripts/devhub.sh" my-devhub --json # {"org":"my-devhub","devHubEnabled":true,"status":"enabled", ... } ``` `--fail-if-disabled` exits `3` (and prints an `ALERT:` line to stderr) if Dev Hub is not enabled, so a scheduled job can gate on it. ## Exit codes - `0` success - `1` an org could not be queried, or a deploy failed (auth/connection/deploy) - `2` bad usage or a missing dependency (`sf` or `jq`) - `3` Dev Hub is not enabled (only when `--fail-if-disabled` is set) ## Authentication If the org isn't authenticated yet, the skill can log in for you with `--login` (or `--instance-url `), then continue with the requested action in the same run — this is the preferred path when the user provides an instance URL: Substitute the user's actual instance URL for `` (shown here as the generic `https://my-domain.my.salesforce.com` placeholder): ```bash # Log in to a specific instance (My Domain / pre-release / sandbox), then enable: bash "/scripts/devhub.sh" my-alias \ --instance-url https://my-domain.my.salesforce.com --enable --apply # Bare instance URL as shorthand — logs in to it, then reports status: bash "/scripts/devhub.sh" https://my-domain.my.salesforce.com # Just authenticate an org (no other action): bash "/scripts/devhub.sh" my-alias --login ``` `sf org login web` opens a browser for the OAuth flow; complete it promptly (the session times out). A supplied positional (`my-alias`) becomes the CLI alias; a positional that looks like a URL (contains `://`) is taken as the `--instance-url` to log in to. The script accepts only HTTPS Salesforce-owned hostnames for this option. Omit `--instance-url` for standard production/DE/trial logins (`login.salesforce.com`). If the browser flow keeps timing out, the script prints the `sf org login device` fallback for a code-based login. If an org isn't authenticated and no login flag was passed, the script instead prints the exact command to log in and re-run — using the instance URL you supplied when there is one: ```text my-org could not query org (...) To authenticate against https://my-domain.my.salesforce.com, run: sf org login web --instance-url "https://my-domain.my.salesforce.com" --alias "my-org" Or let this script log you in and continue in one step: devhub.sh "my-org" --instance-url "https://my-domain.my.salesforce.com" --login Then re-run. List existing logins with: sf org list ``` ## Manual fallback (if the script is unavailable) ```bash # Detect Dev Hub (INVALID_TYPE error means OFF; a count means ON): sf data query --query "SELECT COUNT() FROM ScratchOrgInfo" --target-org --json # Enable Dev Hub via the Tooling API (what the Setup toggle does; irreversible): sf api request rest "/services/data/v47.0/tooling/sobjects/DevHubSettings/DevHub" \ --method PATCH \ --body '{"FullName":"DevHub","Metadata":{"enableScratchOrgManagementPref":true}}' \ --target-org # Or enable in the UI: Setup > Quick Find > "Dev Hub" > turn Enable Dev Hub On. # View scratch org allocation: sf org list limits --target-org --json | jq '.result[] | select(.name|test("ScratchOrg"))' ``` ## Notes - Requires the Salesforce CLI (`sf`) and `jq` on the PATH, plus at least one authenticated org (`sf org login web`). - After enabling, set the org as your default Dev Hub: `sf config set target-dev-hub `. - Enabling **packaging** (`enablePackaging2`) requires Dev Hub to be on first — `--enable --packaging` handles the ordering in a single deploy. - Non-admin users still need object access (Read/Create on `ScratchOrgInfo` and `ActiveScratchOrg`) to create/view scratch orgs, and the "Create and Update Second-Generation Packages" permission to build 2GP/unlocked packages. - To *switch* the default org use `dx-org-switch`; to check *expiration* use `dx-org-trial-expiration-check`.

相关技能

运维与云

Docker Essentials

用于容器管理,图像操作,调试的基本道克命令和工作流程.

运维与云

Find Skills

从开放的代理技能生态系统中发现并安装技能. 使用时:(1)用户问"我如何做X",X可能拥有现有技能,(2)用户说"为X找到技能"或"是否为X有技能",(3)用户问"你能否做X",X是专门能力,(4)用户想扩展代理能力,(5)用户想搜索工具,模板,或工作流程,(6)用户提到他们希望…

运维与云

Microsoft Foundry

构建,部署,评价,优化,微调,管理微软创始代理,模型,资源最终结束. 用法:铸造、azd ai代理、azd 提供/部署、托管代理脚手架/开发/运行/部署/拖放、即时代理创建、创建代理、更新代理、添加代理工具、援引代理、代理.yaml、评估代理、批量活化、连续活化、持续监测、代理C…

运维与云

Azure Deploy

执行已有.azure/部署计划.md和基础设施文件的ALREADY-PREPARED应用程序的Azure部署。 当用户向 CREATE 请求新应用程序时, 请不要使用此技能 。 这种技能运行了 azd上行, azd 部署, trarraform 应用, 和 az 部署命令带有内置…