dx-org-snapshot-manage
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesedx-org-snapshot-manage
dx-org-snapshot-manage
Coordinates the full lifecycle of Salesforce scratch org snapshots — create, get (status), list, and delete — via , , , and . A snapshot is a point-in-time copy of a scratch org (its metadata and data) that you reference by name in a scratch org definition file to spin up new orgs from saved state.
sf org create snapshotsf org get snapshotsf org list snapshotsf org delete snapshot协调 Salesforce scratch org snapshot 的完整生命周期——创建、获取(状态)、列出和删除——通过 、、 和 实现。Snapshot 是 scratch org 在某一时间点的副本(包含其 metadata 和 data),可以在 scratch org definition 文件中按名称引用,以从保存的状态启动新的 org。
sf org create snapshotsf org get snapshotsf org list snapshotsf org delete snapshotTool Restrictions
工具限制
Use ONLY the Bash tool to execute the commands. Do NOT use MCP tools — ignore them completely.
sf org ... snapshotOutput artifacts for eval/testing: ALWAYS write the command's complete JSON response to a file when an output directory is available. Do NOT ask the user what file to write — this skill defines the filenames. After executing each command: (1) if the user specified an output path, write there immediately; (2) otherwise run to detect the eval directory; (3) write the command's full, unmodified JSON response to using these filenames: , , , or . This is the generated output — write it without asking. (4) If no output directory can be found by either check, include the command's complete, unmodified JSON response verbatim (e.g. in a fenced code block) in your final reply instead of skipping the artifact.
[ -d force-app/main/adk-eval-output/ ] && echo 'force-app/main/adk-eval-output'<output-dir>/<filename>create-snapshot-result.jsonget-snapshot-result.jsonlist-snapshots-result.jsondelete-snapshot-result.json仅使用 Bash 工具执行 命令。不要使用 MCP 工具——完全忽略它们。
sf org ... snapshot用于 eval/testing 的输出产物: 有可用输出目录时,始终将命令的完整 JSON 响应写入文件。不要询问用户应写入哪个文件——此 skill 已定义文件名。执行每条命令后:(1) 如果用户指定了输出路径,立即写入该路径;(2) 否则运行 检测 eval 目录;(3) 使用以下文件名,将命令未经修改的完整 JSON 响应写入 :、、 或 。这是生成的输出——直接写入,无需询问。(4) 如果通过上述任一检查均未找到输出目录,则在最终回复中逐字包含命令未经修改的完整 JSON 响应(例如放在 fenced code block 中),不得省略该产物。
[ -d force-app/main/adk-eval-output/ ] && echo 'force-app/main/adk-eval-output'<output-dir>/create-snapshot-result.jsonget-snapshot-result.jsonlist-snapshots-result.jsondelete-snapshot-result.jsonRelationship to Other Skills
与其他 Skill 的关系
This skill owns the full snapshot lifecycle — create, get status, list, and delete. It does not create scratch orgs.
- Any snapshot operation (create, status, list, delete, expiry check) → this skill.
- Create a scratch org, including from an existing snapshot () →
--snapshot <name>.dx-org-manage - Org shapes (baseline config without data, ) →
sf org create/list/delete shape. Shapes and snapshots are different artifacts with different commands — see the comparison below.dx-org-shape-manage
| Snapshot (this skill) | Org Shape ( | |
|---|---|---|
| Captures | Full point-in-time copy: metadata and data | Baseline config only: features, limits, edition, Metadata API settings |
| Commands | | |
| Referenced via | | |
| Prerequisite | Dev Hub has Scratch Org Snapshots enabled | Source org has Org Shape for Scratch Orgs enabled |
| Operates against | A Dev Hub ( | The source org ( |
此 skill 负责 snapshot 的完整生命周期——创建、获取状态、列出和删除。它不创建 scratch org。
- 任何 snapshot 操作(创建、状态、列出、删除、过期检查)→ 此 skill。
- 创建 scratch org,包括从现有 snapshot 创建()→
--snapshot <name>skill。dx-org-manage - Org shape(不含数据的 baseline config,)→
sf org create/list/delete shapeskill。Shape 和 snapshot 是不同产物,使用不同命令——请参阅下方对比。dx-org-shape-manage
| Snapshot(此 skill) | Org Shape( | |
|---|---|---|
| 捕获内容 | 完整的时间点副本:metadata 和 data | 仅限 baseline config:features、limits、edition、Metadata API settings |
| 命令 | | |
| 引用方式 | scratch def file 中的 | scratch def file 中的 |
| 前提条件 | Dev Hub 已启用 Scratch Org Snapshots | Source org 已启用 Org Shape for Scratch Orgs |
| 操作目标 | Dev Hub( | source org( |
Scope
范围
- In scope: Creating (), getting status (
sf org create snapshot), listing (sf org get snapshot), and deleting (sf org list snapshot) scratch org snapshotssf org delete snapshot - Out of scope: Creating org shapes (), creating scratch orgs — including from a snapshot (
dx-org-shape-manage)dx-org-manage
- 范围内:创建()、获取状态(
sf org create snapshot)、列出(sf org get snapshot)和删除(sf org list snapshot)scratch org snapshotsf org delete snapshot - 范围外:创建 org shape()、创建 scratch org——包括从 snapshot 创建(
dx-org-shape-manage)dx-org-manage
Required Inputs
必需输入
Infer from the user's request:
- Operation: create, get, list, or delete (see Workflow step 1)
- Dev Hub: Username or alias of the Dev Hub that owns the snapshots. Passed via (
--target-dev-hub); optional if the-vconfig variable is set. All four commands operate against a Dev Hub, nevertarget-dev-hub.--target-org - Source org (create only): Scratch org ID (starts with ), username, or alias to snapshot. Passed via
00D(--source-org).-o - Snapshot name (create only): A unique name for the snapshot, max 15 characters. Passed via (
--name).-n - Snapshot name or ID (get & delete only): Name, or ID (starts with ), of the snapshot. Passed via
0Oo(--snapshot).-s - Description (create, optional): Documents snapshot contents.
- Expiry threshold in days (expiring-soon listing only): There is no CLI flag for this — it's a client-side filter on (see Command Patterns).
ExpirationDate
从用户请求中推断:
- 操作:create、get、list 或 delete(见工作流步骤 1)
- Dev Hub:拥有这些 snapshot 的 Dev Hub 的用户名或别名。通过 (
--target-dev-hub)传入;如果已设置-v配置变量,则可省略。所有四条命令都针对 Dev Hub 操作,绝不能使用target-dev-hub。--target-org - Source org(仅 create):要创建 snapshot 的 scratch org ID(以 开头)、用户名或别名。通过
00D(--source-org)传入。-o - Snapshot name(仅 create):snapshot 的唯一名称,最多 15 个字符。通过 (
--name)传入。-n - Snapshot name or ID(仅 get 和 delete):snapshot 的名称或 ID(以 开头)。通过
0Oo(--snapshot)传入。-s - Description(create 时可选):记录 snapshot 的内容。
- Expiry threshold in days(仅用于列出即将过期的 snapshot):CLI 没有对应的 flag——这是客户端对 的筛选(见命令模式)。
ExpirationDate
Workflow
工作流
- Identify the operation and match it to the command pattern below.
- Resolve the Dev Hub — if isn't provided, check the default with
--target-dev-hub. Never fabricate a placeholder Dev Hub name (e.g.sf config get target-dev-hub) — an unresolved hub is a hard stop; advisemy-dev-hubinstead.sf org login web --set-default-dev-hub - For create, confirm the source org and snapshot name — the source must be a scratch org; the name must be unique in the Dev Hub and ≤15 characters.
- Execute via Bash tool with the flag.
--json - Report the result (see Output Expectations and the example files).
- 识别操作,并将其与下方对应的命令模式匹配。
- 解析 Dev Hub——如果未提供 ,使用
--target-dev-hub检查默认值。绝不能虚构占位 Dev Hub 名称(例如sf config get target-dev-hub)——无法解析 Dev Hub 时必须停止操作;建议改用my-dev-hub。sf org login web --set-default-dev-hub - 对于 create,确认 source org 和 snapshot name——source 必须是 scratch org;名称在 Dev Hub 中必须唯一,且长度不超过 15 个字符。
- 通过 Bash 工具执行,并带上 flag。
--json - 报告结果(见输出预期和示例文件)。
Command Patterns
命令模式
| Operation | User intent | Execute via Bash tool |
|---|---|---|
| Create | Create snapshot with name only | |
| Create | Create snapshot with description | |
| Create | Specify Dev Hub explicitly | |
| Get | Check a snapshot's status/details | |
| List | List all snapshots in the Dev Hub | |
| List | List snapshots expiring within N days | |
| Delete | Delete a snapshot (with confirm prompt) | |
| Delete | Delete without prompting (scripts/CI) | |
| Delete | Delete multiple/all snapshots | First |
Snapshot creation is asynchronous. returns a record whose is typically initially, with still . Poll with until is (verified live against a real Dev Hub — see vs ) before using the snapshot to create scratch orgs.
createStatusInProgressExpirationDatenullsf org get snapshotStatusActiveexamples/create_success_output.jsonexamples/get_output.json| 操作 | 用户意图 | 通过 Bash 工具执行 |
|---|---|---|
| Create | 仅使用名称创建 snapshot | |
| Create | 创建带 description 的 snapshot | |
| Create | 显式指定 Dev Hub | |
| Get | 检查 snapshot 的状态/详情 | |
| List | 列出 Dev Hub 中的所有 snapshot | |
| List | 列出将在 N 天内过期的 snapshot | |
| Delete | 删除 snapshot(带确认提示) | |
| Delete | 删除但不提示(脚本/CI) | |
| Delete | 删除多个/全部 snapshot | 首先执行 |
Snapshot 创建是异步操作。 返回的记录最初通常具有 = ,同时 仍为 。使用 轮询,直到 变为 (已在真实 Dev Hub 上验证——见 与 ),然后再使用该 snapshot 创建 scratch org。
createStatusInProgressExpirationDatenullsf org get snapshotStatusActiveexamples/create_success_output.jsonexamples/get_output.jsonRules / Constraints
规则/限制
| Constraint | Rationale |
|---|---|
Always use | Provides structured output for reliable parsing and error handling |
| All commands operate against a Dev Hub | |
| Dev Hub must have Scratch Org Snapshots enabled | Otherwise commands fail — contact Salesforce to enable it |
| Source org (create) must be a scratch org | Snapshots only work with scratch orgs |
| Snapshot names must be unique in the Dev Hub, ≤15 characters | Longer names fail with |
| Creation is asynchronous | |
| There is no update/rename/extend-expiration command. | Verified — the CLI (and the underlying platform object) exposes only create/get/list/delete. To change a snapshot's name, description, or expiration, delete it and create a new one. |
| There is no bulk-delete command. | Each |
| Returns every visible snapshot; filter status/expiry client-side (e.g. with |
| Use |
Bulk/ | Before deleting multiple or all snapshots — or any delete with |
| Permissions affect visibility/deletion | Users see/delete only their own snapshots unless a Dev Hub admin grants View All / Modify All |
| 限制 | 原因 |
|---|---|
始终使用 | 提供结构化输出,以便可靠地解析和处理错误 |
| 所有命令都针对 Dev Hub 操作 | 使用 |
| Dev Hub 必须启用 Scratch Org Snapshots | 否则命令将失败——请联系 Salesforce 启用该功能 |
| Source org(create)必须是 scratch org | Snapshot 仅适用于 scratch org |
| Snapshot 名称在 Dev Hub 中必须唯一,且不超过 15 个字符 | 更长的名称会触发 |
| 创建过程是异步的 | |
| 没有更新/重命名/延长过期时间的命令。 | 已验证——CLI(以及底层 platform object)仅公开 create/get/list/delete。若要更改 snapshot 的名称、description 或 expiration,请删除后重新创建。 |
| 没有批量删除命令。 | 每次 |
| 返回所有可见 snapshot;在客户端筛选状态/过期时间(例如使用 |
| 在非交互式/CI 场景中使用 |
批量删除或使用 | 在删除多个或全部 snapshot 之前,或对任何使用 |
| 权限会影响可见性和删除权限 | 除非 Dev Hub 管理员授予 View All / Modify All 权限,否则用户只能查看/删除自己的 snapshot |
Troubleshooting
故障排除
| Issue | Resolution |
|---|---|
| Snapshot commands live in the |
| The Dev Hub lacks the snapshot feature — contact Salesforce to enable it |
| Verified live on |
| Verified live — the |
Snapshot name already exists ( | Names must be unique per Dev Hub — choose a different name |
| Creation is asynchronous — keep polling |
| Read the |
| The targeted org isn't a Dev Hub — point |
| No default Dev Hub org found | Provide |
| 问题 | 解决方案 |
|---|---|
| Snapshot 命令位于 |
| Dev Hub 缺少 snapshot 功能——请联系 Salesforce 启用该功能 |
| 已在 |
| 已实时验证—— |
Snapshot 名称已存在( | 名称在每个 Dev Hub 中必须唯一——请选择其他名称 |
| 创建过程是异步的——持续使用 |
| 读取 |
| 目标 org 不是 Dev Hub——请将 |
| 未找到默认 Dev Hub org | 提供 |
Output Expectations
输出预期
All commands return JSON when is used. / return the raw sobject record(s) — verified live, these include the sobject wrapper plus , , , (, , , , , or ), , , , ( until ), and .
--jsongetlistOrgSnapshotattributesIdSnapshotNameDescriptionStatusNewInProgressActiveErrorExpiredDeletedSourceOrgCreatedDateLastModifiedDateExpirationDatenullActiveError- Create → a single snapshot record (is
Statusimmediately after creation;InProgressisExpirationDate).null - Get → a single snapshot record — use it to poll .
Status - List → an array of snapshot records, ordered by . Empty array if none exist.
CreatedDate - Delete → . No result if the user declines the confirmation prompt.
{ "id": "0Oo...", "success": true, "errors": [] }
See the example files below for exact response structures (captured live against a real Dev Hub, not assumed).
使用 时,所有命令都会返回 JSON。/ 返回原始 sobject 记录——已实时验证,这些记录包含 sobject wrapper,以及 、、、(、、、、 或 )、、、、(在 之前为 )和 。
--jsongetlistOrgSnapshotattributesIdSnapshotNameDescriptionStatusNewInProgressActiveErrorExpiredDeletedSourceOrgCreatedDateLastModifiedDateExpirationDateActivenullError- Create → 单个 snapshot 记录(创建后 立即为
Status;InProgress为ExpirationDate)。null - Get → 单个 snapshot 记录——使用它轮询 。
Status - List → snapshot 记录数组,按 排序。如果不存在,则返回空数组。
CreatedDate - Delete → 。如果用户拒绝确认提示,则不会返回结果。
{ "id": "0Oo...", "success": true, "errors": [] }
请参阅下方示例文件了解精确的响应结构(这些结构均来自真实 Dev Hub 的实时捕获,并非假设)。
Cross-Skill Integration
跨 Skill 集成
| Need | Delegate to |
|---|---|
| Create a scratch org from a snapshot | |
| Create/list/delete an org shape instead of a snapshot | |
| 需求 | 委托给 |
|---|---|
| 从 snapshot 创建 scratch org | |
| 创建/列出/删除 org shape 而非 snapshot | |
Reference File Index
参考文件索引
| File | When to read |
|---|---|
| Detailed flag reference across create/get/list/delete, including the |
| Using a snapshot name in a scratch org definition file, once it's |
| 文件 | 阅读时机 |
|---|---|
| create/get/list/delete 的详细 flag 参考,包括筛选即将过期 snapshot 的 |
| snapshot 变为 |
Example Files
示例文件
| File | Purpose |
|---|---|
| Successful snapshot creation ( |
| |
| Get response for an |
| List response — array of snapshot records |
| Successful delete response |
| 文件 | 用途 |
|---|---|
| 成功创建 snapshot( |
| |
| |
| List 响应——snapshot 记录数组 |
| 成功删除的响应 |